conda / conda-lock

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

Proposed fix for #474: enables parsing of requirements.txt during locking #476

Open stefansjs opened 1 year ago

stefansjs commented 1 year ago

Description

This addresses https://github.com/conda/conda-lock/issues/474, which fails to lock if environment.yml has -rrequirements.txt in the pip requirements. The main problem with the existing implementation is that it treats requirements lists as if they were a tool.poetry.dependencies block in a pyproject.toml. Poetry is great, and I see why you would want to vendor such a clean implementation, but poetry doesn't have any specification for external files. Further, any differences between calling pip install and poetry lock would eventually cause an issue.

My fix mimics conda's implementation which writes a temporary requirements.txt and invokes the command-line pip install command. https://github.com/conda/conda/blob/main/conda_env/installers/pip.py. Ideally this means there will be fewer bugs/differences between performing conda env create and conda lock.

Since pip doesn't provide an explicit library or API for parsing I do it by invoking pip's own parse_requirements function. I also based the return values strongly on the pyproject_toml.py implementation.

Testing and Feedback

I would love if somebody could suggest the right place to put unit tests.

netlify[bot] commented 1 year ago

Deploy Preview for conda-lock ready!

Name Link
Latest commit 41cae9a2fd516f29ae283231cd57d0c4513d4e0f
Latest deploy log https://app.netlify.com/sites/conda-lock/deploys/64c4399b190087000832f68e
Deploy Preview https://deploy-preview-476--conda-lock.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.