|
| 1 | +# Pyvarium |
| 2 | + |
| 3 | +Pyvarium is a tool designed to help create environments which are managed by [Spack](github.com/spack/spack/) and a pure python environment manager like [Pipenv](https://pipenv.pypa.io/en/latest/) or [Poetry](https://github.com/python-poetry/poetry). |
| 4 | + |
| 5 | +It aims to help tackle the problem of long term reproducibility and portability of software environments, especially in the area of scientific HPC, by combining the ability of Spack to compile arbitrary software (as long as a package Spack package has been written for it) and flexibility of python environments. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +Simplest installation is with [pipx](https://github.com/pypa/pipx): |
| 10 | + |
| 11 | +```shell |
| 12 | +pipx install pyvarium |
| 13 | +``` |
| 14 | + |
| 15 | +Note that Pyvarium is designed to **manage** Spack and python environments, so an existing spack installation as well as a supported backend (e.g. pipenv) is required for Pyvarium to run. |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +```shell |
| 20 | +$ pyvarium --help |
| 21 | +Usage: pyvarium [OPTIONS] COMMAND [ARGS]... |
| 22 | + |
| 23 | +Deploy mixed computational environments with dependencies and packages provided by Spack and Pipenv |
| 24 | + |
| 25 | +Options: |
| 26 | + --log-level [TRACE|DEBUG|INFO|WARNING|ERROR|CRITICAL] |
| 27 | + Pick which level of output to show |
| 28 | + [default: INFO] |
| 29 | + |
| 30 | + -v, --verbose [default: 0] |
| 31 | + --install-completion Install completion for the current shell. |
| 32 | + --show-completion Show completion for the current shell, to |
| 33 | + copy it or customize the installation. |
| 34 | + |
| 35 | + --help Show this message and exit. |
| 36 | + |
| 37 | +Commands: |
| 38 | + add Add packages via spack or pipenv. |
| 39 | + config Modify user settings for pyvarium. |
| 40 | + install Concretize and install an existing environment. |
| 41 | + modulegen Generate modulefile to load the environment. |
| 42 | + new Create a new combined Spack and Pipenv environment. |
| 43 | + sync Sync Spack-managed packages with Pipenv. |
| 44 | +``` |
| 45 | + |
| 46 | +To create a new environment: |
| 47 | + |
| 48 | +``` |
| 49 | +$ pyvarium new ./environment-demo |
| 50 | +``` |
| 51 | + |
| 52 | +This creates a new directory `./environment-demo` which has Pipenv (`Pipfile`, `Pipfile.lock`) and Spack (`spack.yaml`, `spack.lock`) environment specification files in it. By default these will only specify `python` and `pip` as requirements. |
| 53 | + |
| 54 | +In general setting up the environment should be done in a specific order, you must install any python packages which have **external dependencies** via Spack **first**, then install any required pure python packages via pipenv afterwards. Otherwise python packages with external dependencies will use their bundled binaries instead of whatever is provided via spack. |
| 55 | + |
| 56 | + |
| 57 | +Installation of dependencies can be done with `pyvarium add {spack,pipenv}`, this command is a wrapper around the respective add/install commands which ensures that the dependencies specified by both programs remain in sync: |
| 58 | + |
| 59 | +```shell |
| 60 | +$ pyvarium add spack py-numpy py-h5py |
| 61 | +$ pyvarium add pipenv extra-data |
| 62 | +``` |
| 63 | + |
| 64 | +The above commands would install numpy and h5py via spack, compiling dependencies along the way, sync these packages with `Pipfile` so that pipenv is aware of what is already within the environment, and then install any specified packages via pipenv. |
| 65 | + |
| 66 | +The environment can be activated as a normal venv with `source .venv/bin/activate`, or a module file can be created for it with with `pyvarium modulegen`. |
| 67 | + |
| 68 | +## Usage |
| 69 | + |
| 70 | +```shell |
| 71 | +Usage: pyvarium [OPTIONS] COMMAND [ARGS]... |
| 72 | + |
| 73 | + Deploy mixed computational environments with dependencies and packages provided by Spack and Pipenv |
| 74 | + |
| 75 | +╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮ |
| 76 | +│ --log-level [TRACE|DEBUG|INFO|WARNING|ERROR|C Pick which level of output to show │ |
| 77 | +│ RITICAL] [default: LogLevel.info] │ |
| 78 | +│ --install-completion Install completion for the current │ |
| 79 | +│ shell. │ |
| 80 | +│ --show-completion Show completion for the current │ |
| 81 | +│ shell, to copy it or customize the │ |
| 82 | +│ installation. │ |
| 83 | +│ --help Show this message and exit. │ |
| 84 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 85 | +╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────╮ |
| 86 | +│ add Add packages via spack or pipenv. │ |
| 87 | +│ config Modify user settings for pyvarium. │ |
| 88 | +│ install Concretize and install an existing environment. │ |
| 89 | +│ modulegen Generate modulefile to load the environment. │ |
| 90 | +│ new Create a new combined Spack and Pipenv environment. │ |
| 91 | +│ sync Sync Spack-managed packages with Pipenv. │ |
| 92 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 93 | +``` |
| 94 | + |
| 95 | +### `config` |
| 96 | + |
| 97 | +```shell |
| 98 | +Usage: pyvarium config [OPTIONS] COMMAND [ARGS]... |
| 99 | + |
| 100 | + Modify user settings for pyvarium. |
| 101 | + |
| 102 | +╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮ |
| 103 | +│ --help Show this message and exit. │ |
| 104 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 105 | +╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────╮ |
| 106 | +│ info Show information about the current configuration. │ |
| 107 | +│ list List configuration. │ |
| 108 | +│ set Set a key value pair for configuration, e.g. `pyvarium set poetry_exec │ |
| 109 | +│ /opt/poetry/bin/poetry`. │ |
| 110 | +│ unset Remove a custom settings from configuration (this reverts to the default, to disable a │ |
| 111 | +│ default set it to an empty string, e.g. `pyvarium set poetry_exec ""`). │ |
| 112 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 113 | +``` |
| 114 | + |
| 115 | +`info` will show the absolute location of the configuration files being used, in the order they are loaded. |
| 116 | + |
| 117 | +`list` shows the current configuration. |
| 118 | + |
| 119 | +`set` can be used to set a key-value pair, and `unset` can be used to remove one. Setting and unsetting configurations can be performed at different scopes: `local` for the local directory (e.g. creating a `pyvarium.toml` file), `user` for the user configuration (`~/.config/pyvarium/settings.toml`), and `builtin` to modify the default configuration within the package. |
| 120 | + |
| 121 | +The configuration is a TOML file containing the paths to the executables to be used by pyvarium, for example: |
| 122 | + |
| 123 | +```toml |
| 124 | +pipenv = "/home/roscar/.local/bin/pipenv" |
| 125 | +pipx = "/home/roscar/.local/bin/pipx" |
| 126 | +poetry = "/sbin/poetry" |
| 127 | +spack = "/opt/spack" |
| 128 | +``` |
| 129 | + |
| 130 | +By default, if an entry is not present in the file for one of these programs, it is automatically set to the path of `which $program`. |
| 131 | + |
| 132 | +### `new` |
| 133 | + |
| 134 | +```shell |
| 135 | +Usage: pyvarium new [OPTIONS] PATH COMMAND [ARGS]... |
| 136 | + |
| 137 | + Create a new combined Spack and Pipenv environment. |
| 138 | + |
| 139 | +╭─ Arguments ────────────────────────────────────────────────────────────────────────────────────────╮ |
| 140 | +│ * path DIRECTORY [default: None] [required] │ |
| 141 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 142 | +╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮ |
| 143 | +│ --help Show this message and exit. │ |
| 144 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 145 | +``` |
| 146 | + |
| 147 | +### `add` |
| 148 | + |
| 149 | +```shell |
| 150 | +Usage: pyvarium add [OPTIONS] COMMAND [ARGS]... |
| 151 | + |
| 152 | + Add packages via spack or pipenv. |
| 153 | + |
| 154 | +╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮ |
| 155 | +│ --help Show this message and exit. │ |
| 156 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 157 | +╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────╮ |
| 158 | +│ pipenv │ |
| 159 | +│ spack │ |
| 160 | +╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
| 161 | +``` |
0 commit comments