diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md deleted file mode 100644 index 8f9c6b8f..00000000 --- a/.github/ISSUE_TEMPLATE/BUG_REPORT.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Bug report -about: Report a bug. -title: '' -labels: bug -assignees: '' - ---- - -## Expected Behavior - -NA - -## Actual Behavior - -NA - -## Steps to Reproduce - -NA - -## Version - -REQUIRED - -## System Information - -REQUIRED \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md deleted file mode 100644 index 86ad0ab4..00000000 --- a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Feature request -about: Request a new feature or a change. -title: '' -labels: enhancement -assignees: '' - ---- - -## Description diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5a42f512..dfb1a45c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,7 +35,7 @@ jobs: - uses: actions/setup-python@v1 # We install instead of just build for insta-cmd TODO(cnpryer) - name: Install huak - run: cargo install --path crates/huak-cli + run: cargo install --path crates/huak-cli --locked - name: Test run: cargo test --workspace --all-features diff --git a/.github/workflows/release.yaml b/.github/workflows/pypi-release.yaml similarity index 99% rename from .github/workflows/release.yaml rename to .github/workflows/pypi-release.yaml index 405a04ba..cbb8d524 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -1,4 +1,4 @@ -name: Release +name: PyPI Release on: release: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7d2b8107 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,265 @@ +# Copyright 2022-2023, axodotdev +# SPDX-License-Identifier: MIT or Apache-2.0 +# +# CI that: +# +# * checks for a Git Tag that looks like a release +# * builds artifacts with cargo-dist (archives, installers, hashes) +# * uploads those artifacts to temporary workflow zip +# * on success, uploads the artifacts to a Github Release +# +# Note that the Github Release will be created with a generated +# title/body based on your changelogs. + +name: Release + +permissions: + contents: write + +# This task will run whenever you push a git tag that looks like a version +# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc. +# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where +# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION +# must be a Cargo-style SemVer Version (must have at least major.minor.patch). +# +# If PACKAGE_NAME is specified, then the announcement will be for that +# package (erroring out if it doesn't have the given version or isn't cargo-dist-able). +# +# If PACKAGE_NAME isn't specified, then the announcement will be for all +# (cargo-dist-able) packages in the workspace with that version (this mode is +# intended for workspaces with only one dist-able package, or with all dist-able +# packages versioned/released in lockstep). +# +# If you push multiple tags at once, separate instances of this workflow will +# spin up, creating an independent announcement for each one. However Github +# will hard limit this to 3 tags per commit, as it will assume more tags is a +# mistake. +# +# If there's a prerelease-style suffix to the version, then the release(s) +# will be marked as a prerelease. +on: + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' + pull_request: + +jobs: + # Run 'cargo dist plan' (or host) to determine what tasks we need to do + plan: + runs-on: ubuntu-latest + outputs: + val: ${{ steps.plan.outputs.manifest }} + tag: ${{ !github.event.pull_request && github.ref_name || '' }} + tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }} + publishing: ${{ !github.event.pull_request }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + # we specify bash to get pipefail; it guards against the `curl` command + # failing. otherwise `sh` won't catch that `curl` returned non-0 + shell: bash + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.10.0/cargo-dist-installer.sh | sh" + # sure would be cool if github gave us proper conditionals... + # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible + # functionality based on whether this is a pull_request, and whether it's from a fork. + # (PRs run on the *source* but secrets are usually on the *target* -- that's *good* + # but also really annoying to build CI around when it needs secrets to work right.) + - id: plan + run: | + cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json + echo "cargo dist ran successfully" + cat plan-dist-manifest.json + echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + name: artifacts-plan-dist-manifest + path: plan-dist-manifest.json + + # Build and packages all the platform-specific things + build-local-artifacts: + name: build-local-artifacts (${{ join(matrix.targets, ', ') }}) + # Let the initial task tell us to not run (currently very blunt) + needs: + - plan + if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }} + strategy: + fail-fast: false + # Target platforms/runners are computed by cargo-dist in create-release. + # Each member of the matrix has the following arguments: + # + # - runner: the github runner + # - dist-args: cli flags to pass to cargo dist + # - install-dist: expression to run to install cargo-dist on the runner + # + # Typically there will be: + # - 1 "global" task that builds universal installers + # - N "local" tasks that build each platform's binaries and platform-specific installers + matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }} + runs-on: ${{ matrix.runner }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: swatinem/rust-cache@v2 + - name: Install cargo-dist + run: ${{ matrix.install_dist }} + # Get the dist-manifest + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - name: Install dependencies + run: | + ${{ matrix.packages_install }} + - name: Build artifacts + run: | + # Actually do builds and make zips and whatnot + cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json + echo "cargo dist ran successfully" + - id: cargo-dist + name: Post-build + # We force bash here just because github makes it really hard to get values up + # to "real" actions without writing to env-vars, and writing to env-vars has + # inconsistent syntax between shell and powershell. + shell: bash + run: | + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: artifacts-build-local-${{ join(matrix.targets, '_') }} + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + + # Build and package all the platform-agnostic(ish) things + build-global-artifacts: + needs: + - plan + - build-local-artifacts + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.10.0/cargo-dist-installer.sh | sh" + # Get all the local artifacts for the global tasks to use (for e.g. checksums) + - name: Fetch local artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + - id: cargo-dist + shell: bash + run: | + cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json + echo "cargo dist ran successfully" + + # Parse out what we just built and upload it to scratch storage + echo "paths<> "$GITHUB_OUTPUT" + jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + echo "EOF" >> "$GITHUB_OUTPUT" + + cp dist-manifest.json "$BUILD_MANIFEST_NAME" + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: artifacts-build-global + path: | + ${{ steps.cargo-dist.outputs.paths }} + ${{ env.BUILD_MANIFEST_NAME }} + # Determines if we should publish/announce + host: + needs: + - plan + - build-local-artifacts + - build-global-artifacts + # Only run if we're "publishing", and only if local and global didn't fail (skipped is fine) + if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + runs-on: "ubuntu-20.04" + outputs: + val: ${{ steps.host.outputs.manifest }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo-dist + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.10.0/cargo-dist-installer.sh | sh" + # Fetch artifacts from scratch-storage + - name: Fetch artifacts + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: target/distrib/ + merge-multiple: true + # This is a harmless no-op for Github Releases, hosting for that happens in "announce" + - id: host + shell: bash + run: | + cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json + echo "artifacts uploaded and released successfully" + cat dist-manifest.json + echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT" + - name: "Upload dist-manifest.json" + uses: actions/upload-artifact@v4 + with: + # Overwrite the previous copy + name: artifacts-dist-manifest + path: dist-manifest.json + + # Create a Github Release while uploading all files to it + announce: + needs: + - plan + - host + # use "always() && ..." to allow us to wait for all publish jobs while + # still allowing individual publish jobs to skip themselves (for prereleases). + # "host" however must run to completion, no skipping allowed! + if: ${{ always() && needs.host.result == 'success' }} + runs-on: "ubuntu-20.04" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: "Download Github Artifacts" + uses: actions/download-artifact@v4 + with: + pattern: artifacts-* + path: artifacts + merge-multiple: true + - name: Cleanup + run: | + # Remove the granular manifests + rm -f artifacts/*-dist-manifest.json + - name: Create Github Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ needs.plan.outputs.tag }} + name: ${{ fromJson(needs.host.outputs.val).announcement_title }} + body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }} + prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }} + artifacts: "artifacts/*" diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..2232c380 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "uv"] + path = uv + url = https://github.com/astral-sh/uv.git +[submodule "ruff"] + path = ruff + url = https://github.com/astral-sh/ruff.git diff --git a/Cargo.lock b/Cargo.lock index eddcf5ab..07071fe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,7 +559,7 @@ dependencies = [ "human-panic", "insta-cmd", "openssl", - "pep508_rs", + "pep508_rs 0.3.0", "tempfile", "termcolor", "thiserror", @@ -590,8 +590,8 @@ dependencies = [ "huak-workspace", "indexmap 2.1.0", "lazy_static", - "pep440_rs", - "pep508_rs", + "pep440_rs 0.4.0", + "pep508_rs 0.3.0", "pyproject-toml", "regex", "serde", @@ -608,7 +608,7 @@ dependencies = [ name = "huak-pyproject-toml" version = "0.0.0" dependencies = [ - "pep508_rs", + "pep508_rs 0.3.0", "tempfile", "thiserror", "toml_edit 0.21.0", @@ -942,9 +942,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" @@ -1023,14 +1023,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "pep440_rs" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c29f9c43de378b4e4e0cd7dbcce0e5cfb80443de8c05620368b2948bc936a1" +dependencies = [ + "once_cell", + "regex", + "serde", + "unicode-width", +] + [[package]] name = "pep508_rs" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4516b53d9ea6112ebb38b4af08d5707d30b994fb7f98ff133c5dcf7ed8fa854" +checksum = "aa9d1320b78f4a5715b3ec914f32b5e85a50287ad923730e3cbf0255259432eb" dependencies = [ "once_cell", - "pep440_rs", + "pep440_rs 0.4.0", "regex", "serde", "thiserror", @@ -1039,6 +1051,21 @@ dependencies = [ "url", ] +[[package]] +name = "pep508_rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "910c513bea0f4f833122321c0f20e8c704e01de98692f6989c2ec21f43d88b1e" +dependencies = [ + "once_cell", + "pep440_rs 0.4.0", + "regex", + "thiserror", + "tracing", + "unicode-width", + "url", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1065,9 +1092,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -1079,17 +1106,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "569e259cd132eb8cec5df8b672d187c5260f82ad352156b5da9549d4472e64b0" dependencies = [ "indexmap 2.1.0", - "pep440_rs", - "pep508_rs", + "pep440_rs 0.3.12", + "pep508_rs 0.2.4", "serde", "toml 0.7.8", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -1238,18 +1265,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -1342,9 +1369,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 35bfe12b..73d5485f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ glob = "0.3.1" hex = "0.4.3" human-panic = "1.1.5" lazy_static = "1.4.0" -pep440_rs = "0.3.11" -pep508_rs = "0.2.1" +pep440_rs = "0.4.0" +pep508_rs = "0.3.0" regex = "1.10.2" sha2 = "0.10.8" tempfile = "3.7.1" @@ -33,3 +33,21 @@ missing_errors_doc = "allow" missing_panics_doc = "allow" module_name_repetitions = "allow" too_many_lines = "allow" + +# Config for 'cargo dist' +[workspace.metadata.dist] +# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) +cargo-dist-version = "0.10.0" +# CI backends to support +ci = ["github"] +# The installers to generate for each app +installers = ["shell", "powershell", "msi"] +# Target platforms to build apps for (Rust target-triple syntax) +targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +# Publish jobs to run in CI +pr-run-mode = "plan" + +# The profile that 'cargo dist' will build with +[profile.dist] +inherits = "release" +lto = "thin" diff --git a/crates/huak-cli/Cargo.toml b/crates/huak-cli/Cargo.toml index b033e00e..56372972 100644 --- a/crates/huak-cli/Cargo.toml +++ b/crates/huak-cli/Cargo.toml @@ -13,6 +13,12 @@ rust-version.workspace = true authors.workspace = true license.workspace = true +[package.metadata.wix] +upgrade-guid = "249CBA9B-C8CA-4619-8CEE-80F10F66E636" +path-guid = "204168AD-B6CA-43A6-A78B-8F1C721B2A57" +license = false +eula = false + [dependencies] clap.workspace = true clap_complete = "4.4.1" diff --git a/crates/huak-package-manager/src/ops/toolchain.rs b/crates/huak-package-manager/src/ops/toolchain.rs index 67d217b2..79f9c37f 100644 --- a/crates/huak-package-manager/src/ops/toolchain.rs +++ b/crates/huak-package-manager/src/ops/toolchain.rs @@ -23,7 +23,7 @@ use termcolor::Color; /// already installed to the toolchain, and a version is provided that's different from the /// installed tool, then replace the installed tool with the desired version. pub fn add_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config) -> HuakResult<()> { - // Resolve a toolchain if a channel is provided. Otherwise resolve the curerent. + // Resolve a toolchain if a channel is provided. Otherwise resolve the current. let toolchain = config.workspace().resolve_local_toolchain(channel)?; add_tool_to_toolchain(tool, &toolchain, config) @@ -360,7 +360,7 @@ pub fn remove_tool(tool: &LocalTool, channel: Option<&Channel>, config: &Config) unimplemented!() } - // Resolve a toolchain if a channel is provided. Otherwise resolve the curerent. + // Resolve a toolchain if a channel is provided. Otherwise resolve the current. let toolchain = config.workspace().resolve_local_toolchain(channel)?; let venv = PythonEnvironment::new(toolchain.root().join(".venv"))?; @@ -492,7 +492,7 @@ pub fn update_toolchain( channel: Option<&Channel>, config: &Config, ) -> HuakResult<()> { - // Resolve a toolchain if a channel is provided. Otherwise resolve the curerent. + // Resolve a toolchain if a channel is provided. Otherwise resolve the current. let toolchain = config.workspace().resolve_local_toolchain(channel)?; let mut terminal = config.terminal(); @@ -551,9 +551,7 @@ pub fn use_toolchain(channel: &Channel, config: &Config) -> HuakResult<()> { } fn resolve_installed_toolchains(config: &Config) -> Option> { - let Some(home) = config.home.clone() else { - return None; - }; + let home = config.home.clone()?; let Ok(toolchains) = std::fs::read_dir(home.join("toolchains")) else { return None; diff --git a/crates/huak-package-manager/src/python_environment.rs b/crates/huak-package-manager/src/python_environment.rs index 0f69c45d..e666d926 100644 --- a/crates/huak-package-manager/src/python_environment.rs +++ b/crates/huak-package-manager/src/python_environment.rs @@ -655,7 +655,7 @@ mod tests { fn python_search() { let dir = tempdir().unwrap(); std::fs::write(dir.path().join("python3.11"), "").unwrap(); - let path_vals = vec![dir.path().to_str().unwrap().to_string()]; + let path_vals = [dir.path().to_str().unwrap().to_string()]; std::env::set_var("PATH", path_vals.join(":")); let mut interpreter_paths = python_paths(); diff --git a/crates/huak-package-manager/src/sys.rs b/crates/huak-package-manager/src/sys.rs index 51959cdd..44b665ca 100644 --- a/crates/huak-package-manager/src/sys.rs +++ b/crates/huak-package-manager/src/sys.rs @@ -44,11 +44,6 @@ pub enum Verbosity { Quiet, } -pub trait ToTerminal { - /// Get a `Terminal`. - fn to_terminal(&self) -> Terminal; -} - /// An abstraction around terminal output that remembers preferences for output /// verbosity and color (inspired by cargo's `Shell`). pub struct Terminal { diff --git a/crates/huak-package-manager/src/workspace.rs b/crates/huak-package-manager/src/workspace.rs index 11863a30..f1e0a4ed 100644 --- a/crates/huak-package-manager/src/workspace.rs +++ b/crates/huak-package-manager/src/workspace.rs @@ -199,11 +199,7 @@ fn resolve_local_toolchain( channel: Option<&Channel>, ) -> Option { let config = &workspace.config; - - let Some(home) = config.home.as_ref() else { - return None; - }; - + let home = config.home.as_ref()?; let toolchains = home.join("toolchains"); let settings = toolchains.join("settings.toml"); diff --git a/crates/huak-pyproject-toml/src/lib.rs b/crates/huak-pyproject-toml/src/lib.rs index fddf1dcf..f2a87070 100644 --- a/crates/huak-pyproject-toml/src/lib.rs +++ b/crates/huak-pyproject-toml/src/lib.rs @@ -184,13 +184,10 @@ impl PyProjectToml { #[must_use] pub fn project_dependencies(&self) -> Option> { - let Some(array) = self + let array = self .project_table() .and_then(|it| it.get("dependencies")) - .and_then(Item::as_array) - else { - return None; - }; + .and_then(Item::as_array)?; Some( array @@ -245,13 +242,10 @@ impl PyProjectToml { #[must_use] pub fn project_optional_dependencies(&self) -> Option>> { - let Some(table) = self + let table = self .project_table() .and_then(|it| it.get("optional-dependencies")) - .and_then(Item::as_table) - else { - return None; - }; + .and_then(Item::as_table)?; let mut deps = HashMap::new(); let groups = table.iter().map(|(k, _)| k).collect::>(); diff --git a/crates/huak-python-manager/src/install.rs b/crates/huak-python-manager/src/install.rs index 6fefc8b1..329a14d8 100644 --- a/crates/huak-python-manager/src/install.rs +++ b/crates/huak-python-manager/src/install.rs @@ -168,24 +168,24 @@ mod tests { let py = bin.join("python"); let py3 = bin.join("python3"); let py312 = bin.join("python3.12"); - let pys = [py.clone(), py3, py312]; + let pythons = [py.clone(), py3, py312]; let module = bin.join("module"); std::fs::create_dir_all(&bin).unwrap(); - for file in pys.iter().chain([&module]) { + for file in pythons.iter().chain([&module]) { let mut file = File::create(file).unwrap(); file.write_all(&[]).unwrap(); } let release_dir = PythonReleaseDir::new(dir); - let ibin = release_dir.bin_path(); - let ipy = ibin.join("python"); + let release_bin = release_dir.bin_path(); + let release_py = release_bin.join("python"); - assert_eq!(bin, ibin); - assert_eq!(py, ipy); - assert_eq!(module, ibin.join("module")); + assert_eq!(bin, release_bin); + assert_eq!(py, release_py); + assert_eq!(module, release_bin.join("module")); } #[cfg(windows)] @@ -197,23 +197,23 @@ mod tests { let parent = dir.join("install"); let bin = parent.join("Scripts"); let py = parent.join("python.exe"); - let pys = [py.clone()]; + let pythons = [py.clone()]; let module = bin.join("module.exe"); std::fs::create_dir_all(&bin).unwrap(); - for file in pys.iter().chain([&module]) { + for file in pythons.iter().chain([&module]) { let mut file = File::create(file).unwrap(); file.write_all(&[]).unwrap(); } let release_dir = PythonReleaseDir::new(dir); - let ibin = release_dir.bin_path(); - let ipy = release_dir.python_path(None); + let release_bin = release_dir.bin_path(); + let release_py = release_dir.python_path(None); - assert_eq!(bin, ibin); - assert_eq!(py, ipy); - assert_eq!(module, ibin.join("module.exe")); + assert_eq!(bin, release_bin); + assert_eq!(py, release_py); + assert_eq!(module, release_bin.join("module.exe")); } } diff --git a/ruff b/ruff new file mode 160000 index 00000000..235cfb79 --- /dev/null +++ b/ruff @@ -0,0 +1 @@ +Subproject commit 235cfb79769da2c435b9c88d8bae4a79f1234857 diff --git a/uv b/uv new file mode 160000 index 00000000..fef1956c --- /dev/null +++ b/uv @@ -0,0 +1 @@ +Subproject commit fef1956c627483d2496b14a0a6a6ac2fc2826c2f