Skip to content

Commit a0b9aaa

Browse files
authored
Merge pull request #59 from Tieqiong/wheel
update wheel setup
2 parents 1ca5b1d + 9fc29ac commit a0b9aaa

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

.github/workflows/build-wheel-release-upload.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Release (GitHub/PyPI) and Deploy Docs
33
on:
44
workflow_dispatch:
55
push:
6-
branches:
7-
- "**"
86
tags:
97
- "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml
108

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ global-exclude .DS_Store # Exclude Mac filesystem artifacts.
1111
global-exclude __pycache__ # Exclude Python cache directories.
1212
global-exclude .git* # Exclude git files and directories.
1313
global-exclude .idea # Exclude PyCharm project settings.
14+
global-exclude SConscript.configure SConscript # SCons build scripts

requirements/pip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
setuptools
12
numpy

setup.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,31 @@
2020

2121

2222
def get_boost_libraries():
23-
base_lib = "boost_python"
24-
major, minor = str(sys.version_info[0]), str(sys.version_info[1])
25-
tags = [f"{major}{minor}", major, ""]
26-
mttags = ["", "-mt"]
27-
candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib]
28-
for lib in candidates:
29-
if find_library(lib):
30-
return [lib]
23+
# the names we'll search for
24+
major, minor = sys.version_info[:2]
25+
candidates = [
26+
f"boost_python{major}{minor}",
27+
f"boost_python{major}",
28+
"boost_python",
29+
]
30+
31+
conda_prefix = os.environ.get("CONDA_PREFIX")
32+
if conda_prefix:
33+
libdir = os.path.join(conda_prefix, "lib")
34+
for name in candidates:
35+
so = f"lib{name}.so"
36+
if os.path.isfile(os.path.join(libdir, so)):
37+
# return the plain "boost_python311" etc (no "lib" prefix or ".so")
38+
return [name]
39+
40+
# fallback to ldconfig
41+
for name in candidates:
42+
found = find_library(name)
43+
if found:
44+
# find_library may return "libboost_python3.so.1.74.0" etc
45+
# strip off lib*.so.* if you like, or just return name
46+
return [name]
47+
3148
raise RuntimeError("Cannot find a suitable Boost.Python library.")
3249

3350

@@ -92,10 +109,11 @@ def create_extensions():
92109
return [ext]
93110

94111

95-
setup_args = dict(
96-
ext_modules=[],
97-
)
112+
def ext_modules():
113+
if set(sys.argv) & {"build_ext", "bdist_wheel", "install"}:
114+
return create_extensions()
115+
return []
116+
98117

99118
if __name__ == "__main__":
100-
setup_args["ext_modules"] = create_extensions()
101-
setup(**setup_args)
119+
setup(ext_modules=ext_modules())

0 commit comments

Comments
 (0)