Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ rustflags = [

[target.'wasm32-unknown-unknown']
# See https://docs.rs/getrandom/latest/getrandom/#webassembly-support
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']
4 changes: 4 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches: [ "main" ]
pull_request:
types:
- labeled
- synchronize
- opened

jobs:
pre-commit:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/rust-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1.13.0
- run: |
RUSTDOCFLAGS="-Dwarnings -Wunreachable-pub" cargo doc --no-deps --all --all-features
- name: Set up pixi
uses: prefix-dev/setup-pixi@14c8aabd75893f83f4ab30c03e7cf853c8208961 # v0.8.10
- run: pixi r doc

format_and_lint:
name: Format and Lint
Expand All @@ -43,15 +43,15 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: recursive
- name: Set up pixi
uses: prefix-dev/setup-pixi@14c8aabd75893f83f4ab30c03e7cf853c8208961 # v0.8.10
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Install Rust toolchain
run: rustup component add clippy rustfmt
- name: Run rustfmt
run: cargo fmt --all --check
run: pixi run fmt --check
- name: Run clippy
run: cargo clippy --all-targets
run: pixi run lint

build:
name: ${{ matrix.name }}
Expand Down
20 changes: 15 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
exclude: (^.pixi/|.snap)
# Reason of exclusion:
# js-rattler/src/PackageName.test.ts: complains about valid test names in strings
# py-rattler/mkdocs.yml: complain about invalid constructor for the tag, although it is valid in mkdocs.yaml
exclude: (^.pixi/|.snap|js-rattler/src/PackageName.test.ts|py-rattler/mkdocs.yml)
repos:
- repo: local
hooks:
Expand All @@ -9,43 +12,48 @@ repos:
always_run: true
require_serial: true
pass_filenames: false
stages: [pre-commit, manual]
# pre-commit-hooks
- id: check-yaml
name: check-yaml
entry: pixi run -e lint check-yaml
language: system
types: [yaml]
stages: [pre-commit, manual]
- id: end-of-file
name: end-of-file
entry: pixi run -e lint end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, manual]
- id: trailing-whitespace
name: trailing-whitespace
entry: pixi run -e lint trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, manual]
# Use ruff for python examples
- id: ruff
name: ruff
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
stages: [pre-commit, manual]
- id: ruff-format
name: ruff-format
entry: pixi run -e lint ruff format --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
stages: [pre-commit, manual]
# typos
- id: typos
name: typos
entry: pixi run -e lint typos --write-changes --force-exclude
language: system
types: [text]
stages: [pre-commit, manual]
# Copied from Mozilla https://github.com/mozilla/grcov/blob/master/.pre-commit-config.yaml
- repo: https://github.com/DevinR528/cargo-sort
rev: v1.0.9
Expand All @@ -57,18 +65,20 @@ repos:
name: fmt
language: system
types: [file, rust]
entry: cargo fmt
entry: pixi run fmt
pass_filenames: false
stages: [pre-commit, manual]
- id: clippy
name: clippy
language: system
types: [file, rust]
entry: cargo clippy --all-targets -- -D warnings -Dclippy::dbg_macro # Use -D warnings option to ensure the job fails when encountering warnings
pass_filenames: false
stages: [pre-commit, manual]
- id: test
name: test
language: system
stages: [push]
stages: [pre-push]
types: [file, rust]
entry: cargo test
pass_filenames: false
26 changes: 13 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ This release contains some big changes to rattler:
#### Consistent clobbering

Rattler installs packages in parallel but this was at the cost of not being able to resolve files properly that existed in multiple packages.
With this release we fixed this issue by creating a consistent clobbering experience.
With this release we fixed this issue by creating a consistent clobbering experience.
When a file is clobbered (installed by multiple packages) the last package in the topological ordering wins.
This information is also recorded in the prefix itself which means that even if packages are added or removed from the environment the order remains consistent.

#### reqwest-middleware-client

