Skip to content

Commit

Permalink
Merge branch 'main' into cnp-prerelease
Browse files Browse the repository at this point in the history
  • Loading branch information
cnpryer committed Mar 4, 2024
2 parents 6a24d05 + 11af741 commit 030f10f
Show file tree
Hide file tree
Showing 16 changed files with 232 additions and 40 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Clippy

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
build:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/python-format.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Python format

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
format:
Expand All @@ -9,6 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: eifinger/setup-rye@v1
- uses: eifinger/setup-rye@v2
- name: Rye fmt
run: rye fmt --check
8 changes: 6 additions & 2 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Python lint

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
lint:
Expand All @@ -9,6 +13,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: eifinger/setup-rye@v1
- uses: eifinger/setup-rye@v2
- name: Rye lint
run: rye lint
6 changes: 5 additions & 1 deletion .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Rustfmt

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
build:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Spelling

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
typos:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-python-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Rye
uses: eifinger/setup-rye@v1
uses: eifinger/setup-rye@v2
with:
enable-cache: true
- name: Sync Python Releases
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-uv-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Rye
uses: eifinger/setup-rye@v1
uses: eifinger/setup-rye@v2
with:
enable-cache: true
- name: Sync UV Releases
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Tests

on: [push, pull_request]
on:
workflow_dispatch:
push:
branches: [main]
pull_request:

jobs:
test-latest-linux:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ that were not yet released.

_Unreleased_

- `--skip-existing` is now available with Rye's `publish` command. #831

- Bumped `uv` to 0.1.13. #760, #820

- Bumped `ruff` to 0.3.0. #821

- The `init` command now generates a script with the name of the
project rather than `hello`. #801

- Retain markers when adding dependencies with features when uv is used. #807

- Fixed a bug that caused repeated syncs not to recall all previous options. #830

<!-- released start -->

