Skip to content

Commit

Permalink
Merge branch 'main' into feat/check_duplicate_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 31, 2024
2 parents a1df903 + 479c06d commit 870c990
Show file tree
Hide file tree
Showing 53 changed files with 9,890 additions and 4,236 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ slow_integration_tests = []
assert_matches = "1.5.0"
async-once-cell = "0.5.3"
async-recursion = "1.0.5"
async-scoped = { version = "0.8.0", features = ["use-tokio"] }
chrono = "0.4.32"
clap = { version = "4.4.18", default-features = false, features = ["derive", "usage", "wrap_help", "std", "color", "error-context"] }
clap-verbosity-flag = "2.1.2"
Expand Down
27 changes: 26 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ moo = { depends_on = ["cow"] }
This command starts a new shell in the project's environment.
To exit the pixi shell, simply run `exit`.

#####Options
##### Options

- `--manifest-path`: the path to `pixi.toml`, by default it searches for one in the parent directories.
- `--frozen`: install the environment as defined in the lockfile. Without checking the status of the lockfile.
Expand All @@ -245,6 +245,31 @@ pixi shell --locked
exit
```

## `shell-hook`

This command prints the activation script of an environment.

##### Options
- `--shell`: The shell for which the activation script should be printed. Defaults to the current shell.
Currently supported variants: [`Bash`, `Zsh`, `Xonsh`, `CmdExe`, `PowerShell`, `Fish`, `NuShell`]
- `--manifest-path`: the path to `pixi.toml`, by default it searches for one in the parent directories.
- `--frozen`: install the environment as defined in the lockfile. Without checking the status of the lockfile.
- `--locked`: only install if the `pixi.lock` is up-to-date with the `pixi.toml`[^1]. Conflicts with `--frozen`.

```shell
pixi shell-hook
pixi shell-hook --shell bash
pixi shell-hook --shell zsh
pixi shell-hook --manifest-path ~/myproject/pixi.toml
pixi shell-hook --frozen
pixi shell-hook --locked
```
Example use-case, when you want to get rid of the `pixi` executable in a Docker container.
```shell
pixi shell-hook --shell bash > /etc/profile.d/pixi.sh
rm ~/.pixi/bin/pixi # Now the environment will be activated without the need for the pixi executable.
```

## `search`

Search a package, output will list the latest version of the package.
Expand Down
4,965 changes: 2,123 additions & 2,842 deletions examples/cpp-sdl/pixi.lock

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions examples/cpp-sdl/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ channels = ["conda-forge"]
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]

[tasks]
# Start the built executable
start = { cmd = ".build/bin/sdl_example", depends_on = ["build"] }

[dependencies]
sdl2 = "2.26.5.*"

[feature.build.dependencies]
cmake = "3.26.4.*"
cxx-compiler = "1.5.2.*"
ninja = "1.11.1.*"

[feature.build.tasks]
# Configures CMake
configure = { cmd = [
"cmake",
Expand All @@ -24,11 +36,5 @@ configure = { cmd = [
# Build the executable but make sure CMake is configured first.
build = { cmd = ["ninja", "-C", ".build"], depends_on = ["configure"] }

# Start the built executable
start = { cmd = ".build/bin/sdl_example", depends_on = ["build"] }

[dependencies]
cmake = "3.26.4.*"
cxx-compiler = "1.5.2.*"
sdl2 = "2.26.5.*"
ninja = "1.11.1.*"
[environments]
build = ["build"]
2 changes: 2 additions & 0 deletions examples/polarify/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML
2 changes: 2 additions & 0 deletions examples/polarify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pixi environments
.pixi
5,182 changes: 5,182 additions & 0 deletions examples/polarify/pixi.lock

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions examples/polarify/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[project]
name = "polarify-use-case"
channels = ["conda-forge"]
platforms = ["linux-64", "osx-arm64", "osx-64", "win-64"]

[tasks]
postinstall = "pip install --no-build-isolation --no-deps --disable-pip-version-check -e ."
start = 'python -c "import sys; print(f\"Python version: {sys.version}\"); import polars; print(f\"Polars version: {polars.__version__}\")"'

[dependencies]
python = ">=3.9"
pip = "*"
polars = ">=0.14.24,<0.21"

[feature.py39.dependencies]
python = "3.9.*"
[feature.py310.dependencies]
python = "3.10.*"
[feature.py311.dependencies]
python = "3.11.*"
[feature.py312.dependencies]
python = "3.12.*"
[feature.pl017.dependencies]
polars = "0.17.*"
[feature.pl018.dependencies]
polars = "0.18.*"
[feature.pl019.dependencies]
polars = "0.19.*"
[feature.pl020.dependencies]
polars = "0.20.*"

[feature.test.dependencies]
pytest = "*"
pytest-md = "*"
pytest-emoji = "*"
hypothesis = "*"
[feature.test.tasks]
test = "pytest -s"

[feature.lint.dependencies]
pre-commit = "*"
[feature.lint.tasks]
lint = "pre-commit run --all"

[environments]
pl017 = ["pl017", "py310", "test"]
pl018 = ["pl018", "py39", "test"]
pl019 = ["pl019", "py39", "test"]
pl020 = ["pl020", "py312", "test"]
py39 = ["py39", "test"]
py310 = ["py310", "test"]
py311 = ["py311", "test"]
py312 = ["py312", "test"]

## test this with:
#pixi run -e pl017 test
#pixi run -e pl018 test
#pixi run -e pl019 test
#pixi run -e pl020 test
#pixi run -e py39 start
#pixi run -e py310 start
#pixi run -e py311 start
#pixi run -e py312 start
7 changes: 7 additions & 0 deletions examples/polarify/tests/test_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import polars
import sys

def test_versions():
print("") # empty line
print(f"Polars version: {polars.__version__}")
print(f"Python version: {sys.version}")
2 changes: 1 addition & 1 deletion install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ update_shell() {
LINE=$2

# shell update can be suppressed by `PIXI_NO_PATH_UPDATE` env var
[[ ! -z "$PIXI_NO_PATH_UPDATE" ]] && return
[[ -z "${PIXI_NO_PATH_UPDATE-}" ]] && return

# Create the file if it doesn't exist
if [ -f "$FILE" ]; then
Expand Down
21 changes: 9 additions & 12 deletions src/activation.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use indexmap::IndexMap;
use std::collections::HashMap;

use itertools::Itertools;
Expand Down Expand Up @@ -117,7 +118,9 @@ pub fn get_activator<'p>(
}

/// Runs and caches the activation script.
async fn run_activation(environment: &Environment<'_>) -> miette::Result<HashMap<String, String>> {
pub async fn run_activation(
environment: &Environment<'_>,
) -> miette::Result<HashMap<String, String>> {
let activator = get_activator(environment, ShellEnum::default()).map_err(|e| {
miette::miette!(format!(
"failed to create activator for {:?}\n{}",
Expand Down Expand Up @@ -179,19 +182,13 @@ pub async fn get_activation_env<'p>(
lock_file_usage: LockFileUsage,
) -> miette::Result<HashMap<String, String>> {
// Get the prefix which we can then activate.
get_up_to_date_prefix(
environment,
lock_file_usage,
false,
None,
Default::default(),
)
.await?;
get_up_to_date_prefix(environment, lock_file_usage, false, IndexMap::default()).await?;

// Get environment variables from the activation
let activation_env = await_in_progress("activating environment", run_activation(environment))
.await
.wrap_err("failed to activate environment")?;
let activation_env =
await_in_progress("activating environment", |_| run_activation(environment))
.await
.wrap_err("failed to activate environment")?;

let environment_variables = get_environment_variables(environment);

Expand Down
15 changes: 2 additions & 13 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use rattler_conda_types::{
};
use rattler_repodata_gateway::sparse::SparseRepoData;
use rattler_solve::{resolvo, SolverImpl};
use rip::resolve::SDistResolution;
use std::{
collections::{HashMap, HashSet},
path::PathBuf,
Expand Down Expand Up @@ -86,10 +85,6 @@ pub struct Args {
/// The platform(s) for which the dependency should be added
#[arg(long, short)]
pub platform: Vec<Platform>,

/// Resolution scheme to use
#[arg(skip)]
pub sdist_resolution: SDistResolution,
}

impl DependencyType {
Expand Down Expand Up @@ -144,7 +139,6 @@ pub async fn execute(args: Args) -> miette::Result<()> {
args.no_install,
args.no_lockfile_update,
spec_platforms,
args.sdist_resolution,
)
.await
}
Expand Down Expand Up @@ -174,7 +168,6 @@ pub async fn execute(args: Args) -> miette::Result<()> {
spec_platforms,
args.no_lockfile_update,
args.no_install,
args.sdist_resolution,
)
.await
}
Expand Down Expand Up @@ -216,7 +209,6 @@ pub async fn add_pypi_specs_to_project(
specs_platforms: &Vec<Platform>,
no_update_lockfile: bool,
no_install: bool,
sdist_resolution: SDistResolution,
) -> miette::Result<()> {
for (name, spec) in &specs {
// TODO: Get best version
Expand All @@ -241,8 +233,7 @@ pub async fn add_pypi_specs_to_project(
&project.default_environment(),
lock_file_usage,
no_install,
None,
sdist_resolution,
IndexMap::default(),
)
.await?;

Expand All @@ -258,7 +249,6 @@ pub async fn add_conda_specs_to_project(
no_install: bool,
no_update_lockfile: bool,
specs_platforms: &Vec<Platform>,
sdist_resolution: SDistResolution,
) -> miette::Result<()> {
// Split the specs into package name and version specifier
let new_specs = specs
Expand Down Expand Up @@ -341,8 +331,7 @@ pub async fn add_conda_specs_to_project(
&project.default_environment(),
lock_file_usage,
no_install,
Some(sparse_repo_data),
sdist_resolution,
sparse_repo_data,
)
.await?;
project.save()?;
Expand Down
15 changes: 9 additions & 6 deletions src/cli/global/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use indexmap::IndexMap;
use itertools::Itertools;
use miette::IntoDiagnostic;
use rattler::install::Transaction;
use rattler::package_cache::PackageCache;
use rattler_conda_types::{Channel, ChannelConfig, MatchSpec, PackageName, Platform, PrefixRecord};
use rattler_networking::AuthenticationMiddleware;
use rattler_repodata_gateway::sparse::SparseRepoData;
Expand Down Expand Up @@ -433,7 +434,7 @@ pub(super) async fn globally_install_package(

// Create the binary environment prefix where we install or update the package
let BinEnvDir(bin_prefix) = BinEnvDir::create(&package_name).await?;
let prefix = Prefix::new(bin_prefix)?;
let prefix = Prefix::new(bin_prefix);
let prefix_records = prefix.find_installed_packages(None).await?;

// Create the transaction that we need
Expand All @@ -448,17 +449,19 @@ pub(super) async fn globally_install_package(

// Execute the transaction if there is work to do
if has_transactions {
let package_cache = Arc::new(PackageCache::new(config::get_cache_dir()?.join("pkgs")));

// Execute the operations that are returned by the solver.
await_in_progress(
"creating virtual environment",
await_in_progress("creating virtual environment", |pb| {
execute_transaction(
package_cache,
&transaction,
&prefix_records,
prefix.root().to_path_buf(),
config::get_cache_dir()?,
authenticated_client,
),
)
pb,
)
})
.await?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/global/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub async fn execute(_args: Args) -> miette::Result<()> {
print_no_packages_found_message();
return Ok(());
};
let prefix = Prefix::new(bin_env_prefix)?;
let prefix = Prefix::new(bin_env_prefix);

let Ok(bin_prefix) = BinDir::from_existing().await else {
print_no_packages_found_message();
Expand Down
2 changes: 1 addition & 1 deletion src/cli/global/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
)
})?;
let BinEnvDir(bin_prefix) = BinEnvDir::from_existing(&package_name).await?;
let prefix = Prefix::new(bin_prefix.clone())?;
let prefix = Prefix::new(bin_prefix.clone());

// Find the installed package in the environment
let prefix_package = find_designated_package(&prefix, &package_name).await?;
Expand Down
Loading

0 comments on commit 870c990

Please sign in to comment.