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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hatch_modulefile-0.1.1.tar.gz.
File metadata
- Download URL: hatch_modulefile-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
731db25f1e650eafbf297473d7299732c334b2735a45906d01e5c85ff5dedc6f
|
|
| MD5 |
cc34712f6cd281bd56bc972657d53667
|
|
| BLAKE2b-256 |
b312693f56dbce18bc8bc4cc48aa70b15d7ac782160f562f8d6c6971e1bb8a21
|
File details
Details for the file hatch_modulefile-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hatch_modulefile-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.26.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fda066ff9731a45842ebb90a5695c4db8fd2d90420f2b106450360b9ef01b5ee
|
|
| MD5 |
fb7447fb1fab82f6a106f0f5fdaf321c
|
|
| BLAKE2b-256 |
353992f6455937c5cde62a6554f6e2eec2c3a4f3359e899983122b70dba6ce1d
|