conda / conda-lock

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

[Feature Request] Support [tool.conda-lock.dev-dependencies] section in pyproject.toml #162

Open wesleykendall opened 2 years ago

wesleykendall commented 2 years ago

The [tool.conda-lock.dependencies] section in pyproject.toml allows one to specify Conda-only dependencies that aren't available via pip. I propose a [tool.conda-lock.dev-dependencies] section for development dependencies only available via Conda.

For example, consider that you want to install git at the latest version as a development dependency but not have this be part of your production dependencies. This is a current requirement of my company since we use newer features in git for our development.

Furthermore, I'm writing a script to generate a meta.yaml (conda-build) using conda-lock. This would help me avoid pulling in git as a dependency of my Conda package when other users install it.

If the authors like this feature suggestion, let me know how trivial it might be to add it and where is the best place for me to look in the code. I'd be happy to try to open a PR. Also open to other ways to achieve this.

mariusvniekerk commented 2 years ago

probably in keeping with the structure of pep621 pyproject-toml files

[tool.conda-lock.optional-dependencies]
dev = ["git"]
someothercategory = ["another dep"]
wesleykendall commented 2 years ago

@mariusvniekerk My understanding of optional dependencies after reading pep621 are that they are optional production dependencies. For example, the pip_support optional dependency for conda-lock.

git would only be for development/CI purposes and never pulled into a production install, which is effectively how poetry.dev-dependencies works.

Hope that makes sense. Are you able to point me to the exact place where conda-lock parses the tool.poetry.dev-dependencies section? It might make more sense if I can open a quick PR to illustrate

mariusvniekerk commented 2 years ago

This is the section that adds in the additional tool.conda-lock parts https://github.com/conda-incubator/conda-lock/blob/4203aef6159093b33382018c54e93c58e488ddb5/conda_lock/src_parser/pyproject_toml.py#L156

Since poetry and flit/pep621 style dependencies differ there are two pyproject toml parsers.
https://github.com/conda-incubator/conda-lock/blob/4203aef6159093b33382018c54e93c58e488ddb5/conda_lock/src_parser/pyproject_toml.py#L62 and https://github.com/conda-incubator/conda-lock/blob/4203aef6159093b33382018c54e93c58e488ddb5/conda_lock/src_parser/pyproject_toml.py#L271