Skip to content

Added build wrapper so build_ext runs before build_py #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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