Hatch plugin for use in Modulefiles environments
Project description
hatch_modulefile
This provides automatic modulefile generation for EnvironmentModules. Modulefiles are created with a basic template which:
- Loads any modules listed in
requires
- Sources the activate script of the installed packages (assumes venv installation)
- Sets extra environment variables defined in extra-paths
Table of Contents
Installation
pip install hatch-modulefile
Example
Example use case. Note that requires is a list of modulefiles available on your system through environment modules. Extra paths defines modulefile environment manipulations.
[build.hooks.modulefile] requires = [ "module1/1.0.0", "module2/3.1.2", "module3/2.0.0", ] extra-paths = [ { type="setenv", variable="NUMEXPR_MAX_THREADS", value="8" }, { type="prepend-path", variable="PATH", value="/custom/path" }, ]
This would generate a modulefile which looks like this:
#%Module
# Gets the folder two folders up from this file
set venv [file dirname [file dirname [file dirname [file normalize $ModulesCurrentModulefile/___]]]]
set site_packages [glob $venv/lib/python*/site-packages]
set necessary {
module1/1.0.0
module2/3.1.2
module3/2.0.0
}
foreach mod $necessary {
set splitList [split $mod "/"]
set mod_name [lindex $splitList 0]
if { [ is-loaded $mod_name ] } {
module switch $mod
} else {
module load $mod
}
}
if { [module-info mode load] || [module-info mode switch2] } {
puts stdout "source $venv/bin/activate;"
} elseif { [module-info mode remove] && ![module-info mode switch3] } {
puts stdout "deactivate;"
}
# Extra module path requirements
setenv NUMEXPR_MAX_THREADS 8
prepend-path PATH /custom/path
License
hatch-modulefile
is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hatch_modulefile-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fda066ff9731a45842ebb90a5695c4db8fd2d90420f2b106450360b9ef01b5ee |
|
MD5 | fb7447fb1fab82f6a106f0f5fdaf321c |
|
BLAKE2b-256 | 353992f6455937c5cde62a6554f6e2eec2c3a4f3359e899983122b70dba6ce1d |