diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index 7a69e2f..a290ab1 100644 --- a/.github/workflows/build-wheel-release-upload.yml +++ b/.github/workflows/build-wheel-release-upload.yml @@ -3,8 +3,6 @@ name: Release (GitHub/PyPI) and Deploy Docs on: workflow_dispatch: push: - branches: - - "**" tags: - "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml diff --git a/MANIFEST.in b/MANIFEST.in index d26fd26..00d47e0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -11,3 +11,4 @@ global-exclude .DS_Store # Exclude Mac filesystem artifacts. global-exclude __pycache__ # Exclude Python cache directories. global-exclude .git* # Exclude git files and directories. global-exclude .idea # Exclude PyCharm project settings. +global-exclude SConscript.configure SConscript # SCons build scripts diff --git a/requirements/pip.txt b/requirements/pip.txt index 24ce15a..a85739e 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1 +1,2 @@ +setuptools numpy diff --git a/setup.py b/setup.py index cec2b8a..243ed54 100644 --- a/setup.py +++ b/setup.py @@ -20,14 +20,31 @@ def get_boost_libraries(): - base_lib = "boost_python" - major, minor = str(sys.version_info[0]), str(sys.version_info[1]) - tags = [f"{major}{minor}", major, ""] - mttags = ["", "-mt"] - candidates = [base_lib + tag for tag in tags for mt in mttags] + [base_lib] - for lib in candidates: - if find_library(lib): - return [lib] + # the names we'll search for + major, minor = sys.version_info[:2] + candidates = [ + f"boost_python{major}{minor}", + f"boost_python{major}", + "boost_python", + ] + + conda_prefix = os.environ.get("CONDA_PREFIX") + if conda_prefix: + libdir = os.path.join(conda_prefix, "lib") + for name in candidates: + so = f"lib{name}.so" + if os.path.isfile(os.path.join(libdir, so)): + # return the plain "boost_python311" etc (no "lib" prefix or ".so") + return [name] + + # fallback to ldconfig + for name in candidates: + found = find_library(name) + if found: + # find_library may return "libboost_python3.so.1.74.0" etc + # strip off lib*.so.* if you like, or just return name + return [name] + raise RuntimeError("Cannot find a suitable Boost.Python library.") @@ -92,10 +109,11 @@ def create_extensions(): return [ext] -setup_args = dict( - ext_modules=[], -) +def ext_modules(): + if set(sys.argv) & {"build_ext", "bdist_wheel", "install"}: + return create_extensions() + return [] + if __name__ == "__main__": - setup_args["ext_modules"] = create_extensions() - setup(**setup_args) + setup(ext_modules=ext_modules())