1111# set -x
1212
1313# ###############################
14- # A configuration script to set things up:
14+ # A configuration script to set things up:
1515# create a virtualenv and install or update thirdparty packages.
1616# Source this script for initial configuration
1717# Use configure --help for details
@@ -26,11 +26,11 @@ CLI_ARGS=$1
2626# ###############################
2727
2828# Requirement arguments passed to pip and used by default or with --dev.
29- REQUIREMENTS=" --editable ."
30- DEV_REQUIREMENTS=" --editable .[testing]"
29+ REQUIREMENTS=" --editable . --constraint requirements.txt "
30+ DEV_REQUIREMENTS=" --editable .[testing] --constraint requirements.txt --constraint requirements-dev.txt "
3131
3232# where we create a virtualenv
33- VIRTUALENV_DIR=.
33+ VIRTUALENV_DIR=venv
3434
3535# Cleanable files and directories with the --clean option
3636CLEANABLE="
@@ -39,7 +39,8 @@ CLEANABLE="
3939 bin
4040 Lib
4141 Scripts
42- include"
42+ include
43+ venv"
4344
4445# extra arguments passed to pip
4546PIP_EXTRA_ARGS=" "
@@ -54,9 +55,12 @@ VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz
5455CFG_ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
5556CFG_BIN_DIR=$CFG_ROOT_DIR /$VIRTUALENV_DIR /bin
5657
58+ # Find packages from the local thirdparty directory or from thirdparty.aboutcode.org
59+ PIP_EXTRA_ARGS=" --find-links $CFG_ROOT_DIR /thirdparty --find-links https://thirdparty.aboutcode.org/pypi"
60+
5761
5862# ###############################
59- # Set the quiet flag to empty if not defined
63+ # Set the quiet flag to empty if not defined
6064if [[ " $CFG_QUIET " == " " ]]; then
6165 CFG_QUIET=" "
6266fi
6771# Use environment variables or a file if available.
6872# Otherwise the latest Python by default.
6973if [[ " $PYTHON_EXECUTABLE " == " " ]]; then
70- # check for a file named PYTHON_EXECUTABLE
74+ # check for a file named PYTHON_EXECUTABLE
7175 if [ -f " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" ]; then
7276 PYTHON_EXECUTABLE=$( cat " $CFG_ROOT_DIR /PYTHON_EXECUTABLE" )
7377 else
@@ -82,10 +86,14 @@ cli_help() {
8286 echo " usage: ./configure [options]"
8387 echo
8488 echo The default is to configure for regular use. Use --dev for development.
89+ echo Use the --init option if starting a new project and the project
90+ echo dependencies are not available on thirdparty.aboutcode.org/pypi/
91+ echo and requirements.txt and/or requirements-dev.txt has not been generated.
8592 echo
8693 echo The options are:
8794 echo " --clean: clean built and installed files and exit."
8895 echo " --dev: configure the environment for development."
96+ echo " --init: pull dependencies from PyPI. Used when first setting up a project."
8997 echo " --help: display this help message and exit."
9098 echo
9199 echo By default, the python interpreter version found in the path is used.
@@ -159,12 +167,22 @@ install_packages() {
159167# Main command line entry point
160168CFG_DEV_MODE=0
161169CFG_REQUIREMENTS=$REQUIREMENTS
162-
163- case " $CLI_ARGS " in
164- --help) cli_help;;
165- --clean) clean;;
166- --dev) CFG_REQUIREMENTS=" $DEV_REQUIREMENTS " && CFG_DEV_MODE=1;;
167- esac
170+ NO_INDEX=" --no-index"
171+
172+ # We are using getopts to parse option arguments that start with "-"
173+ while getopts :-: optchar; do
174+ case " ${optchar} " in
175+ -)
176+ case " ${OPTARG} " in
177+ help ) cli_help;;
178+ clean ) clean;;
179+ dev ) CFG_REQUIREMENTS=" $DEV_REQUIREMENTS " && CFG_DEV_MODE=1;;
180+ init ) NO_INDEX=" " ;;
181+ esac ;;
182+ esac
183+ done
184+
185+ PIP_EXTRA_ARGS=" $PIP_EXTRA_ARGS $NO_INDEX "
168186
169187create_virtualenv " $VIRTUALENV_DIR "
170188install_packages " $CFG_REQUIREMENTS "
0 commit comments