Bug 263580 - net/py-pyzmq: Builds with Cython when it is installed
Summary: net/py-pyzmq: Builds with Cython when it is installed
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Roman Bogorodskiy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-26 12:23 UTC by Dmitry Marakasov
Modified: 2022-04-27 12:15 UTC (History)
1 user (show)

See Also:
novel: maintainer-feedback+


Attachments
Patch (423 bytes, patch)
2022-04-26 12:23 UTC, Dmitry Marakasov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2022-04-26 12:23:48 UTC
Created attachment 233499 [details]
Patch

This fixes hidden dependency on cython, which is used as long as it's available on the system. Using cython also fixes compatibility with newer python versions (bundled pregenerated C sources are often not compatible) and tests (which require pyximport module which comes with cython).
Comment 1 Roman Bogorodskiy freebsd_committer freebsd_triage 2022-04-26 12:33:04 UTC
Thanks for looking into it. Feel free to commit if you've tested that, I won't have time until the weekend.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2022-04-26 23:58:57 UTC
The upstream sdist (PyPI tarball creation) process has a process for checking and ensuring cython files are compiled to C files prior to upload:

class CheckSDist(sdist):
    """Custom sdist that ensures Cython has compiled all pyx files to c."""

Unfortunately the check for Cython is not made conditional:

try:
    import Cython

However later in the setup.py, the following only adds (registers) and actual cython dependency if socket.c doesnt exist (indicating cython sources havent been compiled)

if not os.path.exists(os.path.join("zmq", "backend", "cython", "socket.c")):
    # this generally means pip install from git
    # which requires Cython
    setup_args.setdefault("setup_requires", []).append(
        f"cython>={min_cython_version}

Adding a cython dependency to the port is spurious, and a better approach is either:

1) merge/move the import line to within the source file check, so both the try import and the registration are conditional, and send upstream, OR

2) hack: remove the try/import/exception block.

As far as Python version support goes, the standard is to declare version support against the versions upstream CI's and passes tests against. If they are testing with Cython builds, that means their sdist pipeline is untested, which is problematic and should be reported too.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-04-27 11:43:36 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2238cdaeeee894eaee1c99f327b5b4a22231b462

commit 2238cdaeeee894eaee1c99f327b5b4a22231b462
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2022-04-26 17:43:21 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2022-04-27 11:42:14 +0000

    net/py-pyzmq: add dependency on cython

    This:
    - Fixes hidden dependency, as cython is used as soon as its detected
    - Improves compatibility with newer python versions by regenerating C
      files with latest cython
    - Fixes tests which require pyximport module from cython

    PR:             263580
    Reported by:    reprise
    Approved by:    novel (maintainer)

 net/py-pyzmq/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)