Skip to content

Commit

Permalink
Change reqs.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 9, 2024
1 parent d246bdf commit d5da3a2
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
- Fixed `moon ci` showing incorrect job related logs.
- Fixed some issues with the Python toolchain:
- pip is no longer required to be enabled to activate a virtual environment.
- The venv root is now the location of a located `requirements.txt`, otherwise the package root,
or workspace root if `python.rootRequirementsOnly` is enabled.
- Changed `python.rootRequirementsOnly` to `false` by default.
- The venv root is now the location of a found `requirements.txt`, otherwise the package root, or
workspace root if `python.rootRequirementsOnly` is enabled.
- Tasks will now inherit the correct venv paths in `PATH`.

## 1.30.3
Expand Down
4 changes: 4 additions & 0 deletions crates/cli/tests/run_python_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ fn runs_install_deps_via_args() {
}),
..PartialPythonConfig::default()
});

// Needed for venv
sandbox.create_file("base/requirements.txt", "");

let assert = sandbox.run_moon(|cmd| {
cmd.arg("run").arg("python:poetry");
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
---
source: crates/cli/tests/run_python_test.rs
assertion_line: 60
expression: assert.output()
snapshot_kind: text
---
▪▪▪▪ activate virtual environment
▪▪▪▪ python venv
▪▪▪▪ pip install
▪▪▪▪ python:poetry
Poetry (version 1.8.4)
Expand Down
1 change: 0 additions & 1 deletion crates/config/src/toolchain/python_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub struct PythonConfig {

/// Assumes only the root `requirements.txt` is used for dependencies.
/// Can be used to support the "one version policy" pattern.
#[setting(default = true)]
pub root_requirements_only: bool,

/// Defines the virtual environment name, which will be created in the workspace root.
Expand Down
2 changes: 1 addition & 1 deletion legacy/python/platform/src/actions/install_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn install_deps(
.join(&python.config.venv_name)
};

if !venv_root.exists() {
if !venv_root.exists() && requirements_path.is_some() {
console
.out
.print_checkpoint(Checkpoint::Setup, "python venv")?;
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/python/base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
7 changes: 3 additions & 4 deletions website/docs/config/toolchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -758,19 +758,18 @@ Python installation's are based on pre-built binaries provided by
Supports the "single version policy" or "one version rule" patterns by only allowing dependencies in
the root `requirements.txt`, and only installing dependencies in the workspace root, and not within
individual projects. It also bypasses all `workspaces` checks to determine package locations.
Defaults to `true`.

```yaml title=".moon/toolchain.yml" {2}
python:
rootRequirementsOnly: false
rootRequirementsOnly: true
```

### `venvName`

<HeadingApiLink to="/api/types/interface/PythonConfig#venvName" />

Defines the virtual environment file name, which will be created in the workspace or project root,
and where dependencies will be installed into. Defaults to `.venv`
Defines the virtual environment name, which will be created in the workspace or project root when a
`requirements.txt` exists, and where dependencies will be installed into. Defaults to `.venv`

```yaml title=".moon/toolchain.yml" {2}
python:
Expand Down

0 comments on commit d5da3a2

Please sign in to comment.