The `AuthenticatedClient` has been rewritten by @vlad-ivanov-name.
The `AuthenticatedClient` has been rewritten by @vlad-ivanov-name.
Instead of having a custom client for network requests we now use the [`reqwest-middleware`](https://crates.io/crates/reqwest-middleware) crate.
The rattler implementation adds a middleware that handles authentication.
This changes makes it easier to integrate with other crates that use `reqwest` for network requests, and it allows users to add their own middleware.
Expand All @@ -51,7 +51,7 @@ This changes makes it easier to integrate with other crates that use `reqwest` f
The lock-file format has been updated to version 4.
Originally our implementation was semi-compatible with [conda-lock](https://github.com/conda/conda-lock).
We wanted to stay as close as possible to this format because it was already an established standard.
However, with version 2 and 3 of the format we started to diverge more and more.
However, with version 2 and 3 of the format we started to diverge more and more.
We felt like the goals between both formats also started to diverge more and more so with version 4 we decided to completely abandon the conda-lock format and create our own.
For more information about the lock-file format and the differences between conda-lock you can [read the documentation](https://docs.rs/rattler_lock/0.17.0/rattler_lock).
Note that all old formats (including the original conda-lock format) can still be parsed by rattler.
Expand Down Expand Up @@ -90,7 +90,7 @@ Note that all old formats (including the original conda-lock format) can still b

# [0.16.2] - 2024-01-11

### 📃 Details
### 📃 Details

#### Fixed

Expand Down Expand Up @@ -208,7 +208,7 @@ Note that all old formats (including the original conda-lock format) can still b

### ✨ Highlights

Adds support for strict priority channel ordering, channel-specific selectors,
Adds support for strict priority channel ordering, channel-specific selectors,

### 📃 Details

Expand Down Expand Up @@ -259,7 +259,7 @@ Lock file support has been moved into its own crate (rattler_lock) and support f
### ✨ Highlights

The solver has been renamed and moved to its own repository: [resolvo](https://github.com/mamba-org/resolvo).
With the latest changes to the python bindings you can now download repodata and solve environments!
With the latest changes to the python bindings you can now download repodata and solve environments!
Still no official release of the bindings though, but getting closer every day.

### 📃 Details
Expand Down Expand Up @@ -293,7 +293,7 @@ Still no official release of the bindings though, but getting closer every day.

### ✨ Highlights

This is a pretty substantial release which includes many refactors to the solver (which we will pull out of this repository at some point), initial work on Python bindings, and many many fixes.
This is a pretty substantial release which includes many refactors to the solver (which we will pull out of this repository at some point), initial work on Python bindings, and many many fixes.

### 📃 Details

Expand Down Expand Up @@ -326,14 +326,14 @@ This is a pretty substantial release which includes many refactors to the solver
* update all dependencies and fix chrono deprecation by @wolfv in [#302](https://github.com/conda/rattler/pull/302)
* shell improvements for powershell env-var escaping and xonsh detection by @wolfv in [#307](https://github.com/conda/rattler/pull/307)
* also export strict version by @wolfv in [#312](https://github.com/conda/rattler/pull/312)
* make FetchRepoDataOptions clonable by @Wackyator in [#321](https://github.com/conda/rattler/pull/321)
* make FetchRepoDataOptions cloneable by @Wackyator in [#321](https://github.com/conda/rattler/pull/321)
* bump json-patch 1.1.0 to fix stack overflow by @baszalmstra in [#332](https://github.com/conda/rattler/pull/332)
* emscripten is a unix variant by @wolfv in [#339](https://github.com/conda/rattler/pull/339)
* authentication fallback storage location by @ruben-arts in [#347](https://github.com/conda/rattler/pull/347)

### 🐍 Python

Although this release doesn't include a formal release of the python bindings yet, a lot of work has been done to work towards a first version.
Although this release doesn't include a formal release of the python bindings yet, a lot of work has been done to work towards a first version.

* initial version of rattler python bindings by @baszalmstra in [#279](https://github.com/conda/rattler/pull/279)
* bind `Version`, `MatchSpec`, `NamelessMatchSpec` by @Wackyator in [#292](https://github.com/conda/rattler/pull/292)
Expand Down Expand Up @@ -407,7 +407,7 @@ This release mostly contains bug fixes.

#### New rust based solver implementation

This version of rattler includes a new solver implementation!
This version of rattler includes a new solver implementation!
@aochagavia worked hard on porting libsolv to rust and integrating that with `rattler_solve`.
The port performs slightly faster or similar to the original C code and does not contain unsafe code, is well documented, and thread-safe.
Our implementation (`rattler_libsolv_rs`) is specific to solving conda packages by leveraging `rattler_conda_types` for matching and parsing.
Expand Down Expand Up @@ -452,7 +452,7 @@ Caching the result of an activation script can be useful if you need to invoke m

- Run activation scripts and capture their output by @baszalmstra in ([#239](https://github.com/conda/rattler/pull/239))
- Support for sha256 and md5 field in matchspec by @0xbe7a in ([#241](https://github.com/conda/rattler/pull/241))
- A rust port of libsolv as an additional solver backend by @aochagavia, @baszalmstra in ([#243](https://github.com/conda/rattler/pull/243) & [#253](https://github.com/conda/rattler/pull/253))
- A rust port of libsolv as an additional solver backend by @aochagavia, @baszalmstra in ([#243](https://github.com/conda/rattler/pull/243) & [#253](https://github.com/conda/rattler/pull/253))
- Test cases and benchmarks for solver implementations by @baszalmstra in ([#250](https://github.com/conda/rattler/pull/249) & [#250](https://github.com/conda/rattler/pull/249))
- The ability to add a dependency from `python` on `pip` while loading repodata @wolfv in ([#238](https://github.com/conda/rattler/pull/238))

Expand Down Expand Up @@ -549,8 +549,8 @@ A new crate has been added to facilitate authentication when downloading repodat
#### Added

- Support for detecting more platforms ([#135](https://github.com/conda/rattler/pull/135))
- `RepoData` is now clonable ([#138](https://github.com/conda/rattler/pull/138))
- `RunExportsJson` is now clonable ([#169](https://github.com/conda/rattler/pull/169))
- `RepoData` is now cloneable ([#138](https://github.com/conda/rattler/pull/138))
- `RunExportsJson` is now cloneable ([#169](https://github.com/conda/rattler/pull/169))
- `file://` urls are now supported for package extraction functions ([#157](https://github.com/conda/rattler/pull/157))
- `file://` urls are now supported for repodata fetching ([#158](https://github.com/conda/rattler/pull/158))
- Getting started with rattler using micromamba ([#163](https://github.com/conda/rattler/pull/163))
Expand Down
7 changes: 2 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ For a good list of things you could help us with, take a look at our [*good firs
If you want to go deeper though, any [open issue](https://github.com/conda/rattler/issues) is up for grabs.
Just let us know what you start on something.

For questions, requests or a casual chat, we are very active on our discord server.
For questions, requests or a casual chat, we are very active on our discord server.
You can [join our discord server via this link][chat-url].

## Development
Expand All @@ -20,14 +20,11 @@ You can use [pixi](https://github.com/prefix-dev/pixi) for setting up the enviro
```

### Virtual env with conda/mamba
The environment can also be managed with conda using the spec in `environments.yml` in the project root.
The environment can also be managed with conda using the spec in `environments.yml` in the project root.
As below,
```sh
❱ git submodule update --init
❱ mamba create -n name_of_your_rattler_env --file='environments.yml' && mamba activate name_of_your_rattler_env
❱ cargo build # uses cargo from your mamba venv
❱ mamba deactivate # don't forget you're in the venv
```



18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Rattler is a library that provides common functionality used within the conda ec
The goal of the library is to enable programs and other libraries to easily interact with the conda ecosystem without being dependent on Python.
Its primary use case is as a library that you can use to provide conda related workflows in your own tools.

Rattler is written in Rust and tries to provide a clean API to its functionalities (see: [Components](#components)).
Rattler is written in Rust and tries to provide a clean API to its functionalities (see: [Components](#components)).
With the primary goal in mind we aim to provide bindings to different languages to make it easy to integrate Rattler in non-rust projects.

Rattler is actively used by [pixi](https://github.com/prefix-dev/pixi), [rattler-build](https://github.com/prefix-dev/rattler-build), and the https://prefix.dev backend.
Expand All @@ -54,7 +54,7 @@ To install the Python bindings, you can use pip or conda:

```bash
pip install py-rattler
# or
# or
conda install -c conda-forge py-rattler
```

Expand Down Expand Up @@ -142,24 +142,24 @@ Run the following command to start jupyterlab:
./.prefix/bin/jupyter-lab
```

Voila!
You have a working installation of jupyterlab installed on your system!
You can of course install any package you want this way.
Voila!
You have a working installation of jupyterlab installed on your system!
You can of course install any package you want this way.
Try it!

## Contributing 😍

We would love to have you contribute!
See the CONTRIBUTION.md for more info. For questions, requests or a casual chat, we are very active on our discord server.
We would love to have you contribute!
See the CONTRIBUTION.md for more info. For questions, requests or a casual chat, we are very active on our discord server.
You can [join our discord server via this link][chat-url].


## Components

Rattler consists of several crates that provide different functionalities.
Rattler consists of several crates that provide different functionalities.

* **rattler_conda_types**: foundational types for all datastructures used within the conda eco-system.
* **rattler_package_streaming**: provides functionality to download, extract and create conda package archives.
* **rattler_package_streaming**: provides functionality to download, extract and create conda package archives.
* **rattler_repodata_gateway**: downloads, reads and processes information about existing conda packages from an index.
* **rattler_shell**: code to activate an existing environment and run programs in it.
* **rattler_solve**: a backend agnostic library to solve the package satisfiability problem.
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler-bin/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub async fn create(opt: Opt) -> anyhow::Result<()> {
.await
.context("failed to load repodata")?;

// Determine the number of recors
// Determine the number of records
let total_records: usize = repo_data.iter().map(RepoData::len).sum();
println!(
"Loaded {} records in {:?}",
Expand Down
1 change: 0 additions & 1 deletion crates/rattler/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,4 +473,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- every crate should have its own version ([#557](https://github.com/conda/rattler/pull/557))

## [0.19.0](https://github.com/baszalmstra/rattler/compare/rattler-v0.18.0...rattler-v0.19.0) - 2024-02-26

8 changes: 5 additions & 3 deletions crates/rattler_cache/src/package_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,11 @@ where
} else if !cache_dir_exists {
tracing::debug!("cache directory does not exist, fetching package");
} else if hash_mismatch {
tracing::warn!("hash mismatch, wanted a package with hash {} but the cached package has hash {}, fetching package",
tracing::warn!(
"hash mismatch, wanted a package with hash {} but the cached package has hash {}, fetching package",
given_sha.map_or(String::from("<unknown>"), |s| format!("{s:x}")),
locked_sha256.map_or(String::from("<unknown>"), |s| format!("{s:x}")));
locked_sha256.map_or(String::from("<unknown>"), |s| format!("{s:x}"))
);
}

// If the cache is stale, we need to fetch the package again. We have to acquire
Expand Down Expand Up @@ -850,7 +852,7 @@ mod test {

let file_name = get_file_name_from_path(cache_lock_without_origin_hash.path());
let path_hash = compute_bytes_digest::<Sha256>(package_path.to_string_lossy().as_bytes());
let expected_file_name = format!("clobber-python-0.1.0-cpython-{:x}", path_hash);
let expected_file_name = format!("clobber-python-0.1.0-cpython-{path_hash:x}");
assert_eq!(file_name, expected_file_name);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/rattler_cache/src/run_exports_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ pub enum RunExportsCacheError {
#[error("{0}")]
Persist(#[from] PersistError),

/// An error occured when extracting `run_exports` from archive
/// An error occurred when extracting `run_exports` from archive
#[error(transparent)]
Extract(#[from] ExtractError),

/// An error occured when serializing `run_exports`
/// An error occurred when serializing `run_exports`
#[error(transparent)]
Serialize(#[from] serde_json::Error),

Expand Down
10 changes: 7 additions & 3 deletions crates/rattler_conda_types/src/match_spec/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub enum ParseMatchSpecError {
InvalidVersionAndBuild(String),

/// Invalid build string
#[error("the build string '{0}' is not valid, it can only contain alphanumeric characters and underscores"
#[error(
"the build string '{0}' is not valid, it can only contain alphanumeric characters and underscores"
)]
InvalidBuildString(String),

Expand Down Expand Up @@ -1349,7 +1350,10 @@ mod tests {

let err = MatchSpec::from_str("bla/bla", Strict)
.expect_err("Should try to parse as name not url");
assert_eq!(err.to_string(), "'bla/bla' is not a valid package name. Package names can only contain 0-9, a-z, A-Z, -, _, or .");
assert_eq!(
err.to_string(),
"'bla/bla' is not a valid package name. Package names can only contain 0-9, a-z, A-Z, -, _, or ."
);
}

#[test]
Expand Down Expand Up @@ -1469,7 +1473,7 @@ mod tests {
.unwrap();
let version_spec = match_spec.version.unwrap();
let version = Version::from_str("0.4.1").unwrap();
assert!(version_spec.matches(&version))
assert!(version_spec.matches(&version));
}

#[cfg(feature = "experimental_extras")]
Expand Down
Loading
Loading