mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
distribution-types: allow RegistrySourceDist to have wheels attached to it (#3610)
Following from #3595, we'd like wheels to make their way into the lock file even if the current environment selects an sdist. With #3595, this didn't happen: $ cargo run -p uv -- pip compile -p3.10 <(echo psycopg2) --unstable-uv-lock-file $ cat uv.lock version = 1 [[distribution]] name = "psycopg2" version = "2.9.9" source = "registry+https://pypi.org/simple" [distribution.sdist] url = "dc6acaf46d/psycopg2-2.9.9.tar.gz
" hash = "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156" The above example uses `psycopg2`, which has an sdist and wheels only on Windows. Since I ran the above on Linux, an sdist was selected. But no wheels appeared in the lock file. With this PR, wheels are now correctly plumbed through: $ cargo run -p uv -- pip compile -p3.10 <(echo psycopg2) --unstable-uv-lock-file $ cat uv.lock version = 1 [[distribution]] name = "psycopg2" version = "2.9.9" source = "registry+https://pypi.org/simple" [distribution.sdist] url = "dc6acaf46d/psycopg2-2.9.9.tar.gz
" hash = "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156" [[distribution.wheel]] url = "2767d96391/psycopg2-2.9.9-cp310-cp310-win32.whl
" hash = "sha256:38a8dcc6856f569068b47de286b472b7c473ac7977243593a288ebce0dc89516" [[distribution.wheel]] url = "6572dec683/psycopg2-2.9.9-cp310-cp310-win_amd64.whl
" hash = "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3" [[distribution.wheel]] url = "1fc5b9d33c/psycopg2-2.9.9-cp311-cp311-win32.whl
" hash = "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372" [[distribution.wheel]] url = "5133dd3183/psycopg2-2.9.9-cp311-cp311-win_amd64.whl
" hash = "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981" [[distribution.wheel]] url = "f74ffe6b6f/psycopg2-2.9.9-cp312-cp312-win32.whl
" hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024" [[distribution.wheel]] url = "c4a26e1918/psycopg2-2.9.9-cp312-cp312-win_amd64.whl
" hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693" [[distribution.wheel]] url = "ffeb9ac356/psycopg2-2.9.9-cp37-cp37m-win32.whl
" hash = "sha256:5e0d98cade4f0e0304d7d6f25bbfbc5bd186e07b38eac65379309c4ca3193efa" [[distribution.wheel]] url = "0a39176d36/psycopg2-2.9.9-cp37-cp37m-win_amd64.whl
" hash = "sha256:7e2dacf8b009a1c1e843b5213a87f7c544b2b042476ed7755be813eaf4e8347a" [[distribution.wheel]] url = "86b90d30c4/psycopg2-2.9.9-cp38-cp38-win32.whl
" hash = "sha256:ff432630e510709564c01dafdbe996cb552e0b9f3f065eb89bdce5bd31fabf4c" [[distribution.wheel]] url = "c439b378ef/psycopg2-2.9.9-cp38-cp38-win_amd64.whl
" hash = "sha256:bac58c024c9922c23550af2a581998624d6e02350f4ae9c5f0bc642c633a2d5e" [[distribution.wheel]] url = "5080c0e61a/psycopg2-2.9.9-cp39-cp39-win32.whl
" hash = "sha256:c92811b2d4c9b6ea0285942b2e7cac98a59e166d59c588fe5cfe1eda58e72d59" [[distribution.wheel]] url = "ec73fe66d4/psycopg2-2.9.9-cp39-cp39-win_amd64.whl
" hash = "sha256:de80739447af31525feddeb8effd640782cf5998e1a4e9192ebdf829717e3913" Ref #3351
This commit is contained in:
parent
a735f6d80c
commit
0a055b7942
5 changed files with 48 additions and 24 deletions
|
@ -221,6 +221,14 @@ pub struct RegistrySourceDist {
|
|||
pub filename: SourceDistFilename,
|
||||
pub file: Box<File>,
|
||||
pub index: IndexUrl,
|
||||
/// When an sdist is selected, it may be the case that there were
|
||||
/// available wheels too. There are many reasons why a wheel might not
|
||||
/// have been chosen (maybe none available are compatible with the
|
||||
/// current environment), but we still want to track that they exist. In
|
||||
/// particular, for generating a universal lock file, we do not want to
|
||||
/// skip emitting wheels to the lock file just because the host generating
|
||||
/// the lock file didn't have any compatible wheels available.
|
||||
pub wheels: Vec<RegistryBuiltWheel>,
|
||||
}
|
||||
|
||||
/// A source distribution that exists at an arbitrary URL.
|
||||
|
|
|
@ -346,12 +346,17 @@ impl PrioritizedDist {
|
|||
/// If this prioritized dist has an sdist, then this creates a source
|
||||
/// distribution.
|
||||
pub fn source_dist(&self) -> Option<RegistrySourceDist> {
|
||||
// FIXME: We shouldn't be dropping all wheels here. When doing
|
||||
// universal resolution, just because the host machine wants to use an
|
||||
// sdist doesn't mean we should not put any wheels in the lock file.
|
||||
// This probably means modifying RegistrySourceDist to look more like
|
||||
// RegistryBuiltDist, but prioritizes the sdist.
|
||||
let sdist = self.0.source.as_ref().map(|(sdist, _)| sdist.clone())?;
|
||||
let mut sdist = self.0.source.as_ref().map(|(sdist, _)| sdist.clone())?;
|
||||
assert!(
|
||||
sdist.wheels.is_empty(),
|
||||
"source distribution should not have any wheels yet"
|
||||
);
|
||||
sdist.wheels = self
|
||||
.0
|
||||
.wheels
|
||||
.iter()
|
||||
.map(|(wheel, _)| wheel.clone())
|
||||
.collect();
|
||||
Some(sdist)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue