conda / conda-lock

Lightweight lockfile for conda environments
https://conda.github.io/conda-lock/
Other
493 stars 103 forks source link

SyntaxWarning on Python 3.12 #677

Open ctcjab opened 1 month ago

ctcjab commented 1 month ago

Checklist

What happened?

After installing the latest version of conda-lock via pixi global install conda-lock, invoking conda-lock results in SyntaxWarning spam in the console output:

$ conda-lock --version
/pixi/envs/conda-lock/lib/python3.12/site-packages/clikit/utils/string.py:81: SyntaxWarning: invalid escape sequence '\s'
  words = re.split("\s+", string)
/pixi/envs/conda-lock/lib/python3.12/site-packages/clikit/api/args/format/command_option.py:47: SyntaxWarning: invalid escape sequence '\-'
  if not re.match("^[a-zA-Z0-9\-]+$", alias):
conda-lock, version 2.5.7

Additional Context

The offending code is in clikit, but it looks like that code has since been fixed (note it now uses a r"raw string literal" as it should have in the first place).

I looked through conda-lock's pyproject.toml to see if fixing this is just a matter of updating a >= constraint on clikit, but I didn't see clikit declared in dependencies. Perhaps it's getting pulled in transitively, but (ironically) I couldn't find a lockfile that mentioned it when I searched the code.

Note this reproduces with a fresh install of the latest version of conda-lock via pixi global install conda-lock, but does not reproduce when installing via other tools I've tested, e.g. uv tool install conda-lock.

ctcjab commented 1 month ago

In case it's relevant, this reproduces when using the latest version of pixi to install conda-lock, namely 0.29.0.

maresb commented 1 month ago

Thanks a lot @ctcjab for the report! We just removed the clikit dependency in #637. Unfortunately that broke some other stuff, so we can't release it yet.

BTW I am very curious why you use conda-lock in addition to pixi. (See also #615)

ctcjab commented 1 month ago

Thanks @maresb, good to know. Out of curiosity, any idea why this doesn't reproduce when installed with e.g. uv tool install?

I use conda-lock in addition to pixi because I work with a large number of codebases, most of which are not mine, and all of which have limited resources for migrations. I've been tracking #615 with interest, and am excited to understand the best path forward for existing conda-lock users, as well as for conda users who are not currently using lockfiles and may be interested to leapfrog straight to pixi.

ctcjab commented 1 month ago

Oh, the only reason this didn't reproduce with uv tool install is that it used an older Python version. I just tried uv tool install conda-lock --python 3.12 and then with that installation this issue reproduced.

maresb commented 1 month ago

Cool, thanks a lot @ctcjab for tracking that down!!!

Any way I could get you to test main? I'm really close to a new major release.

ctcjab commented 1 month ago

Just did a uv pip install -e . from the latest revision of main in a python 3.12 venv, and when I invoked the conda-lock that got installed there, this did not reproduce. Awesome!