PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.62k stars 712 forks source link

OpenBSD/amd64: pip install cryptography fails #3807

Closed holsta closed 3 months ago

holsta commented 5 months ago

David Hewitt asked me to file this issue to see if we can make certain aspects of Python work better for OpenBSD users. Please let me know if there is other information I should provide.

For what it's worth, these are the patches involved in getting this particular package working on OpenBSD. https://cvsweb.openbsd.org/ports/security/py-cryptography/patches/

/tmp$ python3 -m venv foo /tmp$ . foo/bin/activate (foo) /tmp$ cd foo (foo) /tmp/foo$ uname -a OpenBSD mbp.sweet.home 7.4 GENERIC.MP#1663 amd64 (foo) /tmp/foo$ export RUST_BACKTRACE=1 (foo) /tmp/foo$ pip3 install --log ~/openbsd-pip-install-fail.txt cryptography Collecting cryptography Downloading cryptography-42.0.2.tar.gz (672 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 672.8/672.8 kB 5.0 MB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting cffi>=1.12 Using cached cffi-1.16.0-cp310-cp310-openbsd_7_4_amd64.whl Collecting pycparser Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB) Building wheels for collected packages: cryptography error: subprocess-exited-with-error

× Building wheel for cryptography (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip. Building wheel for cryptography (pyproject.toml) ... error ERROR: Failed building wheel for cryptography Failed to build cryptography ERROR: Could not build wheels for cryptography, which is required to install pyproject.toml-based projects

openbsd-pip-install-fail.txt

davidhewitt commented 5 months ago

Thanks @holsta for following up!

This looks like the relevant bit of the build log:

2024-02-07T11:25:39,511     thread 'main' panicked at cryptography-cffi/build.rs:61:49:
2024-02-07T11:25:39,511     unable to find openssl include path

cc @alex

From first look this is a duplicate of https://github.com/pyca/cryptography/issues/9144, but the fix discussed there has landed already in cryptography-42.0.2.tar.gz which this build is attempting, so there's something else going on there.

@holsta does it resolve if you set OPENSSL_DIR="/usr" as per that issue?

alex commented 5 months ago

Yes I agree with that analysis.

holsta commented 5 months ago

It did resolve! Is this something that can be autodetected?

$ OPENSSL_DIR="/usr" pip install cryptography
Collecting cryptography
  Using cached cryptography-42.0.2.tar.gz (672 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting cffi>=1.12 (from cryptography)
  Using cached cffi-1.16.0-cp310-cp310-openbsd_7_4_amd64.whl
Collecting pycparser (from cffi>=1.12->cryptography)
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Building wheels for collected packages: cryptography
  Building wheel for cryptography (pyproject.toml) ... done
  Created wheel for cryptography: filename=cryptography-42.0.2-cp310-cp310-openbsd_7_4_amd64.whl size=4114747 sha256=3a3678d6b04b236bdb0ee400294d170dd62293182c30c4c2054dbbbb7ce12922
  Stored in directory: /home/holsta/.cache/pip/wheels/fe/1a/d3/0602dc92573d8c77c900c72fda996e8cb13ac092a56351811b
Successfully built cryptography
Installing collected packages: pycparser, cffi, cryptography
Successfully installed cffi-1.16.0 cryptography-42.0.2 pycparser-2.21
alex commented 5 months ago

It is autodetected! Or at least, it's supposed to be -- that's the issue/PR that @davidhewitt linked.

What does rustc -V -v print?

holsta commented 5 months ago
$ rustc -V -v
rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-openbsd
release: 1.75.0
LLVM version: 16.0.6
davidhewitt commented 3 months ago

@alex - should we move this issue over to pyca/cyptography?

alex commented 3 months ago

Unless there's a pyo3 bug here, yup!

On Tue, Apr 2, 2024, 4:53 PM David Hewitt @.***> wrote:

@alex https://github.com/alex - should we move this issue over to pyca/cyptography?

— Reply to this email directly, view it on GitHub https://github.com/PyO3/pyo3/issues/3807#issuecomment-2033080663, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBHEEGVJWYFRYEGXGSDY3MLDFAVCNFSM6AAAAABC5SNZJSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZTGA4DANRWGM . You are receiving this because you were mentioned.Message ID: @.***>

davidhewitt commented 3 months ago

Opened https://github.com/pyca/cryptography/issues/10817