Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: find links with manifest-path #1864

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/pixi_uv_conversions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ version = "0.1.0"
distribution-filename = { workspace = true }
distribution-types = { workspace = true }
dunce = { workspace = true }
pep508_rs = { workspace = true }
pep508_rs = { workspace = true, features = ["non-pep508-extensions"] }
pixi_manifest = { workspace = true }
pypi-types = { workspace = true }
rattler_lock = { workspace = true }
Expand Down
17 changes: 10 additions & 7 deletions crates/pixi_uv_conversions/src/conversions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use distribution_types::{FlatIndexLocation, IndexLocations, IndexUrl};
use pep508_rs::{VerbatimUrl, VerbatimUrlError};
use pixi_manifest::pypi::pypi_options::PypiOptions;
use pixi_manifest::pypi::GitRev;
use pixi_manifest::pypi::{pypi_options::PypiOptions, GitRev};
use rattler_lock::FindLinksUrlOrPath;
use uv_git::GitReference;

Expand All @@ -16,11 +15,13 @@ pub enum ConvertFlatIndexLocationError {
/// Converts to the [`distribution_types::FlatIndexLocation`]
pub fn to_flat_index_location(
find_links: &FindLinksUrlOrPath,
base_path: &Path,
) -> Result<FlatIndexLocation, ConvertFlatIndexLocationError> {
match find_links {
FindLinksUrlOrPath::Path(path) => Ok(FlatIndexLocation::Path(
VerbatimUrl::from_path(path.clone())
.map_err(|e| ConvertFlatIndexLocationError::VerbatimUrlError(e, path.clone()))?,
VerbatimUrl::parse_path(path.clone(), base_path)
.map_err(|e| ConvertFlatIndexLocationError::VerbatimUrlError(e, path.clone()))?
.with_given(path.display().to_string()),
)),
FindLinksUrlOrPath::Url(url) => {
Ok(FlatIndexLocation::Url(VerbatimUrl::from_url(url.clone())))
Expand All @@ -31,6 +32,7 @@ pub fn to_flat_index_location(
/// Convert the subset of pypi-options to index locations
pub fn pypi_options_to_index_locations(
options: &PypiOptions,
base_path: &Path,
) -> Result<IndexLocations, ConvertFlatIndexLocationError> {
// Convert the index to a `IndexUrl`
let index = options
Expand All @@ -55,7 +57,7 @@ pub fn pypi_options_to_index_locations(
// Convert to list of flat indexes
flat_indexes
.into_iter()
.map(|i| to_flat_index_location(&i))
.map(|i| to_flat_index_location(&i, base_path))
.collect::<Result<Vec<_>, _>>()?
} else {
vec![]
Expand All @@ -75,6 +77,7 @@ pub fn pypi_options_to_index_locations(
/// Convert locked indexes to IndexLocations
pub fn locked_indexes_to_index_locations(
indexes: &rattler_lock::PypiIndexes,
base_path: &Path,
) -> Result<IndexLocations, ConvertFlatIndexLocationError> {
let index = indexes
.indexes
Expand All @@ -93,7 +96,7 @@ pub fn locked_indexes_to_index_locations(
let flat_indexes = indexes
.find_links
.iter()
.map(to_flat_index_location)
.map(|find_link| to_flat_index_location(find_link, base_path))
.collect::<Result<Vec<_>, _>>()?;

// we don't have support for an explicit `no_index` field in the `PypiIndexes`
Expand Down
577 changes: 294 additions & 283 deletions examples/pypi-find-links/pixi.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/pypi-find-links/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ platforms = ["osx-arm64", "osx-64", "linux-64", "win-64"]
[project.pypi-options]
# This is similar to the --find-links option in pip
find-links = [{ path = "./links" }]
index-url = "https://pypi.org/simple"

[tasks]
start = { depends-on = ["test"] }
Expand Down
3 changes: 2 additions & 1 deletion src/cli/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ pub async fn execute(args: Args) -> miette::Result<()> {
if environment.has_pypi_dependencies() {
uv_context = UvResolutionContext::from_project(&project)?;
index_locations =
pypi_options_to_index_locations(&environment.pypi_options()).into_diagnostic()?;
pypi_options_to_index_locations(&environment.pypi_options(), project.root())
.into_diagnostic()?;
tags = get_pypi_tags(
platform,
&environment.system_requirements(),
Expand Down
12 changes: 6 additions & 6 deletions src/install_pypi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ use itertools::Itertools;
use miette::{IntoDiagnostic, WrapErr};
use pep440_rs::Version;
use pep508_rs::{VerbatimUrl, VerbatimUrlError};
use pixi_consts::consts;
use pixi_manifest::{pyproject::PyProjectManifest, SystemRequirements};
use pixi_uv_conversions::locked_indexes_to_index_locations;
use pypi_modifiers::pypi_tags::{get_pypi_tags, is_python_record};
use pypi_types::{
HashAlgorithm, HashDigest, ParsedDirectoryUrl, ParsedGitUrl, ParsedPathUrl, ParsedUrl,
ParsedUrlError, VerbatimParsedUrl,
Expand All @@ -39,9 +42,6 @@ use crate::{
prefix::Prefix,
uv_reporter::{UvReporter, UvReporterOptions},
};
use pixi_consts::consts;
use pixi_uv_conversions::locked_indexes_to_index_locations;
use pypi_modifiers::pypi_tags::{get_pypi_tags, is_python_record};

type CombinedPypiPackageData = (PypiPackageData, PypiPackageEnvironmentData);

Expand Down Expand Up @@ -420,8 +420,8 @@ fn need_reinstall(
Ok(git) => {
// Check the repository base url
if git.url.repository() != &url
// Check the sha from the direct_url.json and the required sha
// Use the uv git url to get the sha
// Check the sha from the direct_url.json and the required sha
// Use the uv git url to get the sha
|| vcs_info.commit_id != git.url.precise().map(|p| p.to_string())
{
return Ok(ValidateInstall::Reinstall);
Expand Down Expand Up @@ -607,7 +607,7 @@ pub async fn update_python_distributions(
let tags = get_pypi_tags(platform, system_requirements, &python_record.package_record)?;

let index_locations = pypi_indexes
.map(locked_indexes_to_index_locations)
.map(|indexes| locked_indexes_to_index_locations(indexes, lock_file_dir))
.unwrap()
.into_diagnostic()?;

Expand Down
Loading
Loading