Opened 5 weeks ago

Closed 5 weeks ago

#70562 closed defect (worksforme)

py310-cython-compat 0.29.37_0.darwin_23.arm64: no module named Cython

Reported by: areilly Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.10.0
Keywords: Cc: jmroot (Joshua Root)
Port: py310-cython-compat

Description (last modified by ryandesign (Ryan Carsten Schmidt))

The port installs cleanly, but does not work. It doesn't install the executables into the /opt/local/bin directory, but into /opt/local/lib/py310-cython-compat/bin/, and when executed directly from there produces the unhelpful error:

Traceback (most recent call last):
  File "/opt/local/bin/cython", line 5, in <module>
    from Cython.Compiler.Main import setuptools_main
ModuleNotFoundError: No module named 'Cython'

If I also install py310-cython, I do get cython in /opt/local/bin but that is the latest version:

% cython --version
Cython version 3.0.10

Now /opt/local/lib/py310-cython-compat/bin/cython does run, but it runs the new version:

% /opt/local/lib/py310-cython-compat/bin/cython --version
Cython version 3.0.10

I need the old version to get the py310-grpcio port to build, apparently: https://github.com/grpc/grpc/blob/42284424acd2ba4ba649599984592f5d2eade919/requirements.txt says cython>=0.29.8,<3.0.0rc1

Macports appears to be able to install this, it just doesn't find or use it.

Change History (3)

comment:1 Changed 5 weeks ago by jmroot (Joshua Root)

Milestone: MacPorts Future

As the port description says, this exists mainly "for the use of ports that are not compatible with the current version". It's not really intended to be used from outside of Portfiles. It's unfortunately not possible to install multiple versions of a python module side-by-side, so to use this older version requires prepending to sys.path, usually via PYTHONPATH. See for example what py-h5py or py-yaml does:

depends_build-append \
    port:py${python.version}-cython-compat
set compat_path [string replace ${python.pkgd} 0 [string length ${python.prefix}]-1 ${prefix}/lib/py${python.version}-cython-compat]
build.env-append    PYTHONPATH=${compat_path}

comment:2 Changed 5 weeks ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)

comment:3 Changed 5 weeks ago by jmroot (Joshua Root)

Cc: jmroot added
Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.