forked from psychopy/psychopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·101 lines (82 loc) · 2.89 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Install PsychoPy to your current Python dist, including requirements
usage::
pip install psychopy
pip install . # to install from within the repository
pip install -e . # to install a link instead of copying the files
"""
from setuptools import setup, find_packages
from setuptools.config import read_configuration
import os
from os.path import exists, join
from sys import platform, argv
with open('version') as f:
version = f.read().strip()
#
# Special handling for Anaconda / Miniconda
#
required = read_configuration('setup.cfg')['options']['install_requires']
# OpenCV
# Naming conflict with PyPI package.
# `opencv` package should be installed via conda instead
if 'CONDA_PREFIX' in os.environ:
required.remove('opencv-python')
# PyQt
# Naming conflict with PyPI package.
# `pyqt` package should be installed via conda instead
# cf. https://github.com/ContinuumIO/anaconda-issues/issues/1554
if 'CONDA_PREFIX' in os.environ:
required.remove('pyqt5')
# compress psychojs to a zip file for packaging
# only takes 0.5s but could skip if you prefer
if ('-noJS' in argv) or not exists('psychojs') or ('clean' in argv):
pass
else:
import shutil
shutil.make_archive(join('psychopy', 'psychojs'),
'zip', 'psychojs')
# regenerate __init__.py only if we're in the source repos (not in a source
# zip file)
try:
from building import createInitFile # won't exist in a sdist.zip
writeNewInit = True
except ImportError:
writeNewInit = False
if writeNewInit:
# determine what type of dist is being created
# (install and bdist might do compiliing and then build platform is needed)
for arg in argv:
if arg.startswith('bdist') or arg.startswith('install'):
dist = 'bdist'
else:
dist = 'sdist'
createInitFile.createInitFile(dist=dist)
packages = find_packages()
# define the extensions to compile if necessary
# for the source dist this doesn't work - use the manifest.in file
dataExtensions = ['*.txt', '*.ico', '*.jpg', '*.gif', '*.png', '*.mov',
'*.spec', '*.csv', '*.psyexp', '*.xlsx', '.zip']
dataFiles = []
if platform == 'win32':
pass
elif platform == 'darwin':
dataExtensions.extend(['*.icns'])
elif platform == 'posix':
dataFiles += [('share/applications',
['psychopy/app/Resources/psychopy.desktop']),
('share/pixmaps',
['psychopy/app/Resources/psychopy.png'])]
setup(name='PsychoPy',
packages=packages,
include_package_data=True,
package_data={
# If any package contains *.txt or *.rst files, include them:
'': dataExtensions,
},
data_files=dataFiles,
install_requires=required,
version=version)
# remove unwanted info about this system post-build
if writeNewInit:
createInitFile.createInitFile(dist=None)