Skip to content

Commit a2a4ec4

Browse files
authored
Merge pull request #1 from boegel/init
2 parents dc448ca + 30c02bf commit a2a4ec4

File tree

7 files changed

+143
-0
lines changed

7 files changed

+143
-0
lines changed

.github/workflows/test.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
2+
name: Tests for eessi-cli
3+
on: [push, pull_request, workflow_dispatch]
4+
permissions:
5+
contents: read # to fetch code (actions/checkout)
6+
jobs:
7+
ubuntu-minimal:
8+
runs-on: ubuntu-20.04
9+
strategy:
10+
matrix:
11+
python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
12+
steps:
13+
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
14+
- name: set up Python
15+
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
16+
with:
17+
python-version: ${{matrix.python}}
18+
19+
- name: Install eessi-cli
20+
id: install
21+
run: |
22+
export PREFIX=/tmp/$USER/$GITHUB_SHA
23+
pip install --prefix $PREFIX .
24+
echo "export PATH=$PREFIX/bin:$PATH" >> ~/env
25+
echo "export PYTHONPATH=$(ls -d $PREFIX/lib/python*/site-packages)" >> ~/env
26+
27+
- name: Test init (without EESSI mounted)
28+
run: |
29+
source ~/env
30+
eessi init 2>&1 | grep "^ERROR: /cvmfs/software.eessi.io/versions/2023.06 does not exist"
31+
32+
- name: Mount EESSI
33+
uses: eessi/github-action-eessi@e1f8f20638ea417a18d23ab29443ee34794ff900 # v3.1.0
34+
35+
- name: Test init
36+
run: |
37+
source ~/env
38+
eessi init
39+
eval "$(eessi init)"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
dist
3+
*.egg-info

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# EESSI command line interface
2+
3+
`eessi-cli` is a lightweight command line tool to help with using the European Environment for Scientific Software Installaitons (EESSI).
4+
5+
* Website: https://eessi.io
6+
* Documentation: https://eessi.io/docs
7+
* GitHub: https:/github.com/EESSI
8+
9+
10+
## Installation
11+
12+
### From PyPI
13+
14+
```shell
15+
pip install eessi-cli
16+
```
17+
18+
### From source
19+
20+
```shell
21+
pip install .
22+
```
23+
24+
25+
## Usage
26+
27+
### `init` subcommand
28+
29+
Use `eval` and `eessi init` to prepare your session environment for using EESSI.
30+
31+
```shell
32+
eval "$(eessi init)"
33+
```
34+
35+
To see which commands this would evaluate, just run `eessi init`.
36+
37+
38+
## Design goals
39+
40+
* Easy to install and use.
41+
* No dependencies beyond Python 3.6 (or newer) and its standard library.

eessi/__init__.py

Whitespace-only changes.

eessi/cli/init.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# license (SPDX): GPL-2.0-only
2+
#
3+
# authors: Kenneth Hoste (Ghent University)
4+
5+
import os
6+
import sys
7+
8+
9+
def init(_):
10+
"""
11+
Initialize shell environment for using EESSI
12+
"""
13+
eessi_path = os.path.join("/cvmfs", "software.eessi.io", "versions", "2023.06")
14+
if os.path.exists(eessi_path):
15+
print("# Commands to prepare your session environment for using EESSI (https://eessi.io/docs)")
16+
print("# Use eval so commands below are used to set up your environment: eval \"$(eessi init)\"")
17+
print("source /cvmfs/software.eessi.io/versions/2023.06/init/bash")
18+
else:
19+
sys.stderr.write(f"ERROR: {eessi_path} does not exist!\n")
20+
eessi_docs_access = "https://eessi.io/docs/getting_access/is_eessi_accessible"
21+
sys.stderr.write(f"See {eessi_docs_access} for information on how to get access to EESSI.\n")
22+
sys.exit(1)

eessi/cli/main.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# license (SPDX): GPL-2.0-only
2+
#
3+
# authors: Kenneth Hoste (Ghent University)
4+
5+
import argparse
6+
import sys
7+
8+
from eessi.cli.init import init
9+
10+
11+
def main():
12+
parser = argparse.ArgumentParser(prog="eessi", description="EESSI command line utility")
13+
subparsers = parser.add_subparsers(help="Available subcommands")
14+
15+
init_descr = "Initialize shell environment for using EESSI"
16+
parser_init = subparsers.add_parser("init", description=init_descr, help=init_descr)
17+
parser_init.set_defaults(func=init)
18+
19+
args = parser.parse_args(sys.argv[1:])
20+
args.func(args)
21+
22+
23+
if __name__ == "__main__":
24+
main()

setup.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name="eessi-cli",
5+
version="0.0.1",
6+
description="EESSI command line interface",
7+
url="https://github.com/EESSI/eessi-cli",
8+
install_requires=["click>=8.0"],
9+
packages=["eessi/cli"],
10+
entry_points={
11+
"console_scripts": ["eessi=eessi.cli.main:main"],
12+
},
13+
python_requires=">=3.6",
14+
)

0 commit comments

Comments
 (0)