diff --git a/Cargo.toml b/Cargo.toml index 85dad1d..3b81860 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,11 +42,13 @@ codegen-units = 1 [package.metadata.cross.build.env] passthrough = [ "PYAPP_ALLOW_UPDATES", + "PYAPP_DISTRIBUTION_CPYTHON_REPOSITORY", "PYAPP_DISTRIBUTION_EMBED", "PYAPP_DISTRIBUTION_FORMAT", "PYAPP_DISTRIBUTION_PATH", "PYAPP_DISTRIBUTION_PATH_PREFIX", "PYAPP_DISTRIBUTION_PIP_AVAILABLE", + "PYAPP_DISTRIBUTION_PYPY_HOST", "PYAPP_DISTRIBUTION_PYTHON_PATH", "PYAPP_DISTRIBUTION_SITE_PACKAGES_PATH", "PYAPP_DISTRIBUTION_SOURCE", @@ -82,5 +84,6 @@ passthrough = [ "PYAPP_UPGRADE_VIRTUALENV", "PYAPP_UV_ENABLED", "PYAPP_UV_ONLY_BOOTSTRAP", + "PYAPP_UV_REPOSITORY", "PYAPP_UV_VERSION", ] diff --git a/build.rs b/build.rs index fdda3d5..4dadfb5 100644 --- a/build.rs +++ b/build.rs @@ -12,219 +12,218 @@ use regex::Regex; const DEFAULT_PYTHON_VERSION: &str = "3.12"; const KNOWN_DISTRIBUTION_FORMATS: &[&str] = &["tar|bzip2", "tar|gzip", "tar|zstd", "zip"]; -const DEFAULT_CPYTHON_SOURCE: &str = - "https://github.com/indygreg/python-build-standalone/releases/download/"; -const DEFAULT_PYPY_SOURCE: &str = "https://downloads.python.org/pypy/"; +const DEFAULT_CPYTHON_SOURCE: &str = "https://github.com/indygreg/python-build-standalone"; +const DEFAULT_PYPY_SOURCE: &str = "https://downloads.python.org"; // Python version in the form MAJOR.MINOR // Target OS https://doc.rust-lang.org/reference/conditional-compilation.html#target_os // Target arch https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch // Target ABI https://doc.rust-lang.org/reference/conditional-compilation.html#target_env // Variant e.g. CPU optimization level for Linux -// URL for fetching the distribution +// URL path for fetching the distribution (Needs to be relative to the repository URL) // // See also https://llvm.org/doxygen/classllvm_1_1Triple.html #[rustfmt::skip] const DEFAULT_CPYTHON_DISTRIBUTIONS: &[(&str, &str, &str, &str, &str, &str)] = &[ ("3.12", "linux", "aarch64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "armv7", "gnueabi", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), ("3.12", "linux", "armv7", "gnueabihf", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), ("3.12", "linux", "powerpc64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "s390x", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "x86_64", "gnu", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "x86_64", "gnu", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "x86_64", "gnu", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "x86_64", "gnu", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), ("3.12", "linux", "x86_64", "musl", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), ("3.12", "linux", "x86_64", "musl", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), ("3.12", "linux", "x86_64", "musl", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), ("3.12", "linux", "x86_64", "musl", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), ("3.12", "windows", "x86", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), ("3.12", "windows", "x86_64", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), ("3.12", "macos", "aarch64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), ("3.12", "macos", "x86_64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.12.3%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), ("3.11", "linux", "aarch64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "armv7", "gnueabi", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), ("3.11", "linux", "armv7", "gnueabihf", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), ("3.11", "linux", "powerpc64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "s390x", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.11.5%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20230826/cpython-3.11.5%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86_64", "gnu", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86_64", "gnu", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86_64", "gnu", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86_64", "gnu", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), ("3.11", "linux", "x86_64", "musl", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), ("3.11", "linux", "x86_64", "musl", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), ("3.11", "linux", "x86_64", "musl", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), ("3.11", "linux", "x86_64", "musl", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), ("3.11", "windows", "x86", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), ("3.11", "windows", "x86_64", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), ("3.11", "macos", "aarch64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), ("3.11", "macos", "x86_64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.11.9%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), ("3.10", "linux", "aarch64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "armv7", "gnueabi", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), ("3.10", "linux", "armv7", "gnueabihf", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), ("3.10", "linux", "powerpc64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "s390x", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.10.13%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20230826/cpython-3.10.13%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86_64", "gnu", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86_64", "gnu", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86_64", "gnu", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86_64", "gnu", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), ("3.10", "linux", "x86_64", "musl", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), ("3.10", "linux", "x86_64", "musl", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), ("3.10", "linux", "x86_64", "musl", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), ("3.10", "linux", "x86_64", "musl", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), ("3.10", "windows", "x86", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), ("3.10", "windows", "x86_64", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), ("3.10", "macos", "aarch64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), ("3.10", "macos", "x86_64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.10.14%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), ("3.9", "linux", "aarch64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "armv7", "gnueabi", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-armv7-unknown-linux-gnueabi-install_only.tar.gz"), ("3.9", "linux", "armv7", "gnueabihf", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-armv7-unknown-linux-gnueabihf-install_only.tar.gz"), ("3.9", "linux", "powerpc64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-ppc64le-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "s390x", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-s390x-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.9.18%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20230826/cpython-3.9.18%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86_64", "gnu", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86_64", "gnu", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v2-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86_64", "gnu", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v3-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86_64", "gnu", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v4-unknown-linux-gnu-install_only.tar.gz"), ("3.9", "linux", "x86_64", "musl", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), ("3.9", "linux", "x86_64", "musl", "v2", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v2-unknown-linux-musl-install_only.tar.gz"), ("3.9", "linux", "x86_64", "musl", "v3", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v3-unknown-linux-musl-install_only.tar.gz"), ("3.9", "linux", "x86_64", "musl", "v4", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64_v4-unknown-linux-musl-install_only.tar.gz"), ("3.9", "windows", "x86", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), ("3.9", "windows", "x86_64", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), ("3.9", "macos", "aarch64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), ("3.9", "macos", "x86_64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.9.19%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), ("3.8", "linux", "aarch64", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-aarch64-unknown-linux-gnu-install_only.tar.gz"), ("3.8", "linux", "x86", "gnu", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20230826/cpython-3.8.17%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20230826/cpython-3.8.17%2B20230826-i686-unknown-linux-gnu-install_only.tar.gz"), ("3.8", "linux", "x86_64", "gnu", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-unknown-linux-gnu-install_only.tar.gz"), ("3.8", "linux", "x86_64", "musl", "v1", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-unknown-linux-musl-install_only.tar.gz"), ("3.8", "windows", "x86", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-i686-pc-windows-msvc-install_only.tar.gz"), ("3.8", "windows", "x86_64", "msvc", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-pc-windows-msvc-install_only.tar.gz"), ("3.8", "macos", "aarch64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-aarch64-apple-darwin-install_only.tar.gz"), ("3.8", "macos", "x86_64", "", "", - "https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), + "releases/download/20240415/cpython-3.8.19%2B20240415-x86_64-apple-darwin-install_only.tar.gz"), // Frozen - ("3.7", "linux", "x86_64", "gnu", "", "https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.7.9-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst"), - ("3.7", "linux", "x86_64", "musl", "", "https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.7.9-x86_64-unknown-linux-musl-noopt-20200823T0036.tar.zst"), - ("3.7", "windows", "x86", "msvc", "", "https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.7.9-i686-pc-windows-msvc-shared-pgo-20200823T0159.tar.zst"), - ("3.7", "windows", "x86_64", "msvc", "", "https://github.com/indygreg/python-build-standalone/releases/download/20200822/cpython-3.7.9-x86_64-pc-windows-msvc-shared-pgo-20200823T0118.tar.zst"), - ("3.7", "macos", "x86_64", "", "", "https://github.com/indygreg/python-build-standalone/releases/download/20200823/cpython-3.7.9-x86_64-apple-darwin-pgo-20200823T2228.tar.zst"), + ("3.7", "linux", "x86_64", "gnu", "", "releases/download/20200822/cpython-3.7.9-x86_64-unknown-linux-gnu-pgo-20200823T0036.tar.zst"), + ("3.7", "linux", "x86_64", "musl", "", "releases/download/20200822/cpython-3.7.9-x86_64-unknown-linux-musl-noopt-20200823T0036.tar.zst"), + ("3.7", "windows", "x86", "msvc", "", "releases/download/20200822/cpython-3.7.9-i686-pc-windows-msvc-shared-pgo-20200823T0159.tar.zst"), + ("3.7", "windows", "x86_64", "msvc", "", "releases/download/20200822/cpython-3.7.9-x86_64-pc-windows-msvc-shared-pgo-20200823T0118.tar.zst"), + ("3.7", "macos", "x86_64", "", "", "releases/download/20200823/cpython-3.7.9-x86_64-apple-darwin-pgo-20200823T2228.tar.zst"), ]; // See https://downloads.python.org/pypy/ #[rustfmt::skip] const DEFAULT_PYPY_DISTRIBUTIONS: &[(&str, &str, &str, &str, &str)] = &[ ("pypy3.10", "linux", "aarch64", "gnu", - "https://downloads.python.org/pypy/pypy3.10-v7.3.15-aarch64.tar.bz2"), + "/pypy/pypy3.10-v7.3.15-aarch64.tar.bz2"), ("pypy3.10", "linux", "x86_64", "gnu", - "https://downloads.python.org/pypy/pypy3.10-v7.3.15-linux64.tar.bz2"), + "/pypy/pypy3.10-v7.3.15-linux64.tar.bz2"), ("pypy3.10", "windows", "x86_64", "msvc", - "https://downloads.python.org/pypy/pypy3.10-v7.3.15-win64.zip"), + "/pypy/pypy3.10-v7.3.15-win64.zip"), ("pypy3.10", "macos", "aarch64", "", - "https://downloads.python.org/pypy/pypy3.10-v7.3.15-macos_arm64.tar.bz2"), + "/pypy/pypy3.10-v7.3.15-macos_arm64.tar.bz2"), ("pypy3.10", "macos", "x86_64", "", - "https://downloads.python.org/pypy/pypy3.10-v7.3.15-macos_x86_64.tar.bz2"), + "/pypy/pypy3.10-v7.3.15-macos_x86_64.tar.bz2"), ("pypy3.9", "linux", "aarch64", "gnu", - "https://downloads.python.org/pypy/pypy3.9-v7.3.15-aarch64.tar.bz2"), + "/pypy/pypy3.9-v7.3.15-aarch64.tar.bz2"), ("pypy3.9", "linux", "x86_64", "gnu", - "https://downloads.python.org/pypy/pypy3.9-v7.3.15-linux64.tar.bz2"), + "/pypy/pypy3.9-v7.3.15-linux64.tar.bz2"), ("pypy3.9", "windows", "x86_64", "msvc", - "https://downloads.python.org/pypy/pypy3.9-v7.3.15-win64.zip"), + "/pypy/pypy3.9-v7.3.15-win64.zip"), ("pypy3.9", "macos", "aarch64", "", - "https://downloads.python.org/pypy/pypy3.9-v7.3.15-macos_arm64.tar.bz2"), + "/pypy/pypy3.9-v7.3.15-macos_arm64.tar.bz2"), ("pypy3.9", "macos", "x86_64", "", - "https://downloads.python.org/pypy/pypy3.9-v7.3.15-macos_x86_64.tar.bz2"), + "/pypy/pypy3.9-v7.3.15-macos_x86_64.tar.bz2"), ("pypy2.7", "linux", "aarch64", "gnu", - "https://downloads.python.org/pypy/pypy2.7-v7.3.15-aarch64.tar.bz2"), + "/pypy/pypy2.7-v7.3.15-aarch64.tar.bz2"), ("pypy2.7", "linux", "x86_64", "gnu", - "https://downloads.python.org/pypy/pypy2.7-v7.3.15-linux64.tar.bz2"), + "/pypy/pypy2.7-v7.3.15-linux64.tar.bz2"), ("pypy2.7", "windows", "x86_64", "msvc", - "https://downloads.python.org/pypy/pypy2.7-v7.3.15-win64.zip"), + "/pypy/pypy2.7-v7.3.15-win64.zip"), ("pypy2.7", "macos", "aarch64", "", - "https://downloads.python.org/pypy/pypy2.7-v7.3.15-macos_arm64.tar.bz2"), + "/pypy/pypy2.7-v7.3.15-macos_arm64.tar.bz2"), ("pypy2.7", "macos", "x86_64", "", - "https://downloads.python.org/pypy/pypy2.7-v7.3.15-macos_x86_64.tar.bz2"), + "/pypy/pypy2.7-v7.3.15-macos_x86_64.tar.bz2"), ]; fn set_runtime_variable(name: &str, value: impl Display) { @@ -310,6 +309,28 @@ fn get_python_version() -> String { DEFAULT_PYTHON_VERSION.to_string() } +fn get_cpython_repository() -> String { + env::var("PYAPP_DISTRIBUTION_CPYTHON_REPOSITORY") + .unwrap_or(DEFAULT_CPYTHON_SOURCE.to_string()) + .trim_end_matches('/') + .to_string() +} + +fn get_pypy_host() -> String { + env::var("PYAPP_DISTRIBUTION_PYPY_HOST") + .unwrap_or(DEFAULT_PYPY_SOURCE.to_string()) + .trim_end_matches('/') + .to_string() +} + +fn get_cpython_source(path: &str) -> String { + format!("{}/{}", get_cpython_repository(), path).into() +} + +fn get_pypy_source(path: &str) -> String { + format!("{}/{}", get_pypy_host(), path).into() +} + fn get_distribution_source() -> String { let distribution_source = env::var("PYAPP_DISTRIBUTION_SOURCE").unwrap_or_default(); if !distribution_source.is_empty() { @@ -352,24 +373,24 @@ fn get_distribution_source() -> String { abi }; - for (python_version, platform, arch, abi, variant, url) in DEFAULT_CPYTHON_DISTRIBUTIONS { + for (python_version, platform, arch, abi, variant, path) in DEFAULT_CPYTHON_DISTRIBUTIONS { if python_version == &selected_python_version && platform == &selected_platform && arch == &selected_arch && abi == &selected_abi && variant == &selected_variant { - return url.to_string(); + return get_cpython_source(path); } } - for (python_version, platform, arch, abi, url) in DEFAULT_PYPY_DISTRIBUTIONS { + for (python_version, platform, arch, abi, path) in DEFAULT_PYPY_DISTRIBUTIONS { if python_version == &selected_python_version && platform == &selected_platform && arch == &selected_arch && abi == &selected_abi { - return url.to_string(); + return get_pypy_source(path); } } @@ -591,8 +612,11 @@ fn set_distribution_format(distribution_source: &String) { fn set_python_path(distribution_source: &str) { let distribution_variable = "PYAPP_DISTRIBUTION_PYTHON_PATH"; + let custom_cpython_repository = + env::var("PYAPP_DISTRIBUTION_CPYTHON_REPOSITORY").unwrap_or_default(); let on_windows = env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows"; let python_path = env::var(distribution_variable).unwrap_or_default(); + let mut relative_path = if !python_path.is_empty() { normalize_relative_path(&python_path) } else if !env::var("PYAPP_DISTRIBUTION_PATH") @@ -600,7 +624,9 @@ fn set_python_path(distribution_source: &str) { .is_empty() { panic!("\n\nThe following option must be set when embedding a custom distribution: {distribution_variable}\n\n"); - } else if distribution_source.starts_with(DEFAULT_CPYTHON_SOURCE) { + } else if distribution_source.starts_with(DEFAULT_CPYTHON_SOURCE) + || distribution_source.starts_with(&custom_cpython_repository) + { if get_python_version() == "3.7" { if on_windows { r"python\install\python.exe".to_string() @@ -922,6 +948,12 @@ fn set_uv_only_bootstrap() { } } +fn set_uv_repository() { + let variable = "PYAPP_UV_REPOSITORY"; + let version = env::var(variable).unwrap_or("https://github.com/astral-sh/uv".to_string()); + set_runtime_variable(variable, version); +} + fn set_uv_version() { let variable = "PYAPP_UV_VERSION"; let version = env::var(variable).unwrap_or("any".to_string()); @@ -1070,6 +1102,7 @@ fn main() { set_pip_allow_config(); set_uv_enabled(); set_uv_only_bootstrap(); + set_uv_repository(); set_uv_version(); set_allow_updates(); set_indicator(); diff --git a/docs/config/distribution.md b/docs/config/distribution.md index 8240b6c..cf914e1 100644 --- a/docs/config/distribution.md +++ b/docs/config/distribution.md @@ -17,7 +17,8 @@ Setting the `PYAPP_PYTHON_VERSION` option will determine the distribution used a | `3.11` | | `3.12` | -The source for pre-built distributions is the [python-build-standalone](https://github.com/indygreg/python-build-standalone) project. +The source for pre-built distributions is the [python-build-standalone](https://github.com/indygreg/python-build-standalone) repository. +Distributions are downloaded from the release section. Some distributions have [variants](https://gregoryszorc.com/docs/python-build-standalone/main/running.html) that may be configured with the `PYAPP_DISTRIBUTION_VARIANT` option: @@ -25,6 +26,8 @@ Some distributions have [variants](https://gregoryszorc.com/docs/python-build-st | --- | --- | | Linux | | +If you want to change the repository URL in order to targer your own GitHub fork/mirror, you can set the `PYAPP_DISTRIBUTION_CPYTHON_REPOSITORY` option. + ### PyPy | ID | @@ -34,6 +37,7 @@ Some distributions have [variants](https://gregoryszorc.com/docs/python-build-st | `pypy3.10` | The source of distributions is the [PyPy](https://www.pypy.org) project. +If you want to change the host in order target your own fork/mirror, you can set the `PYAPP_DISTRIBUTION_PYPY_HOST` option. ## Custom diff --git a/docs/config/installation.md b/docs/config/installation.md index 2957a93..f157493 100644 --- a/docs/config/installation.md +++ b/docs/config/installation.md @@ -8,6 +8,12 @@ These options have no effect when the project installation is [disabled](#skippi You may set the `PYAPP_UV_ENABLED` option to `true` or `1` to use [UV](https://github.com/astral-sh/uv) for virtual environment creation and project installation. +Executable is downloaded from the release section of the repository. + +### Custom repository + +You may use your own GitHub fork/mirror of [UV repository](https://github.com/astral-sh/uv) by setting the `PYAPP_UV_REPOSITORY` option. + ### Version ### {: #uv-version } You may use a specific `X.Y.Z` version by setting the `PYAPP_UV_VERSION` option. diff --git a/docs/users.md b/docs/users.md index 74ae42b..cbef1b8 100644 --- a/docs/users.md +++ b/docs/users.md @@ -14,3 +14,7 @@ The following is not intended to be a complete enumeration. Be sure to view the | [Litestar](https://github.com/litestar-org/litestar-fullstack/blob/dc72eee78173790c3e91b0c095ac9e70ba91bedd/scripts/post-builds.py) | [Preservation Workbench](https://github.com/Preservation-Workbench/PWCode/blob/e7777806be35bd60ca8c33e677ffd77e38b277d0/build/make.sh) | [tidal-wave](https://github.com/ebb-earl-co/tidal-wave/blob/6358ede21adb715a053b1e6cc73968933c3bed05/BUILDME.md#pyapp-created-binaries) + +## Industry + +- [Amadeus](https://amadeus.com) \[[1](https://github.com/ofek/pyapp/pull/147)|[2](https://github.com/AmadeusITGroup/pyapp)\] diff --git a/src/app.rs b/src/app.rs index 4cca7ad..7b97c58 100644 --- a/src/app.rs +++ b/src/app.rs @@ -194,6 +194,13 @@ pub fn uv_only_bootstrap() -> bool { env!("PYAPP_UV_ONLY_BOOTSTRAP") == "1" } +pub fn uv_repository() -> String { + env!("PYAPP_UV_REPOSITORY") + .to_string() + .trim_end_matches('/') + .into() +} + pub fn uv_version() -> String { env!("PYAPP_UV_VERSION").into() } @@ -297,3 +304,20 @@ pub fn installer_lock(name: &str, id: &str) -> PathBuf { .join("locks") .join(format!("installer-{}-{}", name, id)) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn distribution_source_is_python_build_standalone_repository_by_default() { + let source = distribution_source(); + assert!(source + .starts_with("https://github.com/indygreg/python-build-standalone/releases/download/")); + } + + #[test] + fn uv_repository_is_official_one_by_default() { + assert_eq!("https://github.com/astral-sh/uv", uv_repository()); + } +} diff --git a/src/distribution.rs b/src/distribution.rs index 33a9ce3..d8b7075 100644 --- a/src/distribution.rs +++ b/src/distribution.rs @@ -471,6 +471,22 @@ pub fn ensure_installer_available() -> Result<()> { Ok(()) } +fn build_uv_download_url(version: &str, artifact_name: &str) -> String { + let repository = app::uv_repository(); + + if version == "any" { + format!( + "{}/releases/latest/download/{}", + &repository, &artifact_name, + ) + } else { + format!( + "{}/releases/download/{}/{}", + &repository, &version, &artifact_name, + ) + } +} + fn ensure_uv_available() -> Result<()> { let uv_version = app::uv_version(); let lock_path = app::installer_lock("uv", &uv_version); @@ -494,18 +510,7 @@ fn ensure_uv_available() -> Result<()> { let mut f = fs::File::create(&temp_path) .with_context(|| format!("unable to create temporary file: {}", &temp_path.display()))?; - let url = if uv_version == "any" { - format!( - "https://github.com/astral-sh/uv/releases/latest/download/{}", - &artifact_name, - ) - } else { - format!( - "https://github.com/astral-sh/uv/releases/download/{}/{}", - &uv_version, &artifact_name, - ) - }; - + let url = build_uv_download_url(&uv_version, &artifact_name); network::download(&url, &mut f, "UV")?; if artifact_name.ends_with(".zip") { @@ -568,3 +573,24 @@ fn apply_project_features(install_target: String) -> String { format!("{install_target}[{}]", app::pip_project_features()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn download_specific_uv_version_from_official_repository_by_default() { + assert_eq!( + "https://github.com/astral-sh/uv/releases/download/my_version/my_artifact", + build_uv_download_url("my_version", "my_artifact") + ); + } + + #[test] + fn download_latest_uv_version_from_official_repository_by_default() { + assert_eq!( + "https://github.com/astral-sh/uv/releases/latest/download/my_artifact", + build_uv_download_url("any", "my_artifact") + ); + } +}