Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
else:
from distutils.core import setup, Extension
from distutils.command.bdist_rpm import bdist_rpm
from distutils.command.build import build
from distutils.command.install import INSTALL_SCHEMES

class bdist_rpm_custom(bdist_rpm):
Expand All @@ -28,6 +29,21 @@ def finalize_package_data (self):
self.no_autoreq = 1
bdist_rpm.finalize_package_data(self)

# Build extensions before python modules, so the generated pythonlsf/lsf.py
# file is created before attempting to install it. This makes building with
# "pip" easier.
# See:
# https://bugs.python.org/issue2624
# https://bugs.python.org/issue1016626
# https://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
# https://stackoverflow.com/questions/50239473/building-a-module-with-setuptools-and-swig

class build_ext_first(build):
def finalize_options(self):
super().finalize_options()
new_order = list(filter(lambda x: x[0] == 'build_ext', self.sub_commands)) + list(filter(lambda x: x[0] != 'build_ext', self.sub_commands))
self.sub_commands[:] = new_order

def get_lsf_libdir():
try:
_lsf_envdir = os.environ['LSF_ENVDIR']
Expand Down Expand Up @@ -145,7 +161,8 @@ def set_gccflag_lsf_version():
extra_objects=lsf_static_lib,
libraries=lsf_dynamic_lib)],
py_modules=['pythonlsf.lsf'],
cmdclass = { 'bdist_rpm': bdist_rpm_custom },
cmdclass = { 'bdist_rpm': bdist_rpm_custom,
'build': build_ext_first },
classifiers=["Development Status :: 2 - Pre-Alpha",
"License :: OSI Approved :: Eclipse Public License",
"Operating System :: OS Independent",
Expand Down