capnproto / pycapnp

Cap'n Proto serialization/RPC system - Python bindings
BSD 2-Clause "Simplified" License
468 stars 124 forks source link

Can't build pip package with Cython 3.0.0 #319

Closed vectorcatch closed 1 year ago

vectorcatch commented 1 year ago

The package does not constrain Cython version for it's build environment when using the the tar.gz package (for instance with Alpine). Cython 3.0.0 appears to have made a number of changes resulting in a failure to build the package.

Adding a version constraint in the tar.gz package to limit Cython to below 3.0.0 resolves the issue. I'm not sure what would need to change in the pxds to fix the issue.

Below is a small chunk of the output (the same error is repeated many times).

Installing build dependencies: started

18 28.06 Installing build dependencies: finished with status 'done'

18 28.08 Getting requirements to build wheel: started

18 36.17 Getting requirements to build wheel: finished with status 'error'

18 36.30 error: subprocess-exited-with-error

18 36.30

18 36.30 × Getting requirements to build wheel did not run successfully.

18 36.30 │ exit code: 1

18 36.30 ╰─> [724 lines of output]

18 36.30 warning: capnp/includes/capnp_cpp.pxd:364:17: Rvalue-reference as function argument not supported

18 36.30

18 36.30 Error compiling Cython file:

18 36.30 ------------------------------------------------------------

18 36.30 ...

18 36.30 cdef _init(self, capnp.DynamicEnum other, object parent):

18 36.30 self.thisptr = other

18 36.30 self._parent = parent

18 36.30 return self

18 36.30

18 36.30 cpdef _as_str(self) except +reraise_kj_exception:

18 36.30 ^

18 36.30 ------------------------------------------------------------

18 36.30

18 36.30 capnp/lib/capnp.pyx:1011:10: Only extern functions can throw C++ exceptions.

18 36.30

18 36.30 Error compiling Cython file:

18 36.30 ------------------------------------------------------------

18 36.30 ...

18 36.30 """

18 36.30 self._check_write()

18 36.30 _write_packed_message_to_fd(file.fileno(), self._parent)

18 36.30 self._is_written = True

18 36.30

18 36.30 cpdef to_bytes(_DynamicStructBuilder self) except +reraise_kj_exception:

alex-reilly-pronto commented 1 year ago

Also seeing this in pycapnp 1.1.0.

Adding a version constraint in the tar.gz package to limit Cython to below 3.0.0 resolves the issue.

Can you explain more about how you did this?

vectorcatch commented 1 year ago

My first cut was to go into the tar.gz and every file that had cython as a dependency to limit it's version. The included Pipfile, the toml, requirements.txt, etc, but I found a better way.

If you use pip environment variables you can push a constraints file to all subprocesses and limit the version of cython even in the isolated builder.

PIP_CONSTRAINT=constraints.txt python -m pip install pycapnp-1.1.1.tar.gz

Where constraints.txt contains: cython<3.0.0