forked from jmp1985/guanaco
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
82 lines (65 loc) · 2.17 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
#
# Copyright (C) 2019 James Parkhurst
#
# This code is distributed under the GPLv3 license.
#
import os
import subprocess
import sys
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
class CMakeBuild(build_ext):
"""
Build the extensions
"""
def build_extensions(self):
# Set the cmake directory
cmake_lists_dir = os.path.abspath(".")
# Ensure the build directory exists
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)
# Run Cmake once
ext = self.extensions[0]
# Get the directory
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# Arguments to cmake
cmake_args = [
"-DCMAKE_BUILD_TYPE=%s" % "Release",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%s" % extdir,
"-DPYTHON_EXECUTABLE=%s" % sys.executable,
]
# Config and the extension
subprocess.check_call(
["cmake", cmake_lists_dir] + cmake_args, cwd=self.build_temp
)
# Build the extension
subprocess.check_call(["cmake", "--build", "."], cwd=self.build_temp)
def main():
"""
Setup the package
"""
tests_require = ["pytest", "pytest-cov", "mock", "scipy"]
setup(
package_dir={"": "src"},
packages=find_packages(where="src"),
install_requires=["mrcfile", "numpy", "pyyaml"],
tests_require=tests_require,
test_suite="tests",
ext_modules=[Extension("guanaco_ext", [])],
cmdclass={"build_ext": CMakeBuild},
use_scm_version={"write_to": "src/guanaco/_version.py"},
entry_points={
"console_scripts": [
"guanaco=guanaco.command_line:main",
"guanaco.plot_ctf=guanaco.command_line:plot_ctf",
"guanaco.generate_ctf=guanaco.command_line:generate_ctf",
"guanaco.correct=guanaco.command_line:correct",
]
},
extras_require={
"build_sphinx": ["sphinx", "sphinx_rtd_theme"],
"test": tests_require,
},
)
if __name__ == "__main__":
main()