Skip to main content

Hatch plugin for use in Modulefiles environments

Project description

hatch_modulefile

PyPI - Version PyPI - Python Version


This provides automatic modulefile generation for EnvironmentModules. Modulefiles are created with a basic template which:

  1. Loads any modules listed in requires
  2. Sources the activate script of the installed packages (assumes venv installation)
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatch_modulefile-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatch_modulefile-0.1.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for hatch_modulefile-0.1.1.tar.gz
Algorithm Hash digest
SHA256 731db25f1e650eafbf297473d7299732c334b2735a45906d01e5c85ff5dedc6f
MD5 cc34712f6cd281bd56bc972657d53667
BLAKE2b-256 b312693f56dbce18bc8bc4cc48aa70b15d7ac782160f562f8d6c6971e1bb8a21

See more details on using hashes here.

File details

Details for the file hatch_modulefile-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_modulefile-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fda066ff9731a45842ebb90a5695c4db8fd2d90420f2b106450360b9ef01b5ee
MD5 fb7447fb1fab82f6a106f0f5fdaf321c
BLAKE2b-256 353992f6455937c5cde62a6554f6e2eec2c3a4f3359e899983122b70dba6ce1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page