Skip to content

Commit 4278edd

Browse files
Joe Jevnikllllllllll
authored andcommitted
BLD: magic build incantations
1 parent 8af544b commit 4278edd

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

MANIFEST.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
# buildtime data
12
include Makefile
23
include etc/detect-compiler.cc
34
include etc/build-and-run
45
include etc/ext_suffix.py
56
include etc/asan-path
67
include etc/python_version.py
78
include version
9+
recursive-include src/ *.cc
10+
recursive-include include/ *.h
811

12+
# runtime data
913
include LICENSE
10-
include libpy/libpy.so
1114
include libpy/_build-and-run
1215
include libpy/_detect-compiler.cc
1316
recursive-include libpy *.h

setup.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import ast
2+
from distutils.command.build_py import build_py as _build_py
23
import os
3-
import sys
4+
import shutil
45

5-
from setuptools import setup, find_packages
6+
from setuptools import setup
67

78

89
class BuildFailed(Exception):
@@ -18,15 +19,29 @@ class BuildFailed(Exception):
1819
# advanced feature and shouldn't be used without care as it may produce invalid
1920
# installs of ``libpy``.
2021
dont_build = ast.literal_eval(os.environ.get('LIBPY_DONT_BUILD', '0'))
21-
if 'build_ext' in sys.argv or 'egg_info' in sys.argv and not dont_build:
22-
path = os.path.dirname(os.path.abspath(__file__))
23-
command = 'make -C "%s"' % path
24-
out = os.system(command)
25-
if out:
26-
raise BuildFailed(
27-
"Command {!r} failed with code {}".format(command, out)
22+
23+
24+
class build_py(_build_py):
25+
def run(self):
26+
if self.dry_run or dont_build:
27+
return super().run()
28+
29+
super().run()
30+
path = os.path.dirname(os.path.abspath(__file__))
31+
command = 'make -C "%s" libpy/libpy.so' % path
32+
out = os.system(command)
33+
if out:
34+
raise BuildFailed(
35+
"Command {!r} failed with code {}".format(command, out)
36+
)
37+
38+
print(os.listdir('libpy'))
39+
shutil.copyfile(
40+
'libpy/libpy.so',
41+
os.path.join(self.build_lib, 'libpy', 'libpy.so'),
2842
)
2943

44+
3045
setup(
3146
name='libpy',
3247
url='https://github.com/quantopian/libpy',
@@ -53,6 +68,7 @@ class BuildFailed(Exception):
5368
# we need the headers to be available to the C compiler as regular files;
5469
# we cannot be imported from a ziparchive.
5570
zip_safe=False,
56-
include_package_data=True,
5771
install_requires=['numpy'],
72+
cmdclass={'build_py': build_py},
73+
package_data={'libpy': ['include/**/*.h']},
5874
)

0 commit comments

Comments
 (0)