-
Notifications
You must be signed in to change notification settings - Fork 8
/
setup.py
75 lines (62 loc) · 2.82 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
from setuptools import setup, find_namespace_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
import subprocess
import sys
import pathlib
from pytom import __version__
def find_executables():
bin_folder = pathlib.Path('pytom/bin')
# exclude entry points as well
executables = [str(path) for path in bin_folder.iterdir() if path.is_file() and '__' not in path.name and path.name != "coords2PL.py"]
return executables + [str(bin_folder.joinpath(f)) for f in ['pytom', 'ipytom', 'pytomGUI']]
def compile_pytom(miniconda_dir):
install_command = f'{sys.executable} compile.py --target all'
if miniconda_dir.exists():
install_command += f' --minicondaEnvDir {miniconda_dir}'
process = subprocess.Popen(install_command, shell=True, cwd="pytom/pytomc")
process.wait()
class PyTomInstaller(install):
def run(self):
compile_pytom(pathlib.Path(self.prefix))
install.run(self)
class PyTomDeveloper(develop):
def run(self):
compile_pytom(pathlib.Path(self.prefix))
develop.run(self)
"""Hacky solution, but we cannot rely on the script linking of pip in develop-mode. Pip will put scripts in the
miniconda bin that have a different shebang than the original ones. However, we need the pytom shebang for GPU
scripts to execute. Only then is the GPU environment variable properly set. Updating gpu code to the cupy
advised agnostic setup (as put in PyTomPrivate issue #117) should also solve this."""
miniconda_bin = pathlib.Path(self.prefix)
scripts = find_executables()
for script in scripts:
script_path = pathlib.Path(script)
symlink_path = miniconda_bin.joinpath('bin', script_path.name)
symlink_path.unlink()
symlink_path.symlink_to(script_path.absolute())
setup(
name='pytom',
version=__version__,
packages=find_namespace_packages(include=['pytom*']),
package_dir={'pytom': 'pytom'},
package_data={
'pytom.angles.angleLists': ['*.em'],
'pytom.simulation.detectors': ['*.csv'],
'pytom.simulation.membrane_models': ['*.pdb']
},
data_files=[("pytom_data", ["./LICENSE.txt"])], # This is a relative dir to sys.prefix
include_package_data=True,
author='`FridoF',
author_email='[email protected]',
url='https://github.com/SBC-Utrecht/PyTom.git',
install_requires=['lxml', 'scipy', 'boost', 'numpy>=1.18,<2'],
extras_require={
'gpu': ['cupy'],
'gui': ['PyQt5', 'pyqtgraph', 'mrcfile'],
'all': ['cupy', 'PyQt5', 'pyqtgraph', 'mrcfile']},
cmdclass={'install': PyTomInstaller,
'develop': PyTomDeveloper},
scripts=find_executables(),
entry_points={'console_scripts': ['coords2PL.py = pytom.convert.coords2PL:entry_point']}
)