macro128 / pdm-conda

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

Add easy complete disabling #36

Closed mdekstrand closed 2 months ago

mdekstrand commented 3 months ago

For projects that want to test and build on both vanilla and Conda Python, it would be useful to be able to easily disable pdm-conda, or generally have it do less when PDM is using a vanilla virtual environment.

Specifically, right now if there are conda dependencies specified (or as-default-manager=true), then it fails:

  File "/Users/mde48/LensKit/lkpy/.pdm-plugins/lib/python3.12/site-packages/pdm_conda/resolvers.py", line 247, in resolve
    assert not any(isinstance(r, CondaRequirement) for r in requirements)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Either a command-line / environment variable to disable the plugin's manipulation of dependencies, or automatically detecting non-Conda environments and disabling that (perhaps with logging messages to show the enable/disable status), would make it easier to work with both types of environments (without needing to install/un-install the plugin).

macro128 commented 2 months ago

Hi! Since v0.18.0 you can use env variable PDM_CONDA_ACTIVE=0/1 or

[pdm.conda]
active = false/true

to deactivate/activate the plugin. Hope this helps!