-
Notifications
You must be signed in to change notification settings - Fork 26
Add Pixi locator #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Pixi locator #172
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
82c89df
Add Pixi locator
renan-r-santos e2fae3f
Add Pixi test
renan-r-santos 947d4cb
Fix "Install Pixi" CI step
renan-r-santos cfeda18
Fix Homebrew CI broken after 4.6.6 release
renan-r-santos 0fbfc9d
Add comment about Homebrew workaround
renan-r-santos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -10,7 +10,10 @@ RUN curl https://raw.githubusercontent.com/DonJayamanne/vscode-jupyter/container | |
RUN echo "# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh." >> ~/.zshrc | ||
RUN echo "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh" >> ~/.zshrc | ||
|
||
# Install Pythone | ||
# Install Python | ||
# homebrew/brew:4.4.6 broke running `brew install` as root. | ||
# As a workaround, running `brew update` and ignoring errors coming from it fixes `brew install`. | ||
RUN brew update || true | ||
RUN brew install [email protected] [email protected] | ||
|
||
# Install Rust | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -167,6 +167,23 @@ jobs: | |
|
||
# endregion venv | ||
|
||
# region Pixi | ||
- name: Install Pixi | ||
uses: prefix-dev/[email protected] | ||
with: | ||
run-install: false | ||
|
||
- name: Create Pixi environments | ||
run: | | ||
pixi init | ||
pixi add python | ||
pixi add --feature dev python | ||
pixi project environment add --feature dev dev | ||
pixi install --environment dev | ||
shell: bash | ||
|
||
# endregion Pixi | ||
|
||
# Rust | ||
- name: Rust Tool Chain setup | ||
uses: dtolnay/rust-toolchain@stable | ||
|
@@ -395,7 +412,11 @@ jobs: | |
# Homebrew | ||
- name: Homebrew Python | ||
if: startsWith( matrix.image, 'homebrew') | ||
run: brew install [email protected] [email protected] | ||
run: | | ||
# homebrew/brew:4.4.6 broke running `brew install` as root. | ||
# As a workaround, running `brew update` and ignoring errors coming from it fixes `brew install`. | ||
brew update || true | ||
brew install [email protected] [email protected] | ||
shell: bash | ||
|
||
# Rust | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -47,6 +47,7 @@ pub enum LocatorKind { | |
MacPythonOrg, | ||
MacXCode, | ||
PipEnv, | ||
Pixi, | ||
Poetry, | ||
PyEnv, | ||
Venv, | ||
|
This file contains hidden or 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 hidden or 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,13 @@ | ||
[package] | ||
name = "pet-pixi" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[target.'cfg(target_os = "windows")'.dependencies] | ||
msvc_spectre_libs = { version = "0.1.1", features = ["error"] } | ||
|
||
[dependencies] | ||
pet-conda = { path = "../pet-conda" } | ||
pet-core = { path = "../pet-core" } | ||
pet-python-utils = { path = "../pet-python-utils" } | ||
log = "0.4.21" |
This file contains hidden or 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 @@ | ||
# Pixi | ||
|
||
## Notes | ||
|
||
- Pixi environments are detected by: | ||
- Searching for Python interpreters in `.pixi/envs` subdirectories within workspace folders | ||
- Checking for a `conda-meta/pixi` file in potential Pixi environment directories (`.pixi/envs/{env_name}`) | ||
- Determining the version of the Python interpreter from the `conda-meta/python-{version}.json` file | ||
|
||
This process ensures fast detection without spawning processes. | ||
Note that the Pixi locator should run before Conda since Conda could incorrectly identify Pixi environments as Conda environments. |
This file contains hidden or 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,87 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
use std::path::{Path, PathBuf}; | ||
|
||
use pet_conda::package::{CondaPackageInfo, Package}; | ||
use pet_core::{ | ||
env::PythonEnv, | ||
python_environment::{PythonEnvironment, PythonEnvironmentBuilder, PythonEnvironmentKind}, | ||
reporter::Reporter, | ||
Locator, LocatorKind, | ||
}; | ||
use pet_python_utils::executable::find_executables; | ||
|
||
pub fn is_pixi_env(path: &Path) -> bool { | ||
path.join("conda-meta").join("pixi").is_file() | ||
} | ||
|
||
fn get_pixi_prefix(env: &PythonEnv) -> Option<PathBuf> { | ||
env.prefix.clone().or_else(|| { | ||
env.executable.parent().and_then(|parent_dir| { | ||
if is_pixi_env(parent_dir) { | ||
Some(parent_dir.to_path_buf()) | ||
} else if parent_dir.ends_with("bin") || parent_dir.ends_with("Scripts") { | ||
parent_dir | ||
.parent() | ||
.filter(|parent| is_pixi_env(parent)) | ||
.map(|parent| parent.to_path_buf()) | ||
} else { | ||
None | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
pub struct Pixi {} | ||
|
||
impl Pixi { | ||
pub fn new() -> Pixi { | ||
Pixi {} | ||
} | ||
} | ||
impl Default for Pixi { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl Locator for Pixi { | ||
fn get_kind(&self) -> LocatorKind { | ||
LocatorKind::Pixi | ||
} | ||
fn supported_categories(&self) -> Vec<PythonEnvironmentKind> { | ||
vec![PythonEnvironmentKind::Pixi] | ||
} | ||
|
||
fn try_from(&self, env: &PythonEnv) -> Option<PythonEnvironment> { | ||
get_pixi_prefix(env).and_then(|prefix| { | ||
if !is_pixi_env(&prefix) { | ||
return None; | ||
} | ||
|
||
let name = prefix | ||
.file_name() | ||
.and_then(|name| name.to_str()) | ||
.unwrap_or_default() | ||
.to_string(); | ||
|
||
let symlinks = find_executables(&prefix); | ||
|
||
let version = CondaPackageInfo::from(&prefix, &Package::Python) | ||
.map(|package_info| package_info.version); | ||
|
||
Some( | ||
PythonEnvironmentBuilder::new(Some(PythonEnvironmentKind::Pixi)) | ||
.executable(Some(env.executable.clone())) | ||
.name(Some(name)) | ||
.prefix(Some(prefix)) | ||
.symlinks(Some(symlinks)) | ||
.version(version) | ||
.build(), | ||
) | ||
}) | ||
} | ||
|
||
fn find(&self, _reporter: &dyn Reporter) {} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome,