-
-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Add Python tier 2 and 3 support. (#1694)
* Save my work * next iteration * Latest version * Run linter * run pip with install args * build: Prepare v1.30 release. * new: Add new workspace builder. (#1697) * Add workspace crate. * Add projects loading. * Add build. * Clean up build data. * Flesh out build. * Add caching. * Add to session. * Use focused graphs. * Add workspace mocker. * Delete old graph builder. * Polish. * Fix tests. * Fix tests. * Add Tests and re-work based on discussions * Add documentation * Resolve conflict * Save my work * next iteration * Latest version * Run linter * run pip with install args * Add Tests and re-work based on discussions * Add documentation * new: Add new workspace builder. (#1697) * Add workspace crate. * Add projects loading. * Add build. * Clean up build data. * Flesh out build. * Add caching. * Add to session. * Use focused graphs. * Add workspace mocker. * Delete old graph builder. * Polish. * Fix tests. * Fix tests. * Add last commit * Rebase completed * Revert new language * Final commit after format, lint and build * Resolve Issues based on suggestions - remove yarn version modification - remove version configuration for pip, if user want's to update the pip dependency he can do this via the requirements.txt or installArgs method - add root_requirements_only, to be able to create venv in project scope or in workspace scope - pip_requirements fixed the occupied/vaccant - clean up Cargo.toml - reworked and rethinked the install_deps and setup_tool function; install_deps phase is absolute sufficient - remove not needed comments - remove all references to get_workspace_root - Cleaned up CHANGELOG.md * Execute lint and format * Fix testing for python areas * Fix project_config_test * Resolve latest comments * Update changelog.md --------- Co-authored-by: Miles Johnson <[email protected]> Co-authored-by: Miles Johnson <[email protected]>
- Loading branch information
1 parent
d7223f8
commit 2cfc800
Showing
43 changed files
with
1,346 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use moon_config::{PartialPipConfig, PartialPythonConfig}; | ||
use moon_test_utils::{ | ||
assert_snapshot, create_sandbox_with_config, get_python_fixture_configs, Sandbox, | ||
}; | ||
use proto_core::UnresolvedVersionSpec; | ||
|
||
fn python_sandbox(config: PartialPythonConfig) -> Sandbox { | ||
python_sandbox_with_config(|_| {}, config) | ||
} | ||
|
||
fn python_sandbox_with_config<C>(callback: C, config: PartialPythonConfig) -> Sandbox | ||
where | ||
C: FnOnce(&mut PartialPythonConfig), | ||
{ | ||
let (workspace_config, mut toolchain_config, tasks_config) = get_python_fixture_configs(); | ||
|
||
toolchain_config.python = Some(config); | ||
|
||
if let Some(python_config) = &mut toolchain_config.python { | ||
callback(python_config); | ||
} | ||
|
||
let sandbox = create_sandbox_with_config( | ||
"python", | ||
Some(workspace_config), | ||
Some(toolchain_config), | ||
Some(tasks_config), | ||
); | ||
|
||
sandbox.enable_git(); | ||
sandbox | ||
} | ||
|
||
#[test] | ||
fn runs_standard_script() { | ||
let sandbox = python_sandbox(PartialPythonConfig { | ||
version: Some(UnresolvedVersionSpec::parse("3.11.10").unwrap()), | ||
..PartialPythonConfig::default() | ||
}); | ||
let assert = sandbox.run_moon(|cmd| { | ||
cmd.arg("run").arg("python:standard"); | ||
}); | ||
|
||
assert_snapshot!(assert.output()); | ||
} | ||
|
||
#[test] | ||
fn runs_install_deps_via_args() { | ||
let sandbox = python_sandbox(PartialPythonConfig { | ||
version: Some(UnresolvedVersionSpec::parse("3.11.10").unwrap()), | ||
pip: Some(PartialPipConfig { | ||
install_args: Some(vec![ | ||
"--quiet".to_string(), | ||
"--disable-pip-version-check".to_string(), | ||
"poetry==1.8.4".to_string(), | ||
]), | ||
}), | ||
..PartialPythonConfig::default() | ||
}); | ||
let assert = sandbox.run_moon(|cmd| { | ||
cmd.arg("run").arg("python:poetry"); | ||
}); | ||
|
||
assert_snapshot!(assert.output()); | ||
} |
14 changes: 14 additions & 0 deletions
14
crates/cli/tests/snapshots/run_python_test__runs_install_deps_via_args.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
source: crates/cli/tests/run_python_test.rs | ||
assertion_line: 60 | ||
expression: assert.output() | ||
snapshot_kind: text | ||
--- | ||
▪▪▪▪ activate virtual environment | ||
▪▪▪▪ pip install | ||
▪▪▪▪ python:poetry | ||
Poetry (version 1.8.4) | ||
▪▪▪▪ python:poetry (100ms) | ||
|
||
Tasks: 1 completed | ||
Time: 100ms |
11 changes: 11 additions & 0 deletions
11
crates/cli/tests/snapshots/run_python_test__runs_standard_script.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
source: crates/cli/tests/run_python_test.rs | ||
assertion_line: 38 | ||
expression: assert.output() | ||
--- | ||
▪▪▪▪ python:standard | ||
Python 3.11.10 | ||
▪▪▪▪ python:standard (100ms) | ||
|
||
Tasks: 1 completed | ||
Time: 100ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// use super::bin_config::BinEntry; | ||
use schematic::Config; | ||
use serde::Serialize; | ||
use version_spec::UnresolvedVersionSpec; | ||
use warpgate_api::PluginLocator; | ||
|
||
#[derive(Clone, Config, Debug, PartialEq, Serialize)] | ||
pub struct PipConfig { | ||
/// List of arguments to append to `pip install` commands. | ||
pub install_args: Option<Vec<String>>, | ||
} | ||
|
||
#[derive(Clone, Config, Debug, PartialEq)] | ||
pub struct PythonConfig { | ||
/// Location of the WASM plugin to use for Python support. | ||
pub plugin: Option<PluginLocator>, | ||
|
||
/// Options for pip, when used as a package manager. | ||
#[setting(nested)] | ||
pub pip: Option<PipConfig>, | ||
|
||
/// Defines the virtual environment name which will be created on workspace root. | ||
/// Project dependencies will be installed into this. Defaults to `.venv` | ||
#[setting(default = ".venv")] | ||
pub venv_name: String, | ||
|
||
/// 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, | ||
|
||
/// The version of Python to download, install, and run `python` tasks with. | ||
#[setting(env = "MOON_PYTHON_VERSION")] | ||
pub version: Option<UnresolvedVersionSpec>, | ||
} |
Oops, something went wrong.