From 4c10b3ecb244b0c6ce8e29cd4ed33ea471bbcf30 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Thu, 27 Aug 2026 13:25:37 +0100 Subject: [PATCH 1/2] Update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d974edd5..f180bccc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/bxlab/bx-python.svg?branch=master)](https://travis-ci.org/bxlab/bx-python) +![PyPI Version](https://img.shields.io/pypi/v/bx-python) [![Read the Docs](https://img.shields.io/readthedocs/bx-python.svg)](https://bx-python.readthedocs.io/) @@ -14,7 +14,7 @@ The bx-python project is a Python library and associated set of scripts for rapi ## Requirements -Build currently requires liblzo, e.g. sudo apt-get install liblzo2-dev on debian/ubuntu). +Testing requires liblzo, e.g. sudo apt-get install liblzo2-dev on Debian/Ubuntu. ## Installing @@ -32,4 +32,4 @@ It is available in [Debian](https://tracker.debian.org/pkg/python-bx) and [Ubunt Or can be built from a checkout of the repository: -```python setup.py install``` +```pip install .``` From 81b3f03e960a642ec91a88bb2c1b48076dbf4b05 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Thu, 27 Aug 2026 13:14:15 +0100 Subject: [PATCH 2/2] Force re-cythonization to fix stale .c files breaking downstream builds `setup.py` shipped Cython-generated .c/.h files in the sdist, produced at release time with whatever NumPy/Cython happened to be newest. Since the old `Cython.Distutils.build_ext` only re-cythonized when the .pyx was newer than the shipped .c, downstream builders (e.g. bioconda) compiled that stale .c as-is against their own, often older, NumPy headers, causing "implicit declaration" errors for `PyDataType_*` functions, see: https://github.com/bioconda/bioconda-recipes/pull/68558 Replace this with an explicit `cythonize(ext_modules, force=True)` call in `setup.py`, so every real build always regenerates C sources fresh against whatever NumPy/Cython is actually installed. NumPy and Cython are both already hard build-time requirements (`build-system.requires` in `pyproject.toml`), so drop the now-pointless `ImportError` fallback and merge their imports. With sources always regenerated, there's no need to ship the generated .c/.h files in the sdist either: trim `MANIFEST.in` to just the .pyx/.pxd sources plus the one genuinely hand-written .c/.h pair (`lib/bx/align/sitemask/find_cpg.*`), and skip building ext_modules for the "sdist" action so setuptools doesn't pull the freshly cythonized files back in as extension sources. Co-Authored-By: Claude Sonnet 5 --- MANIFEST.in | 3 +-- setup.py | 48 ++++++++++++++++++++---------------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 7fac4702..5b8157f5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include LICENSE recursive-include src *.h recursive-include src *.c -recursive-include lib *.h -recursive-include lib *.c +include lib/bx/align/sitemask/find_cpg.* recursive-include lib *.pyx recursive-include lib *.pxd diff --git a/setup.py b/setup.py index 72d8b61e..cef83160 100644 --- a/setup.py +++ b/setup.py @@ -6,53 +6,45 @@ Extension, setup, ) -from setuptools.command.sdist import sdist def main(): - metadata = {"scripts": glob("scripts/*.py"), "cmdclass": command_classes} + metadata = {"scripts": glob("scripts/*.py")} if len(sys.argv) >= 2 and ( - "--help" in sys.argv[1:] or sys.argv[1] in ("--help-commands", "egg_info", "--version", "clean") + "--help" in sys.argv[1:] or sys.argv[1] in ("--help-commands", "egg_info", "--version", "clean", "sdist") ): - # For these actions, NumPy is not required. + # For these actions, NumPy and Cython are not required. # - # They are required to succeed without Numpy for example when - # pip is used to install when Numpy is not yet present in - # the system. + # They are required to succeed without them, for example when pip is + # used to install when NumPy is not yet present in the system. + # + # "sdist" does not need to compile anything: the .pyx/.pxd/.h sources + # in MANIFEST.in are enough to rebuild later, and skipping ext_modules + # here keeps setuptools' sdist file list from also pulling in the + # cythonized .c files as extension sources. pass else: try: import numpy + from Cython.Build import cythonize # Suppress numpy tests numpy.test = None except Exception as e: - raise Exception(f"numpy must be installed to build: {e}") - metadata["ext_modules"] = get_extension_modules(numpy_include=numpy.get_include()) + raise Exception(f"NumPy and Cython must be installed to build: {e}") + ext_modules = get_extension_modules(numpy_include=numpy.get_include()) + # Force re-cythonization instead of reusing the .c files shipped in the + # sdist: those were generated with whichever NumPy/Cython versions were + # used for the bx-python release, which can be incompatible with the + # NumPy/Cython versions installed in the environment actually doing the + # build (e.g. "implicit declaration" errors for PyDataType_* functions + # when building against an older NumPy than the one used to release). + metadata["ext_modules"] = cythonize(ext_modules, force=True) setup(**metadata) -# ---- Commands ------------------------------------------------------------- - -# Use build_ext from Cython if found -command_classes = {} -try: - import Cython.Distutils - - command_classes["build_ext"] = Cython.Distutils.build_ext - - class build_ext_sdist(sdist): - def run(self): - # Make sure the compiled Cython files in the distribution are up-to-date - self.run_command("build_ext") - super().run() - - command_classes["sdist"] = build_ext_sdist -except ImportError: - pass - # ---- Extension Modules ---------------------------------------------------- # # suppress C++ #warning, e.g., to silence NumPy deprecation warnings: