Skip to content

Commit

Permalink
Make editable installation of the project itself explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-lacroix committed Mar 31, 2024
1 parent e8e3766 commit 9884c7e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
10 changes: 6 additions & 4 deletions docs/advanced/pyproject_toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]
```
This is the minimum requirement for pixi to understand and parse the project.

If you use `pixi init` in a folder that has a `pyproject.toml` file, pixi will automatically add the `[tool.pixi.project]` section to the file.
And will also add some defaults to the `.gitignore` and `.gitattributes` file.
However, it is recommended you use `pixi init` in a folder that has a `pyproject.toml` file. Pixi will automatically

- Add the above `[tool.pixi.project]` section to the file, auto-detecting your current platform;
- Add the current project as an editable pypi dependency;
- Add some defaults to the `.gitignore` and `.gitattributes` file.

## Python dependency
The `pyproject.toml` file supports the `requires_python` field.
Expand Down Expand Up @@ -144,8 +147,7 @@ test = ["test"]
```

## Build-system section
The `pyproject.toml` file normally contains a `[build-system]` section.
Pixi will use this section to install the project (as an editable install, i.e. equivalent to `pip install -e .`) automatically and add it to the lock file.
The `pyproject.toml` file normally contains a `[build-system]` section. Pixi will use this section to build and install the project if it is added as a path pypi dependency.
```toml title="pyproject.toml"
[build-system]
requires = ["setuptools", "wheel"]
Expand Down
3 changes: 3 additions & 0 deletions src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ name = "{{ name }}"
channels = [{%- if channels %}"{{ channels|join("\", \"") }}"{%- endif %}]
platforms = ["{{ platforms|join("\", \"") }}"]
[tool.pixi.pypi-dependencies]
{{ name }} = { path = ".", editable = true }
"#;

const GITIGNORE_TEMPLATE: &str = r#"# pixi environments
Expand Down
12 changes: 1 addition & 11 deletions src/project/manifest/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl PyProjectManifest {
impl From<PyProjectManifest> for ProjectManifest {
fn from(item: PyProjectManifest) -> Self {
// Start by loading the data nested under "tool.pixi" as manifest,
// and a reference to the pyproject project table
// and create a reference to the 'pyproject.toml' project table
let mut manifest = item.tool.pixi.clone();
let pyproject = item.project.as_ref().expect("project table should exist");

Expand Down Expand Up @@ -69,16 +69,6 @@ impl From<PyProjectManifest> for ProjectManifest {
}
}

// Add the project itself as an editable dependency
target.add_pypi_dependency(
PyPiPackageName::from_str(&pyproject.name).unwrap(),
PyPiRequirement::Path {
path: PathBuf::from("."),
editable: Some(true),
extras: Default::default(),
},
);

// For each extra group, create a feature of the same name if it does not exist,
// add dependencies and create corresponding environments if they do not exist
// TODO: Add solve groups as well?
Expand Down

0 comments on commit 9884c7e

Please sign in to comment.