## 0.27.0
Expand Down
2 changes: 1 addition & 1 deletion docs/philosophy.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on my mind when I built it:
format and uses [`uv`](https://github.com/astral-sh/uv) and
[`pip-tools`](https://github.com/jazzband/pip-tools) behind the scenes.

- **No Pip:** Rye uses pip, but it does not expose it. It manage dependencies in
- **No Pip:** Rye uses pip, but it does not expose it. It manages dependencies in
`pyproject.toml` only.

- **No System Python:** I can't deal with any more linux distribution weird Python
Expand Down
4 changes: 2 additions & 2 deletions rye/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub const SELF_PYTHON_TARGET_VERSION: PythonVersionRequest = PythonVersionReques
suffix: None,
};

const SELF_VERSION: u64 = 14;
const SELF_VERSION: u64 = 16;

const SELF_REQUIREMENTS: &str = r#"
build==1.0.3
Expand All @@ -50,7 +50,7 @@ twine==4.0.2
unearth==0.14.0
urllib3==2.0.7
virtualenv==20.25.0
ruff==0.2.2
ruff==0.3.0
"#;

static FORCED_TO_UPDATE: AtomicBool = AtomicBool::new(false);
Expand Down
6 changes: 6 additions & 0 deletions rye/src/cli/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub struct Args {
/// Path to alternate CA bundle.
#[arg(long)]
cert: Option<PathBuf>,
/// Continue uploading files if one already exists (only applies to repositories supporting this feature)
#[arg(long)]
skip_existing: bool,
/// Skip prompts.
#[arg(short, long)]
yes: bool,
Expand Down Expand Up @@ -167,6 +170,9 @@ pub fn execute(cmd: Args) -> Result<(), Error> {
if let Some(cert) = cmd.cert {
publish_cmd.arg("--cert").arg(cert);
}
if cmd.skip_existing {
publish_cmd.arg("--skip-existing");
}

if output == CommandOutput::Quiet {
publish_cmd.stdout(Stdio::null());
Expand Down
50 changes: 31 additions & 19 deletions rye/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static REQUIREMENTS_HEADER: &str = r#"# generated by rye
"#;
static PARAM_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^# (pre|features|all-features|with_sources):\s*(.*?)$").unwrap());
Lazy::new(|| Regex::new(r"^# (pre|features|all-features|with-sources):\s*(.*?)$").unwrap());

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum LockMode {
Expand Down Expand Up @@ -111,7 +111,9 @@ impl LockOptions {
"all-features" => {
rv.all_features = rv.all_features || serde_json::from_str(value)?
}
"with-sources" => rv.with_sources = serde_json::from_str(value)?,
"with-sources" => {
rv.with_sources = rv.with_sources || serde_json::from_str(value)?
}
_ => unreachable!(),
}
}
Expand Down Expand Up @@ -139,7 +141,8 @@ pub fn update_workspace_lockfile(
echo!("Generating {} lockfile: {}", lock_mode, lockfile.display());
}

let features_by_project = collect_workspace_features(lock_options);
let lock_options = restore_lock_options(lockfile, lock_options)?;
let features_by_project = collect_workspace_features(&lock_options);
let mut req_file = NamedTempFile::new()?;

let mut local_projects = HashMap::new();
Expand Down Expand Up @@ -185,14 +188,27 @@ pub fn update_workspace_lockfile(
req_file.path(),
lockfile,
sources,
lock_options,
&lock_options,
&exclusions,
true,
)?;

Ok(())
}

/// Tries to restore the lock options from the given lockfile.
fn restore_lock_options<'o>(
lockfile: &Path,
lock_options: &'o LockOptions,
) -> Result<Cow<'o, LockOptions>, Error> {
if lockfile.is_file() {
let requirements = fs::read_to_string(lockfile)?;
Ok(LockOptions::restore(&requirements, lock_options)?)
} else {
Ok(Cow::Borrowed(lock_options))
}
}

fn format_project_extras<'a>(
features_by_project: Option<&'a HashMap<String, HashSet<&str>>>,
project: &PyProject,
Expand Down Expand Up @@ -307,11 +323,12 @@ pub fn update_single_project_lockfile(
echo!("Generating {} lockfile: {}", lock_mode, lockfile.display());
}

let lock_options = restore_lock_options(lockfile, lock_options)?;
let mut req_file = NamedTempFile::new()?;

// virtual packages are themselves not installed
if !pyproject.is_virtual() {
let features_by_project = collect_workspace_features(lock_options);
let features_by_project = collect_workspace_features(&lock_options);
let applicable_extras = format_project_extras(features_by_project.as_ref(), pyproject)?;
writeln!(
req_file,
Expand Down Expand Up @@ -340,7 +357,7 @@ pub fn update_single_project_lockfile(
req_file.path(),
lockfile,
sources,
lock_options,
&lock_options,
&exclusions,
false,
)?;
Expand All @@ -363,19 +380,14 @@ fn generate_lockfile(
let use_uv = Config::current().use_uv();
let scratch = tempfile::tempdir()?;
let requirements_file = scratch.path().join("requirements.txt");
let lock_options = if lockfile.is_file() {
let requirements = fs::read_to_string(lockfile)?;
fs::write(&requirements_file, &requirements)
if lockfile.is_file() {
fs::copy(lockfile, &requirements_file)
.path_context(&requirements_file, "unable to restore requirements file")?;
LockOptions::restore(&requirements, lock_options)?
} else {
if !use_uv {
fs::write(&requirements_file, b"").path_context(
&requirements_file,
"unable to write empty requirements file",
)?;
}
Cow::Borrowed(lock_options)
} else if !use_uv {
fs::write(&requirements_file, b"").path_context(
&requirements_file,
"unable to write empty requirements file",
)?;
};

let mut cmd = if use_uv {
Expand Down Expand Up @@ -454,7 +466,7 @@ fn generate_lockfile(
workspace_path,
exclusions,
sources,
&lock_options,
lock_options,
)?;

Ok(())
Expand Down
14 changes: 7 additions & 7 deletions rye/src/sources/generated/uv_downloads.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// To regenerate, run `rye run uv-downloads > rye/src/generated/uv_downloads.inc` from the root of the repository.
use std::borrow::Cow;
pub const UV_DOWNLOADS: &[UvDownload] = &[
UvDownload {arch: Cow::Borrowed("aarch64"), os: Cow::Borrowed("macos"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-aarch64-apple-darwin.tar.gz"), sha256: Cow::Borrowed("64e0aeae1d5135684c65e5d41741f1b2eba5c60e574dfef7386712b259066d95") },
UvDownload {arch: Cow::Borrowed("aarch64"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-aarch64-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("56a7edd9bfadab67100bde6aca3012c9d7d8619405ebb360eae50b88ba2c6dff") },
UvDownload {arch: Cow::Borrowed("i686"), os: Cow::Borrowed("windows"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-i686-pc-windows-msvc.zip"), sha256: Cow::Borrowed("75e74c43bf6aeb3cd83a7b7a1f578c2247c48a03fa421317ca7f27f881c0890e") },
UvDownload {arch: Cow::Borrowed("i686"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-i686-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("f8d63781a8a0d3452f7322268a4bfb3a6e06816b76deafde660d53bbc2d790d9") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("macos"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-x86_64-apple-darwin.tar.gz"), sha256: Cow::Borrowed("62f2c6696fdf8bf394662cad54244411b9e96908de9e52b3743955b0d94bd8d4") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("windows"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-x86_64-pc-windows-msvc.zip"), sha256: Cow::Borrowed("e3e49f27f032c195f01d33df30dff16c9ce7d6ac60512c1af117fc4597d0e632") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 11, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.11/uv-x86_64-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("8b1d098549f46814ed40975db6e88aba2eb541196bea54753b08f789b6db8384") },
UvDownload {arch: Cow::Borrowed("aarch64"), os: Cow::Borrowed("macos"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-aarch64-apple-darwin.tar.gz"), sha256: Cow::Borrowed("9d7a71dbb75dbabcbaace98d06517caa691ec8dab8ecbda3afee44ac9cb1e1c3") },
UvDownload {arch: Cow::Borrowed("aarch64"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-aarch64-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("16429c1a00b0a1fb653ae8a104d5af121bc765f047a7b750f356515c50c226c7") },
UvDownload {arch: Cow::Borrowed("i686"), os: Cow::Borrowed("windows"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-i686-pc-windows-msvc.zip"), sha256: Cow::Borrowed("5e75f004ece194c6c0bbec894f229bae440556c3c43df6d6a33a93b287a6ef96") },
UvDownload {arch: Cow::Borrowed("i686"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-i686-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("3a74bace4da3dbdc3f36e7720d7f6bc56098716e7c3e949664b301136fdf3dee") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("macos"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-x86_64-apple-darwin.tar.gz"), sha256: Cow::Borrowed("ad133fc0c67cbe2d578631d77d2f6442626c77a1e144bbda2912b7af9085e91a") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("windows"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-x86_64-pc-windows-msvc.zip"), sha256: Cow::Borrowed("f61cc5c329abc535248cce0912fe01c20e7c99ae9bead6015842f8c5fd3cdfeb") },
UvDownload {arch: Cow::Borrowed("x86_64"), os: Cow::Borrowed("linux"), major: 0, minor: 1, patch: 13, suffix: None, url: Cow::Borrowed("https://github.com/astral-sh/uv/releases/download/0.1.13/uv-x86_64-unknown-linux-gnu.tar.gz"), sha256: Cow::Borrowed("2bfc6a542a3df6af6f56ccd8ec9f1b0596fff62b11650b0bdb830f10ee4e2d64") },
];
2 changes: 1 addition & 1 deletion rye/src/templates/lib/maturin/lib.rs.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const LIB_RS_TEMPLATE: &str = r#"use pyo3::prelude::*;
use pyo3::prelude::*;

/// Prints a message.
#[pyfunction]
Expand Down
Loading

0 comments on commit 030f10f

Please sign in to comment.