-
Notifications
You must be signed in to change notification settings - Fork 41
/
setup.py
136 lines (113 loc) · 3.95 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
Setup for SasView
TODO: Add checks to see that all the dependencies are on the system
"""
from typing import List
import os
import subprocess
import shutil
import sys
from setuptools import setup, Command, find_packages
# Manage version number
version_file = os.path.join("src", "sas", "system", "version.py")
with open(version_file) as fid:
for line in fid:
if line.startswith('__version__'):
VERSION = line.split('"')[1]
break
else:
raise ValueError(f"Could not find version in {version_file}")
CURRENT_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
SASVIEW_BUILD = os.path.join(CURRENT_SCRIPT_DIR, "build")
# Optionally clean before build.
dont_clean = 'update' in sys.argv
if dont_clean:
sys.argv.remove('update')
elif os.path.exists(SASVIEW_BUILD):
print("Removing existing build directory", SASVIEW_BUILD, "for a clean build")
shutil.rmtree(SASVIEW_BUILD)
# Class that manages the sphinx build stuff
class BuildSphinxCommand(Command):
description = "Build Sphinx documentation."
user_options = []
def initialize_options(self):
self.cwd = None
def finalize_options(self):
self.cwd = os.getcwd()
def run(self):
"""
First builds the sasmodels documentation if the directory
is present. Then builds the sasview docs.
"""
SASMODELS_DOCPATH = os.path.abspath(os.path.join(os.getcwd(), '..', 'sasmodels', 'doc'))
print("========= check for sasmodels at", SASMODELS_DOCPATH, "============")
if os.path.exists(SASMODELS_DOCPATH):
if os.path.isdir(SASMODELS_DOCPATH):
# if available, build sasmodels docs
print("============= Building sasmodels model documentation ===============")
smdocbuild = subprocess.call([
"make",
"PYTHON=%s" % sys.executable,
"-C", SASMODELS_DOCPATH,
"html"
])
else:
# if not available warning message
print("== !!WARNING!! sasmodels directory not found. Cannot build model docs. ==")
#Now build sasview (+sasmodels) docs
sys.path.append("docs/sphinx-docs")
import build_sphinx
build_sphinx.rebuild()
# _standard_ commands which should trigger the Qt build
build_commands = [
'install', 'build', 'build_py', 'bdist', 'bdist_egg', 'bdist_rpm',
'bdist_wheel', 'develop', 'test'
]
print(sys.argv)
# determine if this run requires building of Qt GUI ui->py
build = any(c in sys.argv for c in build_commands)
force_rebuild = "-f" if 'rebuild_ui' in sys.argv or 'clean' in sys.argv else ""
if 'rebuild_ui' in sys.argv:
sys.argv.remove('rebuild_ui')
if build:
# build qt
_ = subprocess.call([sys.executable, "src/sas/qtgui/convertUI.py", force_rebuild])
# download external dependencies
from build_tools.get_external_dependencies import fetch_external_dependencies
fetch_external_dependencies()
# Required packages
required = [
'bumps>=0.7.5.9', 'periodictable>=1.5.0', 'pyparsing>=2.0.0',
'lxml',
]
if os.name == 'nt':
required.extend(['html5lib', 'reportlab'])
else:
# 'pil' is now called 'pillow'
required.extend(['pillow'])
# Run setup
setup(
name="sasview",
version=VERSION,
description="SasView application",
author="SasView Team",
author_email="[email protected]",
url="http://sasview.org",
license="PSF",
keywords="small-angle x-ray and neutron scattering analysis",
download_url="https://github.com/SasView/sasview.git",
packages=find_packages(where="src"),
package_dir={"": "src"},
ext_modules=[],
install_requires=required,
zip_safe=False,
include_package_data=True,
entry_points={
'console_scripts': [
"sasview=sas.qtgui.MainWindow.MainWindow:run_sasview",
]
},
cmdclass={'docs': BuildSphinxCommand},
)