Skip to content

Commit

Permalink
Unify packse find links urls (#2969)
Browse files Browse the repository at this point in the history
The sync scenarios script is broken, so i did the updates manually

```
$ ./scripts/sync_scenarios.sh
Setting up a temporary environment...
Using Python 3.12.1 interpreter at: /home/konsti/projects/uv/.venv/bin/python3
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
  × No solution found when resolving dependencies:
  ╰─▶ Because docutils==0.21.post1 is unusable because the package metadata was inconsistent and you require docutils==0.21.post1, we can conclude that the requirements are unsatisfiable.

      hint: Metadata for docutils==0.21.post1 was inconsistent:
        Package metadata version `0.21` does not match given version `0.21.post1`
```

---------

Co-authored-by: Zanie Blue <[email protected]>
  • Loading branch information
konstin and zanieb authored Apr 11, 2024
1 parent 5f59e30 commit c85c52d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/uv-git/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl GitSource {
}

/// Fetch the underlying Git repository at the given revision.
#[instrument(skip(self))]
#[instrument(skip(self), fields(repository = %self.git.repository, rev = ?self.git.precise))]
pub fn fetch(self) -> Result<Fetch> {
// The path to the repo, within the Git database.
let ident = digest(&RepositoryUrl::new(&self.git.repository));
Expand Down
5 changes: 5 additions & 0 deletions crates/uv/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ use uv_toolchain::{toolchains_for_version, PythonVersion};
// Exclude any packages uploaded after this date.
pub static EXCLUDE_NEWER: &str = "2024-03-25T00:00:00Z";

/// Using a find links url allows using `--index-url` instead of `--extra-index-url` in tests
/// to prevent dependency confusion attacks against our test suite.
pub const BUILD_VENDOR_LINKS_URL: &str =
"https://raw.githubusercontent.com/astral-sh/packse/0.3.14/vendor/links.html";

#[doc(hidden)] // Macro and test context only, don't use directly.
pub const INSTA_FILTERS: &[(&str, &str)] = &[
(r"--cache-dir [^\s]+", "--cache-dir [CACHE_DIR]"),
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/pip_compile_scenarios.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DO NOT EDIT
//!
//! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/zanieb/packse/tree/0.3.13/scenarios>
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.14/scenarios>
//!
#![cfg(all(feature = "python", feature = "pypi", unix))]

Expand All @@ -27,9 +27,9 @@ fn command(context: &TestContext, python_versions: &[&str]) -> Command {
.arg("compile")
.arg("requirements.in")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.13/simple-html/")
.arg("https://astral-sh.github.io/packse/0.3.14/simple-html/")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/zanieb/packse/0.3.13/vendor/links.html")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.14/vendor/links.html")
.arg("--cache-dir")
.arg(context.cache_dir.path())
.env("VIRTUAL_ENV", context.venv.as_os_str())
Expand Down
18 changes: 9 additions & 9 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#![cfg(all(feature = "python", feature = "pypi"))]

use std::process::Command;

use anyhow::Result;
use assert_cmd::prelude::*;
use assert_fs::prelude::*;
use base64::{prelude::BASE64_STANDARD as base64, Engine};
use indoc::indoc;
use itertools::Itertools;

use std::process::Command;

use common::{uv_snapshot, TestContext};
use uv_fs::Simplified;

use crate::common::get_bin;
use crate::common::{get_bin, BUILD_VENDOR_LINKS_URL};

mod common;

Expand Down Expand Up @@ -3150,7 +3150,7 @@ fn already_installed_dependent_editable() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -3185,7 +3185,7 @@ fn already_installed_dependent_editable() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: false
exit_code: 1
----- stdout -----
Expand Down Expand Up @@ -3246,7 +3246,7 @@ fn already_installed_local_path_dependent() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: true
exit_code: 0
----- stdout -----
Expand Down Expand Up @@ -3281,7 +3281,7 @@ fn already_installed_local_path_dependent() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: false
exit_code: 1
----- stdout -----
Expand Down Expand Up @@ -3321,7 +3321,7 @@ fn already_installed_local_path_dependent() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: false
exit_code: 1
----- stdout -----
Expand All @@ -3343,7 +3343,7 @@ fn already_installed_local_path_dependent() {
// Disable the index to guard this test against dependency confusion attacks
.arg("--no-index")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.12/vendor/links.html"), @r###"
.arg(BUILD_VENDOR_LINKS_URL), @r###"
success: true
exit_code: 0
----- stdout -----
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/pip_install_scenarios.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! DO NOT EDIT
//!
//! Generated with `./scripts/sync_scenarios.sh`
//! Scenarios from <https://github.com/zanieb/packse/tree/0.3.13/scenarios>
//! Scenarios from <https://github.com/astral-sh/packse/tree/0.3.14/scenarios>
//!
#![cfg(all(feature = "python", feature = "pypi", unix))]

Expand Down Expand Up @@ -46,9 +46,9 @@ fn command(context: &TestContext) -> Command {
.arg("pip")
.arg("install")
.arg("--index-url")
.arg("https://astral-sh.github.io/packse/0.3.13/simple-html/")
.arg("https://astral-sh.github.io/packse/0.3.14/simple-html/")
.arg("--find-links")
.arg("https://raw.githubusercontent.com/zanieb/packse/0.3.13/vendor/links.html")
.arg("https://raw.githubusercontent.com/astral-sh/packse/0.3.14/vendor/links.html")
.arg("--cache-dir")
.arg(context.cache_dir.path())
.env("VIRTUAL_ENV", context.venv.as_os_str())
Expand Down
5 changes: 2 additions & 3 deletions scripts/scenarios/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
)
exit(1)


try:
import chevron_blue
except ImportError:
Expand Down Expand Up @@ -175,11 +174,11 @@ def main(scenarios: list[Path], snapshot_update: bool = True):

# Add generated metadata
data["generated_from"] = (
f"https://github.com/zanieb/packse/tree/{ref}/scenarios"
f"https://github.com/astral-sh/packse/tree/{ref}/scenarios"
)
data["generated_with"] = "./scripts/sync_scenarios.sh"
data["vendor_links"] = (
f"https://raw.githubusercontent.com/zanieb/packse/{ref}/vendor/links.html"
f"https://raw.githubusercontent.com/astral-sh/packse/{ref}/vendor/links.html"
)

data["index_url"] = f"https://astral-sh.github.io/packse/{ref}/simple-html/"
Expand Down
2 changes: 1 addition & 1 deletion scripts/scenarios/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ nh3==0.2.17
# via readme-renderer
packaging==24.0
# via hatchling
packse==0.3.13
packse==0.3.14
pathspec==0.12.1
# via hatchling
pkginfo==1.10.0
Expand Down

0 comments on commit c85c52d

Please sign in to comment.