rust and python

Marco Atzeri via Cygwin-apps <[email protected]> Tue, 30 Dec 2025 12:49:38 +0100
Newsgroups gmane.os.cygwin.applications
Message-ID <[email protected]>
Hi Mantainers,

using the SCALLYWAG build of rust

$ rustc --version
rustc 1.91.0 (f8297e351 2025-10-28) (built from a source tarball)

I was able to compile the latest versions of

	python-bcrypt
	python-cryptography

that I uploded as TEST.

The build dependency on RUST is currently disabled to avoid complaint
during the upload.

While "python-bcrypt" was relative straightward with minor trick to set 
RUSTFLAGS for the right version of python

---------------------------------------------------------
BASE_PYTHON_WHEEL_VERSIONS=${PYTHON_WHEEL_VERSIONS}

src_compile() {
         cd ${S}
         lndirs
         cd ${B}
         for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
         do
                 export RUSTFLAGS=" -lpython${v}"
                 PYTHON_WHEEL_VERSIONS="${v}"
                 inform "building ${v}"
                 python_wheel_compile
         done
         PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}
---------------------------------------------------------

"python-cryptography" needed an additional package
as the wheel files were NOT in a suitable format

./dist/cryptography-46.0.3-cp312-abi3-cygwin_86_64.whl
./dist/cryptography-46.0.3-cp39-abi3-cygwin_86_64.whl

after installing the "python-maturin" packages the wheel files
were correctly built

./dist/cryptography-46.0.3-cp312-abi3-cygwin_3_6_5_x86_64.whl
./dist/cryptography-46.0.3-cp39-abi3-cygwin_3_6_5_x86_64.whl



Regards
Marco
python-bcrypt.cygport (text/plain, 1.4 KB)
PYTHON_WHEEL_VERSIONS="3.9:3.12"
inherit python-wheel

NAME="python-bcrypt"
VERSION="5.0.0"
RELEASE="1"

LICENSE="Apache-2.0"
CATEGORY="Python"
SUMMARY="Modern password hashing for your software and your servers"
DESCRIPTION="Password hashing library for Python"
python312_bcrypt_REQUIRES+=" python312-six python312-cffi"
python39_bcrypt_REQUIRES+=" python39-six python39-cffi"

BUILD_REQUIRES+=" ${python312_bcrypt_REQUIRES} python312-devel python312-wheel python312-pytest"
BUILD_REQUIRES+=" ${python39_bcrypt_REQUIRES} python39-devel python39-wheel python39-pytest"
# to add when "rust" is added as cygwin package
#BUILD_REQUIRES+=" libffi-devel rust"


BASE_PYTHON_WHEEL_VERSIONS=${PYTHON_WHEEL_VERSIONS}

