macro128 / pdm-conda

A PDM plugin to resolve/install/uninstall project dependencies with Conda
32 stars 1 forks source link

Failure to uninstall locally #34

Closed griff-rees closed 4 days ago

griff-rees commented 2 months ago

Again nice work on the package. After getting stuck on #33, removing pdm-conda locally seems to fail. Figure I can force it, but FYI (using project as the folder where I tried pdm-cond within pyproject.toml):

$ cd project 
$ pdm plugin remove pdm-conda
Will remove: ['pdm-conda'], continue? [y/n] (y): y
Uninstallation succeeds.
$ pdm add tqdm -v
Adding packages to default dependencies: tqdm
Traceback (most recent call last):
  File "/Users/grees/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 358, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 276, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 271, in main
    self.handle(project, options)
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/core.py", line 207, in handle
    command.handle(project, options)
  File "/Users/grees/code/clim-recal/python/.pdm-plugins/lib/python3.12/site-packages/pdm_conda/cli/commands/add.py", line 123, in handle
    super().handle(project, options)
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/cli/commands/add.py", line 69, in handle
    self.do_add(
  File "/Users/grees/.local/pipx/venvs/pdm/lib/python3.12/site-packages/pdm/cli/commands/add.py", line 159, in do_add
    project.add_dependencies(requirements, group, selection.dev or False, write=False)
TypeError: CondaProject.add_dependencies() got an unexpected keyword argument 'write'

For completeness (after the uninstall above; annoyingly quote marks don't show up well hence no console/ python syntax highlighting):

$ cd project
$ pdm plugin list
Installed packages:
Pygments          2.18.0    Pygments is a syntax highlighting package written in Python. 
anyio             4.3.0     High level compatibility layer for multiple asyasynchronous event
                            loop implementations
blinker           1.8.2     Fast, simple object-to-object and broadcast signaling
certifi           2024.2.2  Python package for providing Mozilla's CA Bundle.
dep-logic         0.2.0     Python dependency specifications supporting logical operations
distlib           0.3.8     Distribution utilities
filelock          3.14.0    A platform independent file lock.
findpython        0.6.1     A utility to find python versions on your system
h11               0.14.0    A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
hishel            0.0.26    Persistent cache implementation for httpx and httpcore
httpcore          1.0.5     A minimal low-level HTTP client.
httpx             0.27.0    The next generation HTTP client.
idna              3.7       Internationalized Domain Names in Applications (IDNA)
installer         0.7.0     A library for installing Python wheels.
markdown-it-py    3.0.0     Python port of markdown-it. Markdown parsing, done right!
mdurl             0.1.2     Markdown URL utilities
msgpack           1.0.8     MessagePack serializer
packaging         24.0      Core utilities for Python packages
pbs-installer     2024.4.24 Installer for Python Build Standalone
pdm               2.15.1    A modern Python package and dependency manager supporting the
                            latest PEP standards
pdm-conda         0.17.5    A PDM plugin to resolve/install/uninstall project dependencies
                            with Conda
pip               24.0      The PyPA recommended tool for installing Python packages.
platformdirs      4.2.1     A small Python package for determining appropriate
                            platform-specific dirs, e.g. a `user data dir`.
pyproject_hooks   1.1.0     Wrappers to call pyproject.toml-based build backend hooks.
python-dotenv     1.0.1     Read key-value pairs from a .env file and set them as
                            environment variables
resolvelib        1.0.1     Resolve abstract dependencies into concrete ones
rich              13.7.1    Render rich text, tables, progress bars, syntax highlighting,
                            markdown and more to the terminal
shellingham       1.5.4     Tool to Detect Surrounding Shell
sniffio           1.3.1     Sniff out which async library your code is running under
socksio           1.0.0     Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5.
tomlkit           0.12.5    Style preserving TOML library
truststore        0.9.1     Verify certificates using native system trust stores
typing_extensions 4.11.0    Backported and Experimental Type Hints for Python 3.8+
unearth           0.15.2    A utility to fetch and download python packages
virtualenv        20.26.2   Virtual Python Environment builder
zstandard         0.22.0    Zstandard bindings for Python

If I go to another folder, it doesn't show up as an installed plugin

$ cd  ~ # away from pdm project
$ pdm plugins list
pdm plugin list        
Installed packages:
Pygments          2.17.2   Pygments is a syntax highlighting package written in Python.
anyio             4.3.0    High level compatibility layer for multiple asynchronous event loop implementations
blinker           1.7.0    Fast, simple object-to-object and broadcast signaling
certifi           2024.2.2 Python package for providing Mozilla's CA Bundle.
dep-logic         0.2.0    Python dependency specifications supporting logical operations
distlib           0.3.8    Distribution utilities
filelock          3.13.4   A platform independent file lock.
findpython        0.6.0    A utility to find python versions on your system
h11               0.14.0   A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
hishel            0.0.25   Persistent cache implementation for httpx and httpcore
httpcore          1.0.5    A minimal low-level HTTP client.
httpx             0.27.0   The next generation HTTP client.
idna              3.7      Internationalized Domain Names in Applications (IDNA)
installer         0.7.0    A library for installing Python wheels.
markdown-it-py    3.0.0    Python port of markdown-it. Markdown parsing, done right!
mdurl             0.1.2    Markdown URL utilities
msgpack           1.0.8    MessagePack serializer
packaging         24.0     Core utilities for Python packages
pbs-installer     2024.4.1 Installer for Python Build Standalone
pdm               2.15.2   A modern Python package and dependency manager supporting the latest PEP standards
pip               24.0     The PyPA recommended tool for installing Python packages.
platformdirs      4.2.0    A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir".
pyproject_hooks   1.0.0    Wrappers to call pyproject.toml-based build backend hooks.
python-dotenv     1.0.1    Read key-value pairs from a .env file and set them as environment variables
resolvelib        1.0.1    Resolve abstract dependencies into concrete ones
rich              13.7.1   Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal
shellingham       1.5.4    Tool to Detect Surrounding Shell
sniffio           1.3.1    Sniff out which async library your code is running under
socksio           1.0.0    Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5.
tomlkit           0.12.4   Style preserving TOML library
truststore        0.8.0    Verify certificates using native system trust stores
typing_extensions 4.11.0   Backported and Experimental Type Hints for Python 3.8+
unearth           0.15.1   A utility to fetch and download python packages
virtualenv        20.25.1  Virtual Python Environment builder
zstandard         0.22.0   Zstandard bindings for Python
griff-rees commented 2 months ago

Think I need to find another way to uninstall, but got this far:

$ cd project
$ ls .pdm-plugins/lib/python3.12/site-packages/
__init__.py   cli/          environments/ installers/   models/       resolver/     utils.py
__pycache__/  conda.py      hooks.py      mapping.py    project/      resolvers.py
$ pdm add tqdm 
ERROR: Failed to load plugin conda=pdm_conda:main: No module named 'pdm_conda'
Adding packages to default dependencies: tqdm
🔒 Lock successful
Changes are written to pyproject.toml.
Synchronizing working set with resolved packages: 0 to add, 1 to update, 0 to remove

  ✔ Update tqdm 4.66.2 -> 4.66.4 successful
Installing the project as an editable package...
  ✔ Update project 0.1.0 -> 0.1.0 successful

🎉 All complete!
griff-rees commented 2 months ago

Possibly related: https://github.com/pdm-project/pdm/issues/2820

griff-rees commented 2 months ago

Also needed to rm pdm.toml which set backend to micromamba:

[python]
use_venv = true
use_pyenv = false

[venv]
backend = "micromamba"
in_project = false
macro128 commented 2 months ago

Hi! Related to this issue, it seems like pdm keeps finding the plugin (even after deleting it) and so it keeps falling into this issue, it might happen with every plugin, you should report it to the main package so it gets fixed

This other issue is related to how the plugin changes settings and will be fixed at the same time of this other one.

griff-rees commented 1 month ago

Ah thanks for the details. Am I right in thinking there's multiple components then? Can separate into different issues if that's useful for you.

macro128 commented 1 month ago

Hi! This issue should be fixed since v0.18.0, could you try it to confirm it's working as expected?