@@ -11,11 +11,13 @@ set -e
11
11
# set -x
12
12
13
13
# ###############################
14
- # A configuration script to set things up:
14
+ # A configuration script to set things up:
15
15
# create a virtualenv and install or update thirdparty packages.
16
16
# Source this script for initial configuration
17
17
# Use configure --help for details
18
18
#
19
+ # NOTE: please keep in sync with Windows script configure.bat
20
+ #
19
21
# This script will search for a virtualenv.pyz app in etc/thirdparty/virtualenv.pyz
20
22
# Otherwise it will download the latest from the VIRTUALENV_PYZ_URL default
21
23
# ###############################
@@ -28,14 +30,13 @@ CLI_ARGS=$1
28
30
# Requirement arguments passed to pip and used by default or with --dev.
29
31
REQUIREMENTS=" --editable .[full] --constraint requirements.txt"
30
32
DEV_REQUIREMENTS=" --editable .[full,testing] --constraint requirements.txt --constraint requirements-dev.txt"
33
+ DOCS_REQUIREMENTS=" --editable .[docs] --constraint requirements.txt"
31
34
32
35
# where we create a virtualenv
33
36
VIRTUALENV_DIR=venv
34
37
35
- # Cleanable files and directories with the --clean option
36
- CLEANABLE="
37
- build
38
- venv"
38
+ # Cleanable files and directories to delete with the --clean option
39
+ CLEANABLE=" build venv"
39
40
40
41
# extra arguments passed to pip
41
42
PIP_EXTRA_ARGS=" "
@@ -50,11 +51,14 @@ VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz
50
51
CFG_ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
51
52
CFG_BIN_DIR=$CFG_ROOT_DIR /$VIRTUALENV_DIR /bin
52
53
54
+
55
+ # ###############################
56
+ # Thirdparty package locations and index handling
53
57
# Find packages from the local thirdparty directory or from thirdparty.aboutcode.org
54
- if [ -f " $CFG_ROOT_DIR /thirdparty" ]; then
55
- PIP_EXTRA_ARGS=" --find-links $CFG_ROOT_DIR /thirdparty "
58
+ if [ -d " $CFG_ROOT_DIR /thirdparty" ]; then
59
+ PIP_EXTRA_ARGS=" --find-links $CFG_ROOT_DIR /thirdparty"
56
60
fi
57
- PIP_EXTRA_ARGS=" $PIP_EXTRA_ARGS --find-links https://thirdparty.aboutcode.org/pypi"
61
+ PIP_EXTRA_ARGS=" $PIP_EXTRA_ARGS --find-links https://thirdparty.aboutcode.org/pypi/simple/links.html "
58
62
59
63
60
64
# ###############################
65
69
66
70
67
71
# ###############################
68
- # find a proper Python to run
72
+ # Find a proper Python to run
69
73
# Use environment variables or a file if available.
70
74
# Otherwise the latest Python by default.
71
- if [[ " $PYTHON_EXECUTABLE " == " " ]]; then
72
- # check for a file named PYTHON_EXECUTABLE
73
- if [ -f " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" ]; then
74
- PYTHON_EXECUTABLE=$( cat " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" )
75
- else
76
- PYTHON_EXECUTABLE=python3
75
+ find_python () {
76
+ if [[ " $PYTHON_EXECUTABLE " == " " ]]; then
77
+ # check for a file named PYTHON_EXECUTABLE
78
+ if [ -f " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" ]; then
79
+ PYTHON_EXECUTABLE=$( cat " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" )
80
+ else
81
+ PYTHON_EXECUTABLE=python3
82
+ fi
77
83
fi
78
- fi
79
-
80
-
81
- # ###############################
82
- cli_help () {
83
- echo An initial configuration script
84
- echo " usage: ./configure [options]"
85
- echo
86
- echo The default is to configure for regular use. Use --dev for development.
87
- echo Use the --init option if starting a new project and the project
88
- echo dependencies are not available on thirdparty.aboutcode.org/pypi/
89
- echo and requirements.txt and/or requirements-dev.txt has not been generated.
90
- echo
91
- echo The options are:
92
- echo " --clean: clean built and installed files and exit."
93
- echo " --dev: configure the environment for development."
94
- echo " --init: pull dependencies from PyPI. Used when first setting up a project."
95
- echo " --help: display this help message and exit."
96
- echo
97
- echo By default, the python interpreter version found in the path is used.
98
- echo Alternatively, the PYTHON_EXECUTABLE environment variable can be set to
99
- echo configure another Python executable interpreter to use. If this is not
100
- echo set, a file named PYTHON_EXECUTABLE containing a single line with the
101
- echo path of the Python executable to use will be checked last.
102
- set +e
103
- exit
104
- }
105
-
106
-
107
- clean () {
108
- # Remove cleanable file and directories and files from the root dir.
109
- echo " * Cleaning ..."
110
- for cln in $CLEANABLE ;
111
- do rm -rf " ${CFG_ROOT_DIR:? } /${cln:? } " ;
112
- done
113
- set +e
114
- exit
115
84
}
116
85
117
86
87
+ # ###############################
118
88
create_virtualenv () {
119
89
# create a virtualenv for Python
120
90
# Note: we do not use the bundled Python 3 "venv" because its behavior and
@@ -145,6 +115,7 @@ create_virtualenv() {
145
115
}
146
116
147
117
118
+ # ###############################
148
119
install_packages () {
149
120
# install requirements in virtualenv
150
121
# note: --no-build-isolation means that pip/wheel/setuptools will not
@@ -161,29 +132,63 @@ install_packages() {
161
132
}
162
133
163
134
135
+ # ###############################
136
+ cli_help () {
137
+ echo An initial configuration script
138
+ echo " usage: ./configure [options]"
139
+ echo
140
+ echo The default is to configure for regular use. Use --dev for development.
141
+ echo
142
+ echo The options are:
143
+ echo " --clean: clean built and installed files and exit."
144
+ echo " --dev: configure the environment for development."
145
+ echo " --help: display this help message and exit."
146
+ echo
147
+ echo By default, the python interpreter version found in the path is used.
148
+ echo Alternatively, the PYTHON_EXECUTABLE environment variable can be set to
149
+ echo configure another Python executable interpreter to use. If this is not
150
+ echo set, a file named PYTHON_EXECUTABLE containing a single line with the
151
+ echo path of the Python executable to use will be checked last.
152
+ set +e
153
+ exit
154
+ }
155
+
156
+
157
+ # ###############################
158
+ clean () {
159
+ # Remove cleanable file and directories and files from the root dir.
160
+ echo " * Cleaning ..."
161
+ for cln in $CLEANABLE ;
162
+ do rm -rf " ${CFG_ROOT_DIR:? } /${cln:? } " ;
163
+ done
164
+ set +e
165
+ exit
166
+ }
167
+
168
+
164
169
# ###############################
165
170
# Main command line entry point
166
- CFG_DEV_MODE=0
167
171
CFG_REQUIREMENTS=$REQUIREMENTS
168
- NO_INDEX=" --no-index"
169
172
170
173
# We are using getopts to parse option arguments that start with "-"
171
174
while getopts :-: optchar; do
172
175
case " ${optchar} " in
173
176
-)
174
177
case " ${OPTARG} " in
175
178
help ) cli_help;;
176
- clean ) clean;;
177
- dev ) CFG_REQUIREMENTS=" $DEV_REQUIREMENTS " && CFG_DEV_MODE=1 ;;
178
- init ) NO_INDEX= " " ;;
179
+ clean ) find_python && clean;;
180
+ dev ) CFG_REQUIREMENTS=" $DEV_REQUIREMENTS " ;;
181
+ docs ) CFG_REQUIREMENTS= " $DOCS_REQUIREMENTS " ;;
179
182
esac ;;
180
183
esac
181
184
done
182
185
183
- PIP_EXTRA_ARGS=" $PIP_EXTRA_ARGS $NO_INDEX "
186
+ PIP_EXTRA_ARGS=" $PIP_EXTRA_ARGS "
184
187
188
+ find_python
185
189
create_virtualenv " $VIRTUALENV_DIR "
186
190
install_packages " $CFG_REQUIREMENTS "
187
191
. " $CFG_BIN_DIR /activate"
188
192
193
+
189
194
set +e
0 commit comments