-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,25 @@ | |
import glob | ||
import os | ||
import sys | ||
import pathlib | ||
import platform | ||
import sysconfig | ||
import setuptools | ||
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 | ||
|
||
# remove build results | ||
for p in ["nexxT/binary", "nexxT/include", "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) | ||
# create platform specific wheel | ||
try: | ||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel | ||
|
@@ -29,11 +40,17 @@ def finalize_options(self): | |
def get_tag(self): | ||
python, abi, plat = _bdist_wheel.get_tag(self) | ||
# uncomment for non-python extensions | ||
#python, abi = 'py3', 'none' | ||
if platform.system() == "Linux": | ||
abi = "abi3" | ||
else: | ||
abi = "none" | ||
python = "cp37.cp38.cp39" | ||
print("plat=", plat) | ||
return python, abi, plat | ||
|
||
except ImportError: | ||
bdist_wheel = None | ||
|
||
if platform.system() == "Linux": | ||
p = "linux_x86_64" | ||
presuf = [("lib", ".so")] | ||
|
@@ -43,28 +60,61 @@ def get_tag(self): | |
|
||
|
||
cv = sysconfig.get_config_vars() | ||
cnexT = cv.get("EXT_PREFIX", "") + "cnexxT" + cv.get("EXT_SUFFIX", "") | ||
if platform.system() == "Windows": | ||
cnexT = cv.get("EXT_PREFIX", "") + "cnexxT" + cv.get("EXT_SUFFIX", "") | ||
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) | ||
|
||
# generate MANIFEST.in to add build files and include files | ||
with open("MANIFEST.in", "w") as manifest: | ||
for fn in glob.glob('nexxT/include/*.hpp'): | ||
manifest.write("include " + fn + "\n") | ||
for bf in build_files: | ||
manifest.write("include " + bf + "\n") | ||
# json schema | ||
manifest.write("include nexxT/core/ConfigFileSchema.json") | ||
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/src/*.*\n") | ||
manifest.write("include nexxT/tests/src/*.*\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") | ||
# 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 | ||
build_required = False | ||
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 | ||
for fn in glob.glob('nexxT/include/*.hpp'): | ||
manifest.write("include " + fn + "\n") | ||
for bf in build_files: | ||
manifest.write("include " + bf + "\n") | ||
|
||
if build_required: | ||
try: | ||
import PySide2 | ||
except ImportError: | ||
raise RuntimeError("PySide2 must be installed for building the extension module.") | ||
cwd = pathlib.Path().absolute() | ||
os.chdir("workspace") | ||
subprocess.run([sys.executable, os.path.dirname(sys.executable) + "/scons", "-j%d" % multiprocessing.cpu_count(), ".."], check=True) | ||
os.chdir(str(cwd)) | ||
|
||
setup(name='nexxT', | ||
install_requires=["PySide2 >=5.14.0, <5.15", "shiboken2 >=5.14.0, <5.15", "jsonschema>=3.2.0"], | ||
version='0.0.0', | ||
description='nexxT extensible framework', | ||
author='pca', | ||
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.tests.interface', 'nexxT.core', 'nexxT.tests.core'], | ||
cmdclass={ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters