macro128 / pdm-conda

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

Installing plugin downgrades PDM to 2.6.1 and breaks PDM installation #22

Closed amitkparekh closed 9 months ago

amitkparekh commented 9 months ago

Hi! Something very odd happened.

I ran pdm self add pdm-conda and my PDM downgrades to 2.6.1, or maybe it claims to be 2.6.1? If I try to remove pdm-conda or try to update PDM (with pdm self update), it says:

root@machine:/workspace/project# pdm self update -vv
Traceback (most recent call last):
  File "/opt/conda/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/pdm/core.py", line 268, in main
    return Core().main(args)
           ^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/pdm/core.py", line 192, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "/opt/conda/lib/python3.11/site-packages/pdm/core.py", line 187, in main
    self.handle(project, options)
  File "/opt/conda/lib/python3.11/site-packages/pdm/core.py", line 153, in handle
    command.handle(project, options)
  File "/opt/conda/lib/python3.11/site-packages/pdm/cli/commands/self_cmd.py", line 234, in handle
    version = get_latest_pdm_version_from_pypi(project, options.pre)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/pdm/cli/actions.py", line 811, in get_latest_pdm_version_from_pypi
    candidate = finder.find_best_match("pdm", allow_prereleases=prereleases).best
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/unearth/finder.py", line 376, in find_best_match
    best_match = next(iter(applicable_candidates), None)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/unearth/finder.py", line 309, in _find_packages_from_requirement
    yield from self._find_packages(requirement.name, allow_yanked)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/unearth/finder.py", line 275, in _find_packages
    return sorted(all_packages, key=self._sort_key, reverse=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/unearth/collector.py", line 135, in collect_links_from_location
    yield from _collect_links_from_index(session, location)
  File "/opt/conda/lib/python3.11/site-packages/unearth/collector.py", line 85, in parse_json_response
    data = json.loads(page.content)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This happened on my Mac (where I'm not running PDM within a conda environment), and within a Docker container on a linux machine (where I am running PDM within a conda environment). The only solution from this is to force re-install PDM.

Have you seen this before? Am I doing something wrong?

macro128 commented 9 months ago

Hi! That's weird cuz latest plugin version requires pdm~=2.10.0, could you add to your pyproject.toml the following lines?

[tool.pdm]
plugins = [
    "pdm-conda>=0.14.1"
]

After that if you run pdm install --plugins it should force pdm to use the correct plugin version

amitkparekh commented 9 months ago

I'm just wondering, what does ~= mean in this context? Could that be a reason, like PDM is downgrading to suit the plugin, but then some other Python break since PDM 2.6.1 might not support Python 3.11?

macro128 commented 9 months ago

Oh you're using python 3.11, that's the problem, the plugin requires python~=3.10.0, in this context ~=3.10.0 means >=3.10.0,<3.11.0. Let me see if changing the python requirement to python>=3.10.0 doesn't break tests

macro128 commented 9 months ago

@amitkparekh this should be fixed on v0.14.2, if it doesn't please reach back