Mercurial > kallithea
annotate scripts/validate-minimum-dependency-versions @ 8576:a63ccbc632d1
docs: add more section headings to setup description to show how it corresponds to the overview
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 19 Jun 2020 18:24:38 +0200 |
parents | 01aca0a4f876 |
children | 0a9ddb8cd8c1 |
rev | line source |
---|---|
7901
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
1 #!/bin/bash |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
2 # Test that installation of all dependencies works fine if versions are set to |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
3 # the minimum ones. |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
4 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
5 set -e |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
6 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
7 if [ -n "$VIRTUAL_ENV" ]; then |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
8 echo "This script will create its own virtualenv - please don't run it inside an existing one." >&2 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
9 exit 1 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
10 fi |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
11 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
12 cd "$(hg root)" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
13 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
14 venv=build/minimum-dependency-versions-venv |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
15 log=build/minimum-dependency-versions.log |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
16 min_requirements=build/minimum-dependency-versions-requirements.txt |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
17 echo "virtualenv: $venv" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
18 echo "log: $log" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
19 echo "minimum requirements file: $min_requirements" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
20 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
21 # clean up previous runs |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
22 rm -rf "$venv" "$log" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
23 mkdir -p "$venv" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
24 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
25 # Make a light weight parsing of setup.py and dev_requirements.txt, |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
26 # finding all >= requirements and dumping into a custom requirements.txt |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
27 # while fixating the requirement at the lower bound. |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
28 sed -n 's/.*"\(.*\)>=\(.*\)".*/\1==\2/p' setup.py > "$min_requirements" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
29 sed 's/>=/==/p' dev_requirements.txt >> "$min_requirements" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
30 |
8193
89e9aef9b983
py3: use "python3 -m venv" instead of virtualenv package
Mads Kiilerich <mads@kiilerich.com>
parents:
8173
diff
changeset
|
31 python3 -m venv "$venv" |
7901
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
32 source "$venv/bin/activate" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
33 pip install --upgrade pip setuptools |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
34 pip install -e . -r "$min_requirements" python-ldap python-pam 2> >(tee "$log" >&2) |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
35 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
36 # Treat any message on stderr as a problem, for the caller to interpret. |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
37 if [ -s "$log" ]; then |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
38 echo |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
39 echo "Error: pip detected following problems:" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
40 cat "$log" |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
41 echo |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
42 exit 1 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
43 fi |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
44 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
45 freeze_txt=build/minimum-dependency-versions.txt |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
46 pip freeze > $freeze_txt |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
47 echo "Installation of minimum packages was successful, providing a set of packages as in $freeze_txt . Now running test suite..." |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
48 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
49 pytest |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
50 |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
51 echo "Test suite execution was successful." |
ac6cc1b8a07e
scripts: new maintainer script validate-minimum-dependency-versions
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
52 echo "You can now do additional validation using virtual env '$venv'." |