Skip to content

Commit

Permalink
trying to fix the install process
Browse files Browse the repository at this point in the history
  • Loading branch information
cwiede committed Mar 26, 2020
1 parent e14cfce commit 136f196
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 16 deletions.
74 changes: 62 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")]
Expand All @@ -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={
Expand Down
14 changes: 10 additions & 4 deletions workspace/SConstruct
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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")
Expand Down

0 comments on commit 136f196

Please sign in to comment.