If You Can't Install Python Cryptography, Install Rust with rustup

Python
2021-02-08 23:34 (3 years ago) ytyng

Pipenv install in the Dockerfile of Alpine is failing.

The installation of cryptography 3.4.1 fails with the error: ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly.

As a test, instead of using pipenv,

try pip install cryptography

#10 32.68 [pipenv.exceptions.InstallError]: Collecting cryptography>=1.4
#10 32.68 [pipenv.exceptions.InstallError]: Using cached cryptography-3.4.4.tar.gz (545 kB)
#10 32.68 [pipenv.exceptions.InstallError]: ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of setuptools.build_meta in pyproject.toml
 generating cffi module 'build/temp.linux-x86_64-3.8/_padding.c'
creating build/temp.linux-x86_64-3.8
generating cffi module 'build/temp.linux-x86_64-3.8/_openssl.c'
running build_rust

=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed.
=============================DEBUG ASSISTANCE=============================

error: Can not find Rust compiler
----------------------------------------
ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
/ #

It requires Rust.

The current version is cryptography 3.4.1, which now requires building with Rust.

According to the FAQ:

https://cryptography.io/en/latest/faq.html

For this version, it seems that setting the environment variable CRYPTOGRAPHY_DONT_BUILD_RUST allows building without Rust.

This should be the last resort.

Let's try installing rust and cargo:

apk add rust cargo

Then,

pip install cryptography

 Running `rustc --crate-name parking_lot_core --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot_core-0.8.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=eee97183f997b675 -C extra-filename=-eee97183f997b675 --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern cfg_if=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libcfg_if-cac6a3fe3e67c31f.rmeta --extern instant=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libinstant-8d8e286f6640e0bb.rmeta --extern libc=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/liblibc-7eee26158fb5ebc8.rmeta --extern smallvec=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsmallvec-4a190f9a26ad8e9a.rmeta --cap-lints allow -C target-feature=-crt-static`
Running `rustc --crate-name syn --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.60/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="extra-traits"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' -C metadata=e836c33ca097f1fb -C extra-filename=-e836c33ca097f1fb --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern unicode_xid=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libunicode_xid-13530667aae58aae.rmeta --cap-lints allow -C target-feature=-crt-static --cfg syn_disable_nightly_tests`
Compiling parking_lot v0.11.1
Running `rustc --crate-name parking_lot --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/parking_lot-0.11.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 --cfg 'feature="default"' -C metadata=01e553f69513271f -C extra-filename=-01e553f69513271f --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern instant=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libinstant-8d8e286f6640e0bb.rmeta --extern lock_api=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/liblock_api-8e10e3c848fbd6d6.rmeta --extern parking_lot_core=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libparking_lot_core-eee97183f997b675.rmeta --cap-lints allow -C target-feature=-crt-static`
Running `/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/build/pyo3-089b3f9e5ef423ad/build-script-build`
Compiling pyo3-macros-backend v0.13.1
Running `rustc --crate-name pyo3_macros_backend --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=1c47d36fb0c032da -C extra-filename=-1c47d36fb0c032da --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern syn=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsyn-e836c33ca097f1fb.rmeta --cap-lints allow -C target-feature=-crt-static`
error[E0658]: use of unstable library feature 'str_strip': newly added
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/method.rs:144:18
|
144 | .strip_prefix(prefix)
| ^^^^^^^^^^^^
|
= note: see issue #67302 <https://github.com/rust-lang/rust/issues/67302> for more information

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `pyo3-macros-backend`.

Caused by:
process didn't exit successfully: `rustc --crate-name pyo3_macros_backend --edition=2018 /root/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-macros-backend-0.13.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C metadata=1c47d36fb0c032da -C extra-filename=-1c47d36fb0c032da --out-dir /tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps -L dependency=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps --extern proc_macro2=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libproc_macro2-aa3871282eef8eab.rmeta --extern quote=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libquote-4a1344d16195b0c6.rmeta --extern syn=/tmp/pip-install-v1h5w2m6/cryptography_7f388e3637a141d696bf039cf3d904e3/src/rust/target/release/deps/libsyn-e836c33ca097f1fb.rmeta --cap-lints allow -C target-feature=-crt-static` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: build failed

=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed.
=============================DEBUG ASSISTANCE=============================

error: cargo failed with code: 101

----------------------------------------
ERROR: Failed building wheel for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
/ #

error[E0658]: use of unstable library feature 'str_strip': newly added

This error occurred.

Upon further investigation, it seems that using rustup instead of installing rust and cargo via apk is recommended.

https://rustup.rs/

apk add curl

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

/ # curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

/root/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory located at:

/root/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

/root/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile file located at:

/root/.profile

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


default host triple: x86_64-unknown-linux-musl
default toolchain: stable (default)
profile: default
modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-musl
info: syncing channel updates for 'stable-x86_64-unknown-linux-musl'
info: latest update on 2020-12-31, rust version 1.49.0 (e1884a8e3 2020-12-29)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
13.9 MiB / 13.9 MiB (100 %) 6.7 MiB/s in 2s ETA: 0s
info: downloading component 'rust-std'
21.5 MiB / 21.5 MiB (100 %) 6.8 MiB/s in 3s ETA: 0s
info: downloading component 'rustc'
76.9 MiB / 76.9 MiB (100 %) 7.2 MiB/s in 11s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: using up to
Current rating: 5

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011