From 5743e454cef16d0d85f3eb72b86eae6dcd54c9ea Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:49:51 +0800 Subject: [PATCH 1/2] Invoke scripts from project root Fixes #930 --- docs/guide/pyproject.md | 2 ++ rye/src/cli/run.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/guide/pyproject.md b/docs/guide/pyproject.md index 34db616b37..ae6a3a3ad4 100644 --- a/docs/guide/pyproject.md +++ b/docs/guide/pyproject.md @@ -127,6 +127,8 @@ with different keys with the most important key being `cmd` which holds the comm However if only `cmd` is set, then the object is optional. `cmd` itself can either be set to a string or an array of arguments. +Scripts are invoked from the root of the project (where the `pyproject.toml` is located). + ```toml [tool.rye.scripts] # These three options are equivalent: diff --git a/rye/src/cli/run.rs b/rye/src/cli/run.rs index 7db917d72b..dd94f1fa1d 100644 --- a/rye/src/cli/run.rs +++ b/rye/src/cli/run.rs @@ -138,6 +138,7 @@ fn invoke_script( let mut cmd = Command::new(&args[0]); cmd.args(&args[1..]); cmd.env("VIRTUAL_ENV", &*pyproject.venv_path()); + cmd.current_dir(pyproject.root_path()); if let Some(path) = env::var_os("PATH") { let mut paths = split_paths(&path).collect::>(); paths.insert(0, venv_bin.into()); From ad99c4afc8fec3f1ce805ab653ee68122d13149b Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:52:20 +0800 Subject: [PATCH 2/2] Add change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d98c37a34..6ad4fffd95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ _Unreleased_ - Always create `.gitignore` file in `rye init`. #919 +- Invoke Rye scripts from the project root. #932 + ## 0.31.0