-
Notifications
You must be signed in to change notification settings - Fork 46
jinja2 + envvars and aliases #88
base: develop
Are you sure you want to change the base?
Conversation
If an 'environment' or 'aliases' tag is found in environment.yml, 'conda-env create' will create activate/deactivate scripts that configure the environment with those values when activated, and remove them when deactivated. This is done by putting two simple '.sh/.bat' files in $PREFIX/etc/conda/(de)?activate.d These files then evalute the output from a python script that does the actual handling of adding/removing environment variables and aliases.
This is simlar to what 'conda_build' does.
248e131
to
4d972b4
Compare
I can't think of a use case for this. would you mind providing me one? |
I'm using this to create a development environment for my projects. My name: coilib50
includes:
- {{ root }}/../../aasimar/environment.yml
- {{ root }}/../../ben10/environment.yml
dependencies:
- gcc
- boost==1.55.0
- scons==2.3.0
environment:
- PYTHONPATH:
- {{ root }}/source/python
- {{ root }}/artifacts/12.0-redhat64-libs
- LD_LIBRARY_PATH:
- {{ root }}/artifacts/12.0-redhat64-libs You can see that
Even more useful than that, I can use jinja to create different sets of dependencies based on the current platform (correct me if I'm wrong, but i don't think selectors such as {% if os.sys.platform != 'win32' %}
- unrar==5.2.7
{% else %}
- gnuwin32=0.6.3
- openssl=1.0.0e
- pywin32==217
{% endif %} |
@campos-ddc this is the problem I see from your PR. It was meant to fix your own problem and it's hard for me to see any other situation where you would need something like this. |
I used Jinja2 because it's the same thing available to conda-build. What do you think about using selectors instead? Like [win] or [unix]. Still requires pre-processing, but not as ugly as jinja. Otherwise, this cases can only be solved by having two separate environment files. It's a pity that you don't think that conda-env should configure more of the environment (vars and aliases), I'll just have to maintain a fork with my requirements :) |
Hi @malev, I work with @campos-ddc at @ESSS and would like to join the discussion, if I may. 😄 We have been using internal tools that take care of configuring our environment in a cross-platform way, and are now switching to Our setup consist of several small projects, all dependent on one another, where we work on them in "develop" mode. This poses a few challenges that are not solved (as far as we know) by
We felt those requirements could be met by some patches to
How do you configure the environment variables your projects need? Or you don't have this need at all? We would love to hear how you guys solve this, we might have tunnel vision here as this is just the way we are used to work. Regarding the PR as it stands now, could you pinpoint what are the points about the implementation or about the motivation behind it that you don't like? We are eager to discuss and make any changes you guys feel appropriate. We at @ESSS would love to contribute back to the project, and we feel that our use case is general enough, if perhaps not that common. Cheers, |
@campos-ddc @nicoddemus I see what you guys are saying, let me think a little bit more about this. I also want to be able to have conditions and environmental variables and I'm not a fan of |
No problem. 😄
Doesn't some support for that exist already? I mean, this PR works by creating a |
Any news on this @malev? Any concerns you would like to address regarding this PR? |
@malev do you think it would be better to separate the features in this PR into individual PRs? If you prefer that (both to review and perhaps to reject some of them) we can work on it. I would drop the |
@nicoddemus I have an idea for this. something like JinjaSpec. |
At least for our use cases it seems this would work for us. Thanks for looking into this. I wonder though how much other systems look for an Also, another feature we use a lot is environment variable support. How do you feel about that? cc @tadeu, @campos-ddc do you have any thoughts here? |
if we do what I want do to, |
Sorry, the correct term is Preprocessing selectors. IMO they feel like they would be a good fit for |
mmh, I'm not a fan of them, they don't look like yaml standard. I rather go with jinja2. Also with jinja we will have super versatile environment definitions. |
No problem, let's go with |
See readthedocs/readthedocs.org#857 for the readthedocs conda support development, I work at @clinicalgraphics and we're sponsoring the development of that feature. So to clarify, the intention is to just call Although I can understand @malev's objection that it's not standard yaml (comments are allowed though right?), I really dig the preprocessed comments. It also seems logical to me to make similar and/or related features behave similarly across |
I support this view:
It should be noted that It seems I wish that |
Ooh, such a good idea! Reuse of |
Perhaps instead of implementing what has been discussed here so far, it would be better then to just support |
We still have interest to have these features in I've seem that it is tagged for 2.5.0, and that the 2.5.0 release date seems to be close. Would it help if we resolve the conflicts, and also perhaps simplify it and remove the Thanks! |
I was reading over this and got interested. Why don't you just use environment modules? Utilities like appending to environmental variables, manipulating PATHS (PATH, LD_LIBRARY_PATH, etc), and defining aliases are exactly what modules are for. EasyBuild should fit a lot of what you are looking for. We are using a very similar workflow on our HPC envirment. Right now we build the environment with the software stack, and upload it to anaconda env. It is then build in its correct location using easybuild, and from the module it is very easy to add environmental variables. ETA - I say HPC, but I also use this to manage software stacks and development environments on servers, and even on my own personal laptop.
LD libraries are already as the root/lib. ETA: I read back over this, and unfortunately I do not think environment modules can be built for windows, but I'm not sure. |
Add support for
jinja2
rendering ofenvironment.yml
files (ifjinja2
is available).When using
jinja2
, on top of the usual template capabilities, you have access to thefollowing variables:
root
: The directory containingenvironment.yml
os
: Python'sos
module.Add support for setting environment variables and aliases in
environment.yml
:Notes: