conda / conda-lock

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

"pypi_to_conda_lookup_file" flag not working as intended #579

Closed neojunjie closed 4 months ago

neojunjie commented 5 months ago

Checklist

What happened?

The occurrence of an error was observed when attempting to reference an alternative location for the mapping file using the "pypi_to_conda_lookup_file" option.

Command fired:

conda-lock -f test_conda_lock.yml -p linux-64   --pypi_to_conda_lookup_file https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/mappings/pypi/grayskull_pypi_mapping.yaml

Error Logs:

Traceback (most recent call last):
  File "/home//miniforge3/bin/conda-lock", line 8, in <module>
    sys.exit(main())
  File "/home//miniforge3/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home//miniforge3/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home//miniforge3/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home//miniforge3/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home//miniforge3/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home//miniforge3/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home//miniforge3/lib/python3.10/site-packages/conda_lock/conda_lock.py", line 1319, in lock
    set_lookup_location(pypi_to_conda_lookup_file)
  File "/home//miniforge3/lib/python3.10/site-packages/conda_lock/lookup.py", line 66, in set_lookup_location
    LOOKUP_OBJECT.mapping_url = lookup_url
  File "/home//miniforge3/lib/python3.10/site-packages/conda_lock/lookup.py", line 27, in mapping_url
    del self.pypi_lookup
AttributeError: pypi_lookup

Conda Info

No response

Conda Config

No response

Conda list

No response

Additional Context

No response

jdespe commented 5 months ago

Hi, same issue here, the variables self.pypi_lookup and self.conda_lookup seems to be deleted before assignment. A temporary workaround is editing the lookup.py file to remove :

        del self.pypi_lookup
        del self.conda_lookup

A way to reproduce the problem is to create a pyproject.toml from https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#a-full-example then calling : conda-lock lock --file pyproject.toml --pypi_to_conda_lookup_file https://raw.githubusercontent.com/regro/cf-graph-countyfair/master/mappings/pypi/grayskull_pypi_mapping.yaml --platform win-64 --lockfile conda-lock.yml

Thanks !

maresb commented 4 months ago

Thanks for the report! This was fixed in #588 and has been released.