enhancement proposal : customization of module files #552
enhancement proposal : customization of module files #552tgamblin merged 31 commits intospack:developfrom
Conversation
…ment and apply them later
|
@tgamblin : could you please have a look at the skeleton of the thing and tell me if the overall idea fits what you had in mind? |
|
Looks likes a well-thought out idea so far. Can you please explain more about the use case and the problem(s) it solves? Thanks! |
|
@citibeth One of the most requested features (and one that we need at our site) is the possibility to 'customize' the modulefiles that are written after a successfull installation. The customizations in which I am interested here will consist in the addition of new entries and/or in the modification of the usual entries that are added via automatic discovery of some standard directories. Also, these customizations may happen either per-package (most part of the cases) or per site. As an example of a per-package customization you may think of an MPICH installation that could set To reach the goal without creating a tight coupling among different parts of
|
lib/spack/spack/modules.py
Outdated
| env.prepend_path(variable, absolute_path) | ||
|
|
||
| env, inspector = EnvironmentModifications(), PathInspector() | ||
| os.path.walk(path, inspector, env) |
There was a problem hiding this comment.
Do you really want to walk the whole prefix? For most of these I think just checking at the top level would be fine. For pkgconfig, there are a few standard locations you could check (lib/pkgconfig, lib64/pkgconfig) but I'm not sure you wan to grab all of them unconditionally. I think for some packages this might pick up stuff you don't want, like tests and such. I would leave adding the deeper directories to the package implementor --- they can extend it if they want.
There was a problem hiding this comment.
@tgamblin Ok, will restore the previous logic. It seems in fact better to leave the responsibility of adding non-standard directories to the package maintainer.
|
@alalazo: ok I went over this. It looks really good! I like the design; I think this is definitely the right direction. High level, my comments are basically:
I think that is it. Thanks! |
|
@tgamblin I think I am done with the comments of your review. If you like the approach above I'll just clean the few By the way, thanks for taking the time to review the code : I see that it's a one versus many battle and I imagine it's taking some effort! |
lib/spack/spack/cmd/uninstall.py
Outdated
| tty.error("Will not uninstall %s" % e.spec.format("$_$@$%@$#", color=True)) | ||
| print "The following packages depend on it:" | ||
| print() |
There was a problem hiding this comment.
@alalazo: this prints () in Python 2.7.11. I think it has to be print('')
…/env_objects_flying_around Conflicts: lib/spack/spack/package.py var/spack/repos/builtin/packages/netlib-scalapack/package.py
|
@alalazo: I just pushed a branch with some additions to this that I think makes the interface a bit cleaner and avoids the need to patch anything. It's in Basically the interface looks like this now: def setup_environment(self, spack_env, run_env)
def setup_dependent_environment(self, spack_env, run_env, dependent_spec)
def setup_dependent_python_module(self, module, dependent_spec)The intent is to make it clear when we're modifying the compile environment and when we're modifying the runtime/module environment. To make it clear, the two env methods have two environment module objects:
I also tried to rename Anyway, see what you think. I think separating this a little more makes the code more clear and avoids the need to patch. PS: I wish Github let us both iterate on the same PR. Do you know if that is possible? I do not see how I could commit to the PR branch. Bitbucket is kind of nicer in this regard b/c it has better branch permissions and you can interact with collaborators on a branch within the main repo. |
|
@tgamblin I really like passing two different environments, in particular as it permits to avoid monkey patching the code (a behavior which would not have been obvious from user perspective). I also think that all the modifications to There are a few thoughts / remarks that I would like to share :
If you agree |
|
@tgamblin It seems that also edits to older messages are not notified to me. I just saw accidentaly your PS above (and that's kind of a shame, as I edit constantly my posts). If it may work for you, I've issued an invitation to our organization so to let you being able to push on PR branches. |
|
@tgamblin On a second thought having both calls may be indeed useful. Here's the use case that comes to my mind : |
I think this is useful, although the ORNL folks (@robertdfrench, others) mentioned that they have some more generic prereq logic that they would like to see added. Do you think this capability could be added later if this PR is mostly ready to go? I know @jgalarowicz would appreciate the capabilities that are already in here. Aslo, did you see #498? Is this a decent naming scheme? It would be nice to support @glennpj's use case here, and I think his module names are better than the current builtin ones. |
Yes. Next on my list for module files I have :
and having this PR merged would surely help to proceed.
Ok. |
|
@alalazo: awesome! So is this one ready to be merged? |
|
@tgamblin Yes, the only detail I am wondering is if in |
|
@alalazo: I think the Python package should probably iterate only on extendees, but I don't think we should add another callback function for that. Packagers can call |
|
@tgamblin Ok then. Merge! 😄 |
…around enhancement proposal : customization of module files
|
Thanks for all the work on modules! |
|
@robertdfrench @jgalarowicz: you should be able to add some variables to the generated module files now. |
|
TODO: docs. |
|
Oops -- forgot to merge my changes here. Sigh. I'll put those in. |
|
@tgamblin Eheh, I thought you decided to merge this and then your changes from llnl branch... |
|
Fixed. |
…pendent_package
- Fixed in package.py
- Fixed wrong prototypes in packages that use it.
- Fixed build_environment to set module variables properly
- added hacky fix to ensure spec/package consistency in build processes.
- Need to think about defensive spec copy done by `Repo.get`. May be
time to think about an immutable spec implementation.
Objective
Being able to customize what gets written in a module file
TLDR
Currently the modifications that gets written in a module file are:
These modifications are obtained inspecting
pkg.prefixaccording to the same set of rules for every package. I would like to extend this process allowing:Current Status
Examples of use
openmpiandmpichpackages in this PR set the environment variables for compiler wrappers differently depending on whether they are used as a dependency during an installation or outside of spack via module filesDetails
The biggest change done in this PR is the introduction of a class (
EnvironmentModifications) to manage environment modifications both during install and module file creation. An object of this class is essentially a FIFO queue containing requests to modify the environment. Those requests can be executed at a later time and from a scope other than where they were created (in which case the environment is modified and the list is cleared.)Alternatively the requests can be inspected and processed. This is what is done during module file creation when each module file writer (
TclModule,Dotkit) maps each single request to a formatted line and writes that line to a file.An interesting side effect of this design is the possibility to inspect the whole set of requests done by different packages before applying them. This could permit to reveal inconsistencies (e.g. variables that are set by a package and unset by another) and output diagnostic messages to the user.