-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronize pip indentation with conda env export #573
Conversation
✅ Deploy Preview for conda-lock ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
In this case it seems to me like Conda is using inconsistent indentation, no? The indentation level under Wouldn't it make more sense to open the dual issue in Conda? |
Thanks @maresb . Conda has used this formatting since always. I can't see them changing it, especially since it's just part of the ruamel.yaml configuration ( In contrast, conda-lock is much newer and uses a custom serializer for environment files, even if it's super simple. But regardless, for me, one of the main use cases for the It's also a (minor) inconvenience if you want to write some code to modify an environment.yml file that you'll end up with whitespace differences between a conda-env-produced one and a conda-lock-produced one. |
Actually, I think the issue is that the pip dependencies actually should be an level 3 indentation, since it's Update: This isn't quite right. See below. |
The ruamel docs describes As far as I can tell ruamel.yaml calculates the indentation as follows ("mapping" doesn't seem to have an impact):
So when you're looking at the indentation of the sequences (via ruamel.yaml), you need to look at the position of the values rather than the You can get the same effect using |
Thanks @jamesmyatt for all the research into this issue. This still looks weird to me, but if it's correct in some sense, and if it's more consistent with Conda then let's do it. Just to confirm before merging, is this PR still correct in the sense of your last comment? |
Yes. I'm happy with this. If it helps, I think you can to look at it this way: dependencies:
- python # <-- this dash is indented 2 spaces compared with the start of "dependencies:"
- pip:
- click # <-- this dash is indented 0 spaces compared with the start of "pip:" |
Thanks for spelling it out @jamesmyatt, I get it now. |
This is a minor change but it synchronizes the indentation of the pip dependencies with the output of
conda env export
. It makes it easier to compareconda-lock
env files with exports of real conda environments.Indentation in
conda env export
is determined by theruamel.yaml
configuration inconda.common.serialize
: e.g. https://github.com/conda/conda/blob/ff330a1807d34870e60a9b8d3540695587845296/conda/common/serialize.py#L20.Commands
conda-lock -f environment.yml -p win-64 conda-lock render -k env -p win-64 conda-lock install -n lock-test conda env export -n lock-test > env-export.yml
environment.yml
conda-win-64.lock.yml
environment.yml