-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
196 lines (178 loc) · 7.92 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020 ifm electronic gmbh
#
# THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
#
import glob
import os
import sys
import pathlib
import platform
import sysconfig
import setuptools
from setuptools.command.install import install
import subprocess
import shutil
import multiprocessing
from setuptools.command.build_ext import build_ext
from distutils.core import setup
from distutils.command.install import INSTALL_SCHEMES
if not int(os.environ.get("DO_NOT_REMOVE_BINARIES", "0")):
# remove build results
for p in ["nexxT/binary", "nexxT/tests/binary"]:
if os.path.exists(p):
shutil.rmtree(p, ignore_errors=True)
if os.path.exists(p):
shutil.rmtree(p, ignore_errors=True)
if os.path.exists(p):
shutil.rmtree(p, ignore_errors=True)
# create platform specific wheel
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False
self.root_is_purelib = False
#if platform.system() == "Linux":
# self.py_limited_api = "abi3"
def get_tag(self):
python, abi, plat = _bdist_wheel.get_tag(self)
# uncomment for non-python extensions
if platform.system() == "Linux" and platform.machine() == "x86_64":
plat = "manylinux_2_28_x86_64"
abi = "abi3"
python = "cp37"
print("plat=", plat)
return python, abi, plat
except ImportError:
print("Warning: wheel is not installed but it is recommended for building nexxT.")
bdist_wheel = None
class InstallPlatlib(install):
def finalize_options(self):
install.finalize_options(self)
# force platlib
self.install_lib = self.install_platlib
class BinaryDistribution(setuptools.Distribution):
"""Distribution which always forces a binary package with platform name"""
def has_ext_modules(*args):
#print("HAS_EXT_MODULES WAS CALLED!")
return True
def is_pure(*args):
#print("IS_PURE WAS CALLED!")
return False
#def get_option_dict(self, k):
# res = super().get_option_dict(k)
# #if k == "install":
# # res["install_lib"] = "platlib"
# #print("GET_OPTION_DICT CALLED:", k, res)
# return res
if platform.system() == "Linux":
p = "linux_" + platform.machine()
presuf = [("lib", ".so")]
else:
p = "msvc_x86_64"
presuf = [("", ".dll"), ("", ".exp"), ("", ".lib")]
cv = sysconfig.get_config_vars()
if platform.system() == "Windows":
cnexT = cv.get("EXT_PREFIX", "") + "cnexxT.pyd"
elif platform.system() == "Linux":
cnexT = cv.get("EXT_PREFIX", "") + "cnexxT.abi3.so"
build_files = []
for variant in ["nonopt", "release"]:
build_files.append('nexxT/binary/' + p + '/' + variant + "/" + cnexT)
for prefix,suffix in presuf:
build_files.append('nexxT/binary/' + p + '/' + variant + "/" + prefix + "nexxT" + suffix)
build_files.append('nexxT/tests/binary/' + p + '/' + variant + "/" + prefix + "test_plugins" + suffix)
# ok, this is hacky but it is a way to easily include build artefacts into the wheels and this is
# the intention here, drawback is that sdist needs to be generated by a seperate setup.py call
if "bdist_wheel" in sys.argv:
if "sdist" in sys.argv:
raise RuntimeError("cannot build sdist and bdist_wheel with one call.")
build_required = True
else:
build_required = False
# generate MANIFEST.in to add build files and include files
with open("MANIFEST.in", "w") as manifest:
manifest.write("include nexxT/examples/*/*.json\n")
manifest.write("include nexxT/examples/*/*.py\n")
manifest.write("include nexxT/core/*.json\n")
manifest.write("include nexxT/tests/core/*.json\n")
manifest.write("include workspace/*.*\n")
manifest.write("include workspace/SConstruct\n")
manifest.write("include workspace/sconstools3/qt5/__init__.py\n")
manifest.write("include LICENSE\n")
manifest.write("include NOTICE\n")
if build_required:
manifest.write("include nexxT/include/nexxT/*.hpp\n")
for bf in build_files:
manifest.write("include " + bf + "\n")
manifest.write("exclude nexxT/src/*.*\n")
manifest.write("exclude nexxT/tests/src/*.*\n")
else:
manifest.write("include nexxT/src/*.*\n")
manifest.write("include nexxT/tests/src/*.*\n")
if build_required:
try:
if os.environ.get("PYSIDEVERSION", "6") in "6":
import PySide6
else:
raise RuntimeError("Don't know what to do with PYSIDEVERSION=%s" % os.environ.get("PYSIDEVERSION", "6"))
except ImportError:
raise RuntimeError("PySide%s must be installed for building the extension module." % os.environ.get("PYSIDEVERSION", "6"))
cwd = pathlib.Path().absolute()
os.chdir("workspace")
if platform.system() == "Linux":
subprocess.run([sys.executable, os.path.dirname(sys.executable) + "/scons", "-j%d" % multiprocessing.cpu_count(), ".."], check=True)
else:
subprocess.run([os.path.join(os.path.dirname(sys.executable), "scons.exe"), "-j%d" % multiprocessing.cpu_count(), ".."], check=True)
os.chdir(str(cwd))
setup(name='nexxT',
install_requires=[
"PySide6==6.8.2",
"shiboken6==6.8.2",
"jsonschema>=3.2.0",
"h5py>=2.10.0",
"setuptools>=41.0.0",
'importlib-metadata >= 1.0 ; python_version < "3.8"',
"pip-licenses",
],
version=os.environ.get("NEXXT_VERSION", "0.0.0"),
description='An extensible framework.',
author='Christoph Wiedemann',
author_email='[email protected]',
url='https://github.com/ifm/nexxT',
license="Apache-2",
include_package_data = True,
packages=['nexxT', 'nexxT.interface', 'nexxT.tests', 'nexxT.services', 'nexxT.services.gui', 'nexxT.filters',
'nexxT.tests.interface', 'nexxT.core', 'nexxT.tests.core', 'nexxT.tests.integration',
'nexxT.examples', 'nexxT.examples.videoplayback'],
cmdclass={
'bdist_wheel': bdist_wheel,
'install': InstallPlatlib,
},
entry_points = {
'console_scripts' : ['nexxT-gui=nexxT.core.AppConsole:mainGui',
'nexxT-console=nexxT.core.AppConsole:mainConsole',
],
'nexxT.filters' : [
'harddisk.HDF5Reader = nexxT.filters.hdf5:Hdf5Reader',
'harddisk.HDF5Writer = nexxT.filters.hdf5:Hdf5Writer',
'examples.videoplayback.AviReader = nexxT.examples:AviReader',
'examples.framework.CameraGrabber = nexxT.examples:CameraGrabber',
'examples.framework.ImageBlur = nexxT.examples.framework.ImageBlur:ImageBlur',
'examples.framework.ImageView = nexxT.examples.framework.ImageView:ImageView',
'tests.nexxT.CSimpleSource = nexxT.tests:CSimpleSource',
'tests.nexxT.PySimpleSource = nexxT.tests.interface.SimpleStaticFilter:SimpleSource',
'tests.nexxT.PySimpleStaticFilter = nexxT.tests.interface.SimpleStaticFilter:SimpleStaticFilter',
'tests.nexxT.PySimpleView = nexxT.tests.interface.SimpleStaticFilter:SimpleView',
'tests.nexxT.PySimpleDynInFilter = nexxT.tests.interface.SimpleDynamicFilter:SimpleDynInFilter',
'tests.nexxT.PySimpleDynOutFilter = nexxT.tests.interface.SimpleDynamicFilter:SimpleDynOutFilter',
'tests.nexxT.CTestExceptionFilter = nexxT.tests:CTestExceptionFilter',
'tests.nexxT.CPropertyReceiver = nexxT.tests:PropertyReceiver',
'tests.nexxT.PyTestExceptionFilter = nexxT.tests.interface.TestExceptionFilter:TestExceptionFilter',
],
},
distclass=BinaryDistribution,
)