src_compile() {
	cd ${S}
	lndirs
	cd ${B}
	for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
	do
		export RUSTFLAGS=" -lpython${v}"
		PYTHON_WHEEL_VERSIONS="${v}"
		inform "building ${v}"
		python_wheel_compile
	done
	PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_install() {
	cd ${B}
	for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
	do
		export RUSTFLAGS=" -lpython${v}"
		PYTHON_WHEEL_VERSIONS="${v}"
		inform "installing ${v}"
		python_wheel_install
	done
	PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_test() {
	cd ${B}
	for v in ${PYTHON_WHEEL_VERSIONS//:/ }
	do
		echo "testing ${v}"
		export PYTHONPATH=${D}/usr/lib/python${v}/site-packages
		pytest-${v} || true
	done
}
python-cryptography.cygport (text/plain, 1.7 KB)
PYTHON_WHEEL_VERSIONS="3.9:3.12"
inherit python-wheel

NAME="python-cryptography"
VERSION=46.0.3
RELEASE=1

LICENSE="Apache-2.0 OR BSD-3-Clause"
CATEGORY="Python"
SUMMARY="Python cryptography primitives"
DESCRIPTION="cryptography is a package which provides cryptographic recipes and
primitives to Python developers."

SRC_DIR="https://files.pythonhosted.org/packages/9f/33/c00162f49c0e2fe8064a62cb92b93e50c74a72bc370ab92f86112b33ff62/cryptography-46.0.3.tar.gz"
SRC_DIR="cryptography-${PV}"

python312_cryptography_REQUIRES="python312-cffi python312-idna"
python39_cryptography_REQUIRES="python39-cffi python39-idna"
python_cryptography_debuginfo_OBSOLETES="python3-cryptography-debuginfo"


BUILD_REQUIRES+=" ${python312__cryptography_REQUIRES} python312-devel python312-wheel python312-pytest"
BUILD_REQUIRES+=" ${python39_cryptography_REQUIRES} python39-devel python39-wheel python39-pytest"
# BUILD_REQUIRES+=" rust python39-maturin python312-maturin"


BASE_PYTHON_WHEEL_VERSIONS=${PYTHON_WHEEL_VERSIONS}

src_compile() {
    cd ${S}
	lndirs
    cd ${B}
    for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
    do
		export RUSTFLAGS=" -lpython${v}"
		PYTHON_WHEEL_VERSIONS="${v}"
        inform "building ${v}"
		python_wheel_compile
    done
	PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_install() {
    cd ${B}
    for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
    do
        export RUSTFLAGS=" -lpython${v}"
        PYTHON_WHEEL_VERSIONS="${v}"
        inform "installing ${v}"
        python_wheel_install
    done
    PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_test() {
    cd ${B}
    for v in ${PYTHON_WHEEL_VERSIONS//:/ }
    do
        echo "testing ${v}"
		export PYTHONPATH=${D}/usr/lib/python${v}/site-packages
        pytest-${v} || true
    done
}
python-maturin.cygport (text/plain, 1.5 KB)
PYTHON_WHEEL_VERSIONS="3.9:3.12"
inherit python-wheel

NAME="python-maturin"
VERSION="1.10.2"
RELEASE="1"

LICENSE="Apache-2.0 OR MIT "
CATEGORY="Python"
SUMMARY="Build and publish rust crates"
DESCRIPTION="Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages"
HOMEPAGE="https://github.com/pyo3/maturin"

BUILD_REQUIRES+=" ${python312_maturin_REQUIRES} python312-devel python312-wheel python312-pytest"
BUILD_REQUIRES+=" ${python39_maturin_REQUIRES} python39-devel python39-wheel python39-pytest"
# to add when "rust" is added as cygwin package
#BUILD_REQUIRES+=" libffi-devel rust"

PKG_NAMES+=" ${NAME}-tool"
python312_maturin_REQUIRES=" python-maturin-tool"
python39_maturin_REQUIRES=" python-maturin-tool"

python_maturin_tool_CONTENTS="usr/bin/maturin.exe"

BASE_PYTHON_WHEEL_VERSIONS=${PYTHON_WHEEL_VERSIONS}

src_compile() {
	cd ${S}
	lndirs
	cd ${B}
	for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
	do
		export RUSTFLAGS=" -lpython${v}"
		PYTHON_WHEEL_VERSIONS="${v}"
		inform "building ${v}"
		python_wheel_compile
	done
	PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_install() {
	cd ${B}
	for v in ${BASE_PYTHON_WHEEL_VERSIONS//:/ }
	do
		export RUSTFLAGS=" -lpython${v}"
		PYTHON_WHEEL_VERSIONS="${v}"
		inform "installing ${v}"
		python_wheel_install
	done
	PYTHON_WHEEL_VERSIONS=${BASE_PYTHON_WHEEL_VERSIONS}
}

src_test() {
	cd ${B}
	for v in ${PYTHON_WHEEL_VERSIONS//:/ }
	do
		echo "testing ${v}"
		export PYTHONPATH=${D}/usr/lib/python${v}/site-packages
		pytest-${v} || true
	done
}