forked from nexB/scancode-toolkit
/
configure
executable file
·102 lines (79 loc) · 3.03 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# ScanCode is a trademark of nexB Inc.
# See https://github.com/nexB/scancode-toolkit for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
set -e
if [[ "$OS" == "Windows_NT" ]]; then
echo "You seem to be running on Windows under Cygwin / MSYS(2),"
echo "like e.g. Git for Windows Bash. This script does not properly work in"
echo "this scenario. As a Windows user, please run 'configure.bat' from a "
echo "regular command prompt instead."
exit 1
fi
################################
# A configuration script to set things up: create a virtualenv and install
# update thirdparty packages
function cli_help {
echo An initial configuration script
echo " usage: ./configure [options]"
echo
echo The default is to configure for regular use.
echo The script will attempt to find a suitable Python executable.
echo Set the PYTHON_EXECUTABLE environment variable to provide your own
echo Python executable path.
echo
echo The options are:
echo "--clean: clean built and installed files and exit."
echo "--dev: configure the environment for development."
echo "--help: display these help messages and exit."
echo
set +e
exit
}
################################
# Defaults. Change these variables to customize this script locally
################################
# thirdparty package locations
export THIRDPARTY_DIR="thirdparty"
export THIRDPARTY_LINKS="https://thirdparty.aboutcode.org/pypi"
# requirements used by default or with --dev.
# note the use of constraints with -c
REQUIREMENTS="--editable . --constraint requirements.txt"
DEV_REQUIREMENTS="--editable .[dev] --editable .[packages] --constraint requirements.txt --constraint requirements-dev.txt"
# default supported Python version
if [[ "$CONFIGURE_SUPPORTED_PYTHON" == "" ]]; then
CONFIGURE_SUPPORTED_PYTHON=3.6
fi
################################
# Current directory where this script lives
PROJECT_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# parse command line options
CLI_ARGS="$REQUIREMENTS"
CONFIGURE_DEV_MODE=0
case "$1" in
--help) cli_help;;
--clean) CLI_ARGS=--clean;;
--dev) CLI_ARGS="$DEV_REQUIREMENTS" && CONFIGURE_DEV_MODE=1;;
esac
# find a proper Python to run
if [[ "$CONFIGURE_PYTHON_EXECUTABLE" == "" ]]; then
CONFIGURE_PYTHON_EXECUTABLE=python3
fi
################################
# Setup development mode
if [[ "$CONFIGURE_DEV_MODE" == 1 ]]; then
# Add development tag file to auto-regen license index on file changes
touch $PROJECT_ROOT_DIR/SCANCODE_DEV_MODE
fi
# Run configure scripts proper and activate
$CONFIGURE_PYTHON_EXECUTABLE "$PROJECT_ROOT_DIR/etc/configure.py" $CLI_ARGS
# Activate the virtualenv if it exists
if [[ -f "$PROJECT_ROOT_DIR/bin/activate" ]]; then
source "$PROJECT_ROOT_DIR/bin/activate"
fi
set +e