Skip to content

Commit e3ed542

Browse files
author
Vasileios Karakasis
authored
Merge pull request #1371 from vkarak/feat/immediate-install
[feat] Add bootstrap script to install dependencies of ReFrame
2 parents 1f97a38 + 4c0d1dd commit e3ed542

File tree

9 files changed

+160
-56
lines changed

9 files changed

+160
-56
lines changed

README.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,37 @@ Users can create their own test hierarchies, create test factories for generatin
2929

3030
## Getting ReFrame
3131

32-
You may install ReFrame directly from [PyPI](https://pypi.org/project/ReFrame-HPC/) through `pip`:
32+
ReFrame is almost ready to run just after you clone it from Github.
33+
All you need is Python 3.6 or above and to run its bootstrap script:
3334

3435
```bash
35-
pip install reframe-hpc
36+
git clone https://github.com/eth-cscs/reframe.git
37+
cd reframe
38+
./bootstrap.sh
39+
./bin/reframe -V
3640
```
3741

38-
ReFrame will be available in your PATH:
42+
### Other installation ways
3943

40-
```bash
41-
reframe -V
42-
```
44+
You can also install ReFrame through the following channels:
4345

44-
Alternatively, and especially if you want to contribute back to the framework, you may clone this repository:
46+
- Through [PyPI](https://pypi.org/project/ReFrame-HPC/):
4547

46-
```bash
47-
git clone https://github.com/eth-cscs/reframe.git
48-
cd reframe
49-
./bin/reframe -V
50-
```
48+
```
49+
pip install reframe-hpc
50+
```
51+
52+
- Through [Spack](https://spack.io/):
53+
54+
```
55+
spack install reframe
56+
```
57+
58+
- Through [EasyBuild](https://easybuild.readthedocs.io/):
59+
60+
```
61+
eb easybuild/easyconfigs/r/ReFrame/ReFrame-VERSION.eb -r
62+
```
5163

5264
Finally, you may access all previous versions of ReFrame [here](https://github.com/eth-cscs/reframe/releases).
5365

@@ -57,24 +69,22 @@ Finally, you may access all previous versions of ReFrame [here](https://github.c
5769
You may find the official documentation of the latest release and the current master in the following links:
5870

5971
- [Latest release](https://reframe-hpc.readthedocs.io/en/stable)
60-
- [Current master](https://reframe-hpc.readthedocs.io)
72+
- [Current master](https://reframe-hpc.readthedocs.io/en/latest)
6173

6274

6375
### Building the documentation locally
6476

65-
You may build the documentation of the master locally either with Python 2 or Python 3.
66-
Here is how to do it:
77+
You may build the documentation of the master manually as follows:
6778

6879
```
69-
pip install -r docs/requirements.txt
70-
make -C docs latest
80+
./bootstrap.sh +docs
7181
```
7282

7383
For viewing it, you may do the following:
7484

7585
```
7686
cd docs/html
77-
python -m http.server # or python -m SimpleHTTPServer for Python 2
87+
python3 -m http.server
7888
```
7989

8090
The documentation is now up on [localhost:8000](http://localhost:8000), where you can navigate with your browser.

bin/reframe

Lines changed: 0 additions & 1 deletion
This file was deleted.

bin/reframe

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright 2016-2020 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
4+
# ReFrame Project Developers. See the top-level LICENSE file for details.
5+
#
6+
# SPDX-License-Identifier: BSD-3-Clause
7+
8+
import os
9+
import sys
10+
11+
prefix = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
12+
external = os.path.join(prefix, 'external')
13+
sys.path = [prefix, external] + sys.path
14+
15+
16+
import reframe.frontend.cli as cli # noqa: F401, F403
17+
18+
if __name__ == '__main__':
19+
cli.main()

bootstrap.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2016-2020 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
4+
# ReFrame Project Developers. See the top-level LICENSE file for details.
5+
#
6+
# SPDX-License-Identifier: BSD-3-Clause
7+
8+
#
9+
# Bootstrap script for running ReFrame from source
10+
#
11+
12+
BLUE='\033[0;34m'
13+
GREEN='\033[0;32m'
14+
YELLOW='\033[0;33m'
15+
NC='\033[0m'
16+
17+
CMD()
18+
{
19+
echo -e "${BLUE}==>${NC}" ${YELLOW}$*${NC} && $*
20+
}
21+
22+
usage()
23+
{
24+
echo "Usage: $0 [-h] [+docs]"
25+
echo "Bootstrap ReFrame by pulling all its dependencies"
26+
echo " -P EXEC Use EXEC as Python interpreter"
27+
echo " -h Print this help message and exit"
28+
echo " +docs Build also the documentation"
29+
}
30+
31+
32+
while getopts "hP:" opt; do
33+
case $opt in
34+
"P") python=$OPTARG ;;
35+
"h") usage && exit 0 ;;
36+
"?") usage && exit 0 ;;
37+
esac
38+
done
39+
40+
shift $((OPTIND - 1))
41+
if [ -z $python ]; then
42+
python=python3
43+
fi
44+
45+
pyver=$($python -V | sed -n 's/Python \([0-9]\+\)\.\([0-9]\+\)\..*/\1.\2/p')
46+
47+
# Install pip for Python 3
48+
CMD $python -m ensurepip --root external/ --default-pip
49+
50+
# ensurepip installs pip in `external/usr/` whereas the --target option installs
51+
# everything under `external/`. That's why include both in the PYTHONPATH
52+
53+
export PATH=$(pwd)/external/usr/bin:$PATH
54+
export PYTHONPATH=$(pwd)/external:$(pwd)/external/usr/lib/python$pyver/site-packages:$PYTHONPATH
55+
56+
CMD $python -m pip install -q --upgrade pip --target=external/
57+
CMD $python -m pip install -q -r requirements.txt --target=external/ --upgrade
58+
59+
if [ x"$1" == x"+docs" ]; then
60+
CMD $python -m pip install -q -r docs/requirements.txt --target=external/ --upgrade
61+
make -C docs
62+
fi

ci-scripts/ci-runner.bash

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,8 @@ else
132132
module load reframe
133133
fi
134134

135-
# Always install our requirements
136-
python3 -m venv venv.unittests
137-
source venv.unittests/bin/activate
138-
pip install --upgrade pip
139-
pip install -r requirements.txt
140-
141-
# FIXME: XALT is causing linking problems (see UES-823)
142-
module unload xalt
135+
# Bootstrap ReFrame
136+
./bootstrap.sh
143137

144138
echo "[INFO] Loaded Modules"
145139
module list
@@ -216,5 +210,4 @@ else
216210
done
217211
fi
218212
fi
219-
deactivate
220213
exit $CI_EXITCODE

ci-scripts/deploy.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,26 @@ echo "Working directory: $tmpdir ..."
3737
cd $tmpdir
3838
git clone https://github.com/eth-cscs/reframe.git
3939
cd reframe
40-
found_version=$(./reframe.py -V | sed -e 's/ (.*)//g')
40+
./bootstrap.sh
41+
found_version=$(./bin/reframe -V | sed -e 's/ (.*)//g')
4142
if [ $found_version != $version ]; then
4243
echo "$0: version mismatch: found $found_version, but required $version" >&2
4344
exit 1
4445
fi
4546

46-
python3 -m venv venv.deployment
47-
source venv.deployment/bin/activate
48-
pip install --upgrade pip setuptools wheel twine
49-
pip install -r requirements.txt
5047
./test_reframe.py
5148
git tag -a v$version -m "ReFrame $version"
5249
git push origin --tags
53-
python setup.py sdist bdist_wheel
54-
twine upload dist/*
50+
51+
# We need this for running the setup.py of ReFrame
52+
export PYTHONPATH=$(pwd)/external:$PYTHONPATH
53+
54+
# We create a virtual environment here just for the deployment
55+
python3 -m venv venv.deployment
56+
source venv.deployment/bin/activate
57+
python3 -m pip install --upgrade pip setuptools wheel twine
58+
python3 setup.py sdist bdist_wheel
59+
python3 -m twine upload dist/*
5560
deactivate
5661
cd $oldpwd
5762
echo "Deployment was successful!"

docs/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
import sphinx_rtd_theme
3131

32-
sys.path.insert(0, os.path.abspath('..'))
32+
prefix = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
33+
pymajver = sys.version_info.major
34+
pyminver = sys.version_info.minor
35+
external = os.path.join(prefix, 'external')
36+
sys.path = [prefix, external] + sys.path
3337

3438
import reframe # noqa: F401, F403
3539
import reframe.utility.os_ext as os_ext # noqa: F401, F403

docs/started.rst

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ Requirements
77

88
* Python 3.6 or higher.
99
Python 2 is not supported.
10-
* Required Python packages can be found in the ``requirements.txt`` file, which you can install as follows:
11-
12-
.. code:: bash
13-
14-
pip3 install -r requirements.txt
10+
* Required Python packages can be found in the ``requirements.txt`` file.
11+
See :ref:`install-from-source` for more information on how to install ReFrame from source.
1512

1613

1714
---------------------
@@ -63,6 +60,8 @@ ReFrame's latest stable version is available through different channels:
6360
eb easybuild/easyconfigs/r/ReFrame/ReFrame-VERSION.eb -r
6461
6562
63+
.. _install-from-source:
64+
6665
-------------------------------
6766
Getting the Latest and Greatest
6867
-------------------------------
@@ -71,10 +70,23 @@ If you want the latest development version or any pre-release, you can clone ReF
7170

7271
.. code:: bash
7372
74-
git clone https://github.com/eth-cscs/reframe.git
73+
git clone https://github.com/eth-cscs/reframe.git
7574
7675
7776
Pre-release versions are denoted with the ``devX`` suffix and are `tagged <https://github.com/eth-cscs/reframe/releases>`__ in the repository.
77+
Preparing and running ReFrame from source is pretty straightforward:
78+
79+
.. code:: bash
80+
81+
git clone https://github.com/eth-cscs/reframe.git
82+
cd reframe
83+
./bootstrap.sh
84+
./bin/reframe -V
85+
86+
.. note::
87+
.. versionadded:: 3.1
88+
The bootstrap script for ReFrame was added.
89+
For previous ReFrame versions you should install its requirements using ``pip install -r requirements.txt`` in a Python virtual environment.
7890

7991

8092
Running the Unit Tests

reframe.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

test_reframe.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
#
66
# SPDX-License-Identifier: BSD-3-Clause
77

8-
import argparse
98
import os
10-
import pytest
119
import sys
1210

13-
import unittests.fixtures as fixtures
11+
prefix = os.path.abspath(os.path.dirname(__file__))
12+
external = os.path.join(prefix, 'external')
13+
sys.path = [prefix, external] + sys.path
14+
15+
import argparse # noqa: F401, F403
16+
import pytest # noqa: F401, F403
17+
import unittests.fixtures as fixtures # noqa: F401, F403
1418

1519

1620
if __name__ == '__main__':
@@ -38,5 +42,12 @@
3842
fixtures.USER_CONFIG_FILE = options.rfm_user_config
3943
fixtures.USER_SYSTEM = options.rfm_user_system
4044
fixtures.init_runtime()
45+
46+
# If no positional argument is specified, use the `unittests` directory,
47+
# so as to avoid any automatic discovery of random unit tests from the
48+
# external dependencies.
49+
if all(arg.startswith('-') for arg in rem_args):
50+
rem_args.append('unittests')
51+
4152
sys.argv = [sys.argv[0], *rem_args]
4253
sys.exit(pytest.main())

0 commit comments

Comments
 (0)