From 136f196d675318069edbd7c8927862653c97ed27 Mon Sep 17 00:00:00 2001 From: Christoph Wiedemann <62332054+cwiede@users.noreply.github.com> Date: Thu, 26 Mar 2020 14:50:18 +0100 Subject: [PATCH] trying to fix the install process --- setup.py | 74 +++++++++++++++++++++++++++++++++++++------- workspace/SConstruct | 14 ++++++--- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index bac8719..39ae218 100644 --- a/setup.py +++ b/setup.py @@ -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='62332054+cwiede@users.noreply.github.com', + 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={ diff --git a/workspace/SConstruct b/workspace/SConstruct index 3ce6e48..a4e07ec 100644 --- a/workspace/SConstruct +++ b/workspace/SConstruct @@ -1,17 +1,23 @@ import platform +import PySide2 + +qtversion = ".".join(PySide2.__version__.split(".")[:2]) if platform.system() == "Linux": env = Environment(target_platform="linux_x86_64", + QT5VERSION=qtversion, toolpath=["#/sconstools3"], variant="unknown") + env.Tool("qt5") + env['ENV']['PKG_CONFIG_PATH'] = env.subst("$QT5DIR") + '/lib/pkgconfig' env.PrependENVPath('LD_LIBRARY_PATH', env.subst("$QT5DIR") + "/lib") - env.Tool("qt5") else: # windows environment env = Environment(MSVC_VERSION="14.0", + QT5VERSION=qtversion, tools=["default", "qt5"], toolpath=["#/sconstools3"], target_platform="msvc_x86_64", @@ -20,18 +26,18 @@ else: env.EnableQt5Modules(['QtCore']) env.AddMethod(lambda env, args: args, "RegisterSources") env.AddMethod(lambda env, args: None, "RegisterTargets") +env.Append(CPPDEFINES=["Py_LIMITED_API"]) if platform.system() == "Linux": dbg_env = env.Clone(CCFLAGS=Split("-g -std=c++14 -O0"), #-fvisibility=hidden LINKFLAGS=Split("-g"), - variant="debug") + variant="nonopt") rel_env = env.Clone(CCFLAGS=Split("-std=c++14 -O3"), #-fvisibility=hidden variant="release") else: dbg_env = env.Clone(CCFLAGS=Split("/nologo /EHsc /TP /W3 /Od /Ob2 /Z7 /MD /std:c++14"), LINKFLAGS=Split("/nologo /DEBUG"), - variant="nonopt", - CPPDEFINES=["Py_LIMITED_API"]) # not exactly sure why we need this in debug mode and not in release mode... + variant="nonopt") # not exactly sure why we need this in debug mode and not in release mode... rel_env = env.Clone(CCFLAGS=Split("/nologo /EHsc /TP /W3 /Ox /Z7 /MD /std:c++14"), LINKFLAGS=Split("/nologo /DEBUG"), variant="release")