summaryrefslogtreecommitdiff
path: root/uv-build.spec
blob: 52db8ca729a8dfbf563f802faf80247d390d6b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# uv-build -- the PEP 517 build backend of the uv project.
#
# Upstream publishes it as the standalone `uv-build` PyPI package built from
# crates/uv-build: a small Rust binary plus the pure-Python `uv_build` module
# that build frontends import and that dispatches to the binary.
#
# Source tarball top level directory: %{name}-%{version}

%global pypi_name uv-build
%global crate     uv-build

# The release profile upstream uses carries no DWARF, so the debug info
# extracted by find-debuginfo is empty and rpmbuild aborts with
# "Empty %files file debugfiles.list".
%global debug_package %{nil}

Name:           python-%{pypi_name}
Version:        0.8.13
Release:        1%{?dist}
Summary:        The uv build backend

License:        MIT OR Apache-2.0
URL:            https://github.com/astral-sh/uv

Source0:        https://github.com/astral-sh/uv/archive/refs/tags/%{version}/uv-%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        %{name}-vendor.tar.gz

BuildRequires:  rust >= 1.86
BuildRequires:  cargo
BuildRequires:  gcc
BuildRequires:  python3-devel

%description
uv-build is uv's native build backend for pure Python projects. It implements
the PEP 517 and PEP 660 hooks (build_wheel, build_sdist, build_editable,
prepare_metadata_for_build_wheel, ...) and is considerably faster than the
generic pure-Python backends, at the cost of only supporting pure Python code.

The hooks live in a small Rust binary; the uv_build module is a thin Python
shim that dispatches to it.


%package -n python3-%{pypi_name}
Summary:        The uv build backend
Provides:       python3dist(%{pypi_name}) = %{version}

%description -n python3-%{pypi_name}
uv-build is uv's native build backend for pure Python projects. It implements
the PEP 517 and PEP 660 hooks (build_wheel, build_sdist, build_editable,
prepare_metadata_for_build_wheel, ...) and is considerably faster than the
generic pure-Python backends, at the cost of only supporting pure Python code.

The hooks live in a small Rust binary; the uv_build module is a thin Python
shim that dispatches to it.


%prep
%autosetup -n %{name}-%{version}

# Unpack the vendored crates: the COPR builders have no network access, so the
# build has to run against a local replacement of the crate sources.
# The replacement map was produced by `cargo vendor` on the upstream tree.
tar -xf %{SOURCE1}
mkdir -p .cargo
cat > .cargo/config.toml << 'EOF'
[source.crates-io]
replace-with = "vendored-sources"

[source."git+https://github.com/astral-sh/pubgrub?rev=06ec5a5f59ffaeb6cf5079c6cb184467da06c9db"]
git = "https://github.com/astral-sh/pubgrub"
rev = "06ec5a5f59ffaeb6cf5079c6cb184467da06c9db"
replace-with = "vendored-sources"

[source."git+https://github.com/astral-sh/reqwest-middleware?rev=ad8b9d332d1773fde8b4cd008486de5973e0a3f8"]
git = "https://github.com/astral-sh/reqwest-middleware"
rev = "ad8b9d332d1773fde8b4cd008486de5973e0a3f8"
replace-with = "vendored-sources"

[source."git+https://github.com/astral-sh/rs-async-zip?rev=285e48742b74ab109887d62e1ae79e7c15fd4878"]
git = "https://github.com/astral-sh/rs-async-zip"
rev = "285e48742b74ab109887d62e1ae79e7c15fd4878"
replace-with = "vendored-sources"

[source."git+https://github.com/astral-sh/tl.git?rev=6e25b2ee2513d75385101a8ff9f591ef51f314ec"]
git = "https://github.com/astral-sh/tl.git"
rev = "6e25b2ee2513d75385101a8ff9f591ef51f314ec"
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor/"
EOF


%build
cargo build --release --offline --locked -p %{crate}


%check
# The upstream Rust test-suite needs network access and test fixtures that are
# not part of the vendored sources, so it cannot run here. Smoke-test the
# backend binary instead: `uv-build --help` is upstream's own smoke test.
%{buildroot}%{_bindir}/%{crate} --help


%install
install -Dpm0755 target/release/%{crate} %{buildroot}%{_bindir}/%{crate}

# uv_build is the pure-Python shim, shipped from crates/%{crate}/python.
mkdir -p %{buildroot}%{python3_sitelib}/uv_build
install -pm0644 crates/%{crate}/python/uv_build/__init__.py \
                crates/%{crate}/python/uv_build/__main__.py \
                crates/%{crate}/python/uv_build/py.typed \
                %{buildroot}%{python3_sitelib}/uv_build/

# Upstream builds this project with maturin, which is what normally emits the
# dist-info directory. Building with cargo directly means emitting that
# metadata here; it is what makes the distribution visible to
# importlib.metadata and to the RPM python3dist() dependency generator.
distinfo=%{buildroot}%{python3_sitelib}/uv_build-%{version}.dist-info
mkdir -p "$distinfo"
cat > "$distinfo/METADATA" <<EOF
Metadata-Version: 2.1
Name: %{pypi_name}
Version: %{version}
Summary: The uv build backend
License: MIT OR Apache-2.0
Requires-Python: >=3.8
EOF
cat > "$distinfo/WHEEL" <<EOF
Wheel-Version: 1.0
Generator: uv-build RPM
Root-Is-Purelib: false
EOF
echo uv_build > "$distinfo/top_level.txt"
cat > "$distinfo/RECORD" <<EOF
uv_build/__init__.py,,
uv_build/__main__.py,,
uv_build/py.typed,,
uv_build-%{version}.dist-info/METADATA,,
uv_build-%{version}.dist-info/WHEEL,,
uv_build-%{version}.dist-info/top_level.txt,,
uv_build-%{version}.dist-info/RECORD,,
EOF


%files -n python3-%{pypi_name}
%license LICENSE-MIT LICENSE-APACHE
%doc crates/%{crate}/README.md
%{_bindir}/%{crate}
%{python3_sitelib}/uv_build/
%{python3_sitelib}/uv_build-%{version}.dist-info/


%changelog
* Tue Sep 22 2026 Python_Bot <Python_Bot@openeuler.org> - 0.8.13-1
- Initial package