71.2. python3-cryptography-50.0.1
Cryptographic primitives and recipes for Python
| Version | 50.0.1, release 1 |
| Shelf | python-libs — General-purpose python3-* runtime libraries: text, templating, markup, parsing, config, CLI, system, files, crypto, imaging |
| Phase | 40_lang (Languages), 77 of 186 in build order |
| Licence | Apache-2.0 OR BSD-3-Clause |
| Homepage | https://cryptography.io/ |
| Build time | 2.6 SBU |
| Installed size | 7.5 MiB in 202 files |
| Recipe | ports/core/python-libs/python3-cryptography/kpkgbuild |
About
cryptography is the Python package of cryptographic recipes and primitives (Fernet, X.509, the hazmat layer). Its core is Rust, bound to Python with PyO3 and to OpenSSL through the openssl crate, and built by maturin from the vendor bundle; the compiled module cryptography/hazmat/bindings/_rust.abi3.so links the system openssl (libssl.so, libcrypto.so). The rest of its OpenSSL binding is C that python3-cffi generates from src/_cffi_src during the cargo build, and the build script compiles it into the same module.
Why it is in KDOS
The comment above it in script/phases/40_lang/packages.d/python-libs.txt:
What pdfminer.six binds through, and half of PyPI with it.
Sources
python3-cryptography-50.0.1.tar.gz(859.7 KiB)
sha2565dd9bda1c12b4162f6ff568eeb5e0ff956c28d14406e875cfe8a63a2d414ff20
upstream: https://files.pythonhosted.org/packages/source/c/cryptography/cryptography-50.0.1.tar.gz
archive copy: sources-4/python-libs--python3-cryptography-50.0.1.tar.gzpython3-cryptography-vendor-50.0.1.tar.xz(2.7 MiB)
sha256c65206c3b124d1b790a6461d5ebc1b466aaa685f37a2b949e01bba9793028fcd
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/python-libs--python3-cryptography-vendor-50.0.1.tar.xz
Dependencies
Depends on: python3, python3-setuptools, python3-pip, python3-cffi, python3-maturin, openssl, rust.
Required by (10): cura, deluge, kolibri, ocrmypdf, python3-esptool, python3-keyring, python3-rns, sideband, spyder, uranium.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/40_lang/phase.env && kpkg install python3-cryptography'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/python-libs/python3-cryptography.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/python-libs/python3-cryptography
echo '5dd9bda1c12b4162f6ff568eeb5e0ff956c28d14406e875cfe8a63a2d414ff20 python3-cryptography-50.0.1.tar.gz' | sha256sum -c -
echo 'c65206c3b124d1b790a6461d5ebc1b466aaa685f37a2b949e01bba9793028fcd python3-cryptography-vendor-50.0.1.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/python3-cryptography
SRC=$SRC_ROOT/python3-cryptography-50.0.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-cryptography-50.0.1.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers vendordir and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
pip3 install --ignore-installed --no-deps --no-index --no-build-isolation --root=$PKG --prefix=/usr .
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/python3-cryptography, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf python3-cryptography-50.0.1-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/python3-cryptography, and runs the triggers its paths call for.
Contents
Installed directories: /usr/lib/python3.14/site-packages/cryptography, /usr/lib/python3.14/site-packages/cryptography-50.0.1.dist-info, /usr/share/licenses/python3-cryptography.
Notes
The Rust crate that maturin builds is src/rust/Cargo.toml (manifest-path in the package’s [tool.maturin]), so the recipe’s vendordir = src/rust makes ports/fetch vendor from there. build.sh unpacks the bundle at the top of the tree all the same, because maturin runs cargo from the top with --manifest-path, and cargo finds .cargo/config.toml by walking up from the directory it runs in, not from the manifest; a configuration beside the manifest is never read, and every crate then resolves as missing. See Where the bundle goes.