|
| 1 | +# Copyright 1999-2024 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +CRATES=" |
| 7 | +" |
| 8 | + |
| 9 | +declare -A GIT_CRATES=( |
| 10 | + [async_zip]='https://github.com/charliermarsh/rs-async-zip;011b24604fa7bc223daaad7712c0694bac8f0a87;rs-async-zip-%commit%' |
| 11 | + [pubgrub]='https://github.com/astral-sh/pubgrub;388685a8711092971930986644cfed152d1a1f6c;pubgrub-%commit%' |
| 12 | + [reqwest-middleware]='https://github.com/astral-sh/reqwest-middleware;5e3eaf254b5bd481c75d2710eed055f95b756913;reqwest-middleware-%commit%/reqwest-middleware' |
| 13 | + [reqwest-retry]='https://github.com/astral-sh/reqwest-middleware;5e3eaf254b5bd481c75d2710eed055f95b756913;reqwest-middleware-%commit%/reqwest-retry' |
| 14 | + [tl]='https://github.com/charliermarsh/tl;6e25b2ee2513d75385101a8ff9f591ef51f314ec;tl-%commit%' |
| 15 | +) |
| 16 | + |
| 17 | +inherit cargo check-reqs |
| 18 | + |
| 19 | +CRATE_PV=0.4.14 |
| 20 | +DESCRIPTION="A Python package installer and resolver, written in Rust" |
| 21 | +HOMEPAGE=" |
| 22 | + https://github.com/astral-sh/uv/ |
| 23 | + https://pypi.org/project/uv/ |
| 24 | +" |
| 25 | +# pypi sdist misses scripts/, needed for tests |
| 26 | +SRC_URI=" |
| 27 | + https://github.com/astral-sh/uv/archive/${PV}.tar.gz |
| 28 | + -> ${P}.gh.tar.gz |
| 29 | + ${CARGO_CRATE_URIS} |
| 30 | +" |
| 31 | +if [[ ${PKGBUMPING} != ${PVR} ]]; then |
| 32 | + SRC_URI+=" |
| 33 | + https://dev.gentoo.org/~mgorny/dist/uv-${CRATE_PV}-crates.tar.xz |
| 34 | + " |
| 35 | +fi |
| 36 | + |
| 37 | +# most of the code |
| 38 | +LICENSE="|| ( Apache-2.0 MIT )" |
| 39 | +# crates/pep508-rs is || ( Apache-2.0 BSD-2 ) which is covered below |
| 40 | +# Dependent crate licenses |
| 41 | +LICENSE+=" |
| 42 | + 0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD ISC MIT |
| 43 | + MPL-2.0 Unicode-DFS-2016 |
| 44 | +" |
| 45 | +# ring crate |
| 46 | +LICENSE+=" openssl" |
| 47 | +SLOT="0" |
| 48 | +KEYWORDS="amd64 arm arm64 x86" |
| 49 | +IUSE="test" |
| 50 | +RESTRICT="test" |
| 51 | +PROPERTIES="test_network" |
| 52 | + |
| 53 | +DEPEND=" |
| 54 | + app-arch/bzip2:= |
| 55 | + app-arch/xz-utils:= |
| 56 | + app-arch/zstd:= |
| 57 | +" |
| 58 | +RDEPEND=" |
| 59 | + ${DEPEND} |
| 60 | +" |
| 61 | +BDEPEND=" |
| 62 | + >=virtual/rust-1.80 |
| 63 | + test? ( |
| 64 | + dev-lang/python:3.8 |
| 65 | + dev-lang/python:3.9 |
| 66 | + dev-lang/python:3.10 |
| 67 | + dev-lang/python:3.11 |
| 68 | + dev-lang/python:3.12 |
| 69 | + ) |
| 70 | +" |
| 71 | + |
| 72 | +QA_FLAGS_IGNORED="usr/bin/.*" |
| 73 | + |
| 74 | +check_space() { |
| 75 | + local CHECKREQS_DISK_BUILD=3G |
| 76 | + use debug && CHECKREQS_DISK_BUILD=9G |
| 77 | + check-reqs_pkg_setup |
| 78 | +} |
| 79 | + |
| 80 | +pkg_pretend() { |
| 81 | + check_space |
| 82 | +} |
| 83 | + |
| 84 | +pkg_setup() { |
| 85 | + check_space |
| 86 | +} |
| 87 | + |
| 88 | +src_prepare() { |
| 89 | + default |
| 90 | + |
| 91 | + # remove patch.* that breaks GIT_CRATES |
| 92 | + local reqmw=${GIT_CRATES[reqwest-middleware]} |
| 93 | + reqmw=${reqmw#*;} |
| 94 | + reqmw=${reqmw%;*} |
| 95 | + sed -i -e "/^\[patch/,\$s@^\(reqwest-middleware = \).*@\1 { path = \"${WORKDIR}/reqwest-middleware-${reqmw}/reqwest-middleware\" }@" Cargo.toml || die |
| 96 | + |
| 97 | + # enable system libraries where supported |
| 98 | + export ZSTD_SYS_USE_PKG_CONFIG=1 |
| 99 | + sed -i -e 's:"static"::' crates/uv-extract/Cargo.toml || die |
| 100 | + # TODO: unbundle libz-ng-sys, tikv-jemalloc-sys? |
| 101 | + |
| 102 | + # remove unbundled sources, just in case |
| 103 | + find "${ECARGO_VENDOR}"/{bzip2,lzma,zstd}-sys-*/ -name '*.c' -delete || die |
| 104 | + |
| 105 | + # bzip2-sys requires a pkg-config file |
| 106 | + # https://github.com/alexcrichton/bzip2-rs/issues/104 |
| 107 | + mkdir "${T}/pkg-config" || die |
| 108 | + export PKG_CONFIG_PATH=${T}/pkg-config${PKG_CONFIG_PATH+:${PKG_CONFIG_PATH}} |
| 109 | + cat >> "${T}/pkg-config/bzip2.pc" <<-EOF || die |
| 110 | + Name: bzip2 |
| 111 | + Version: 9999 |
| 112 | + Description: |
| 113 | + Libs: -lbz2 |
| 114 | + EOF |
| 115 | +} |
| 116 | + |
| 117 | +src_compile() { |
| 118 | + cd crates/uv || die |
| 119 | + cargo_src_compile |
| 120 | +} |
| 121 | + |
| 122 | +src_test() { |
| 123 | + # work around https://github.com/astral-sh/uv/issues/4376 |
| 124 | + local -x PATH=${BROOT}/usr/lib/python-exec/python3.12:${PATH} |
| 125 | + local -x COLUMNS=100 |
| 126 | + local -x PYTHONDONTWRITEBYTECODE= |
| 127 | + |
| 128 | + cd crates/uv || die |
| 129 | + cargo_src_test --no-fail-fast |
| 130 | +} |
| 131 | + |
| 132 | +src_install() { |
| 133 | + cd crates/uv || die |
| 134 | + cargo_src_install |
| 135 | +} |
0 commit comments