-
Notifications
You must be signed in to change notification settings - Fork 114
fix: register as conda plugin #905
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
Open
beckermr
wants to merge
24
commits into
main
Choose a base branch
from
beckermr-patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+101
−11
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
17912ca
fix: register as plugin properly
beckermr c33c7ef
fix: add conda entry point for conda-lock
beckermr 7d834a3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 589987e
Refactor plugin to handle optional conda import
beckermr a989779
fix: typing issues
beckermr 0dbc5d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5a3f923
fix: ignore typing errors?
beckermr 10f270c
Apply suggestion from @beckermr
beckermr 06dd585
Add basic logger configuration function
beckermr 8917581
Replace basicConfig with configure_logger_basic
beckermr 54af5cd
Replace basicConfig with configure_logger_basic
beckermr 10b9e1b
Apply suggestion from @beckermr
beckermr 7afefed
Apply suggestions from code review
beckermr 0ed0ea2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 310a2e0
fix: pass args
beckermr c68609d
Apply suggestion from @beckermr
beckermr dd636ac
test: expand integration tests to test conda lock cli plugin
beckermr dc15ee6
fix: use proper shell in tests
beckermr 131c2b0
fix: need hatchling
beckermr 16ecdd4
fix: need hatch-vcs
beckermr 9f893ba
fix: need editables
beckermr 8cad0b3
fix: need conda too
beckermr 76d1d6b
fix: exclude windows from 3.14 testing
beckermr 84a0635
feat: use a simpler approach for the fix
beckermr 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 |
|---|---|---|
|
|
@@ -38,6 +38,11 @@ jobs: | |
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
| python-version: [ "3.10", "3.14" ] | ||
| use_conda_cli: ["false", "true"] | ||
| exclude: | ||
| - os: windows-latest | ||
| python-version: "3.14" | ||
| use_conda_cli: "true" | ||
| steps: | ||
| - name: Set Conda platform | ||
| run: | | ||
|
|
@@ -55,14 +60,17 @@ jobs: | |
| with: | ||
| persist-credentials: false | ||
| - name: Set up Python | ||
| if: matrix.use_conda_cli == 'false' | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: install conda-lock | ||
| if: matrix.use_conda_cli == 'false' | ||
| run: | | ||
| pip install pipx | ||
| pipx install -e . | ||
| - name: run-test | ||
| if: matrix.use_conda_cli == 'false' | ||
| run: | | ||
| conda-lock --log-level=DEBUG --micromamba -f tests/gdal/environment.yml -p $CONDA_PLATFORM | ||
| conda-lock render -p $CONDA_PLATFORM | ||
|
|
@@ -72,11 +80,37 @@ jobs: | |
| cat conda-lock.yml | ||
| mkdir lockfiles | ||
| mv conda-$CONDA_PLATFORM.lock conda-$CONDA_PLATFORM.lock.yml conda-lock.yml lockfiles | ||
| - name: Set up Python | ||
| if: matrix.use_conda_cli == 'true' | ||
| uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | ||
| with: | ||
| auto-activate-base: true | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: install conda-lock | ||
| if: matrix.use_conda_cli == 'true' | ||
| shell: bash -leo pipefail {0} | ||
| run: | | ||
| conda install conda pip setuptools editables hatchling hatch-vcs conda-lock --yes | ||
| conda uninstall conda-lock --force --yes | ||
| pip install --no-deps --no-build-isolation -e . | ||
| - name: run-test | ||
| if: matrix.use_conda_cli == 'true' | ||
| shell: bash -leo pipefail {0} | ||
| run: | | ||
| python -m conda lock --log-level=DEBUG --micromamba -f tests/gdal/environment.yml -p $CONDA_PLATFORM | ||
| python -m conda lock render -p $CONDA_PLATFORM | ||
| python -m conda lock render -p $CONDA_PLATFORM --kind=env | ||
| cat conda-$CONDA_PLATFORM.lock | ||
| cat conda-$CONDA_PLATFORM.lock.yml | ||
| cat conda-lock.yml | ||
| mkdir lockfiles | ||
| mv conda-$CONDA_PLATFORM.lock conda-$CONDA_PLATFORM.lock.yml conda-lock.yml lockfiles | ||
| - name: Upload lockfiles | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| with: | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }} | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.use_conda_cli }} | ||
| path: lockfiles | ||
|
|
||
| install-gdal-with-micromamba: | ||
| runs-on: ${{ matrix.os }} | ||
| needs: lock-gdal | ||
|
|
@@ -87,7 +121,12 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
| python-version: [ "3.10" ] | ||
| python-version: [ "3.10", "3.14" ] | ||
| use_conda_cli: ["false", "true"] | ||
| exclude: | ||
| - os: windows-latest | ||
| python-version: "3.14" | ||
| use_conda_cli: "true" | ||
| steps: | ||
| - name: Set Conda platform | ||
| run: | | ||
|
|
@@ -110,7 +149,7 @@ jobs: | |
| - name: Download lockfiles | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | ||
| with: | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }} | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.use_conda_cli }} | ||
| path: lockfiles | ||
| - name: Install GDAL with Micromamba | ||
| run: | | ||
|
|
@@ -125,6 +164,7 @@ jobs: | |
| micromamba run -n gdal-test-mm-lock python -c 'import toolz; print(toolz.__version__)' | ||
| # Micromamba won't install pip dependencies from explicit lockfiles, so skip this test | ||
| micromamba run -n gdal-test-mm-env python -c 'import toolz; print(toolz.__version__)' | ||
|
|
||
| install-gdal-with-conda-lock: | ||
| runs-on: ${{ matrix.os }} | ||
| needs: lock-gdal | ||
|
|
@@ -136,6 +176,11 @@ jobs: | |
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
| python-version: [ "3.10", "3.14" ] | ||
| use_conda_cli: ["false", "true"] | ||
| exclude: | ||
| - os: windows-latest | ||
| python-version: "3.14" | ||
| use_conda_cli: "true" | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
|
|
@@ -151,7 +196,7 @@ jobs: | |
| - name: Download lockfiles | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | ||
| with: | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }} | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.use_conda_cli }} | ||
| path: lockfiles | ||
| - name: Install GDAL with conda-lock | ||
| run: | | ||
|
|
@@ -182,7 +227,12 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
| python-version: [ "3.10" ] | ||
| python-version: [ "3.10", "3.14" ] | ||
| use_conda_cli: ["false", "true"] | ||
| exclude: | ||
| - os: windows-latest | ||
| python-version: "3.14" | ||
| use_conda_cli: "true" | ||
|
Comment on lines
+232
to
+235
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this exclude? Does setup-miniconda not work yet with python 3.14? Could we add a comment explaining why? |
||
| steps: | ||
| - uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0 | ||
| with: | ||
|
|
@@ -191,7 +241,7 @@ jobs: | |
| - name: Download lockfiles | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | ||
| with: | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }} | ||
| name: conda-lock-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.use_conda_cli }} | ||
| path: lockfiles | ||
| - name: Install GDAL with conda | ||
| run: | | ||
|
|
||
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,37 @@ | ||
| """Conda plugin hooks for conda-lock. | ||
|
|
||
| Registers ``conda lock`` so the feedstock tooling is available as a conda | ||
| subcommand when this package is installed in the same environment as conda. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
|
|
||
| try: | ||
| from conda.plugins import hookimpl # type: ignore[unused-ignore] | ||
| from conda.plugins.types import CondaSubcommand # type: ignore[unused-ignore] | ||
|
|
||
| HAVE_CONDA = True | ||
| except ImportError: | ||
| HAVE_CONDA = False | ||
|
|
||
|
|
||
| if HAVE_CONDA: | ||
|
|
||
| def _execute(args: tuple[str, ...]) -> int | None: | ||
| """Dispatch plugin arguments to the lock CLI. | ||
|
|
||
| Lazy import to avoid import-time side effects when not using conda-lock. | ||
| """ | ||
| # code below suggested by AI and appears to work | ||
| from conda_lock.conda_lock import main | ||
|
|
||
| return main(args, standalone_mode=False) | ||
beckermr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @hookimpl | ||
| def conda_subcommands() -> CondaSubcommand: | ||
| yield CondaSubcommand( | ||
| name="lock", | ||
| summary=("enerate fully reproducible lock files for conda environments."), | ||
| action=_execute, | ||
| ) | ||
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.