Skip to content

Commit a261885

Browse files
committed
Fixed #456 - Adapt with the latest skeleton code
- merge with the latest skeleton code - Update configure scripts and documentation Signed-off-by: Chin Yeung Li <[email protected]>
2 parents b483595 + c41196a commit a261885

37 files changed

+5089
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/Lib
1313
/pip-selfcheck.json
1414
/tmp
15+
/venv
1516
.Python
1617
/include
1718
/Include

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ python:
1919
install: ./configure --dev
2020

2121
# Scripts to run at script stage
22-
script: bin/pytest
22+
script: venv/bin/pytest

README.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ identify redistributable source code used in your project to help you comply
2121
with open source licenses conditions.
2222

2323
This version of the AboutCode Toolkit follows the ABOUT specification version 3.2.1 at:
24-
https://github.com/nexB/aboutcode-toolkit/blob/develop/SPECIFICATION.rst
24+
https://aboutcode-toolkit.readthedocs.io/en/latest/specification.html
2525

2626

2727
Build and tests status
@@ -68,9 +68,9 @@ or on windows:
6868
Activate the virtualenv
6969
-----------------------
7070
To activate the virtualenv, run (on posix):
71-
source bin/activate
71+
source venv/bin/activate
7272
or on windows:
73-
bin\\activate
73+
venv\\bin\\activate
7474

7575

7676
Deactivate the virtualenv
@@ -89,9 +89,10 @@ i.e. MAJOR.MINOR.PATCH format
8989
3. PATCH version when making backwards compatible bug fixes.
9090

9191

92-
REFERENCE
93-
---------
94-
See https://aboutcode-toolkit.readthedocs.io/en/latest/reference.html for reference
92+
DOCUMENTATION and REFERENCE
93+
---------------------------
94+
See https://aboutcode-toolkit.readthedocs.io/en/latest/ or documentation and
95+
https://aboutcode-toolkit.readthedocs.io/en/latest/reference.html for reference
9596
on aboutcode-toolkit usage.
9697

9798

about

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
#!/bin/bash
22
#
3-
# Copyright (c) 2015 nexB Inc. http://www.nexb.com/ - All rights reserved.
3+
# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
44
#
55

66
# cd to the root directory
77
ABOUT_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
88
cd "$ABOUT_ROOT_DIR"
99

10-
CONFIGURED_PYTHON=$ABOUT_ROOT_DIR/bin/python
10+
# where we create a virtualenv
11+
VIRTUALENV_DIR=venv
12+
13+
CONFIGURED_PYTHON=$ABOUT_ROOT_DIR/$VIRTUALENV_DIR/bin/python
1114

1215
if [ ! -f "$CONFIGURED_PYTHON" ]; then
1316
echo "* Configuring AboutCode ..."
1417
source $ABOUT_ROOT_DIR/configure
1518
fi
1619

17-
source $ABOUT_ROOT_DIR/bin/activate
1820

19-
$ABOUT_ROOT_DIR/bin/about "$@"
21+
source $ABOUT_ROOT_DIR/$VIRTUALENV_DIR/bin/activate
22+
23+
$ABOUT_ROOT_DIR/$VIRTUALENV_DIR/bin/about "$@"

about.bat

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
set ABOUT_ROOT_DIR=%~dp0
88
cd %ABOUT_ROOT_DIR%
99

10+
# where we create a virtualenv
11+
set VIRTUALENV_DIR=venv
12+
1013
set CMD_LINE_ARGS=
11-
set CONFIGURED_PYTHON=%ABOUT_ROOT_DIR%\Scripts\python.exe
14+
set CONFIGURED_PYTHON=%ABOUT_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts\python.exe
1215

1316
@rem Collect all command line arguments in a variable
1417
:collectarg
@@ -28,8 +31,8 @@ goto about
2831
call %ABOUT_ROOT_DIR%\configure
2932

3033
:about
31-
call %ABOUT_ROOT_DIR%\Scripts\activate
32-
echo %ABOUT_ROOT_DIR%\bin\about %CMD_LINE_ARGS%
33-
%ABOUT_ROOT_DIR%\bin\about %CMD_LINE_ARGS%
34+
call %ABOUT_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts\activate
35+
echo %ABOUT_ROOT_DIR%\%VIRTUALENV_DIR%\bin\about %CMD_LINE_ARGS%
36+
%ABOUT_ROOT_DIR%\%VIRTUALENV_DIR%\bin\about %CMD_LINE_ARGS%
3437

3538
:EOS

azure-pipelines.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,53 @@ jobs:
1313
image_name: ubuntu-16.04
1414
python_versions: ['3.6', '3.7', '3.8', '3.9']
1515
test_suites:
16-
all: bin/pytest -vvs
16+
all: venv/bin/pytest -vvs
1717

1818
- template: etc/ci/azure-posix.yml
1919
parameters:
2020
job_name: ubuntu18_cpython
2121
image_name: ubuntu-18.04
2222
python_versions: ['3.6', '3.7', '3.8', '3.9']
2323
test_suites:
24-
all: bin/pytest -n 2 -vvs
24+
all: venv/bin/pytest -n 2 -vvs
2525

2626
- template: etc/ci/azure-posix.yml
2727
parameters:
2828
job_name: ubuntu20_cpython
2929
image_name: ubuntu-20.04
3030
python_versions: ['3.6', '3.7', '3.8', '3.9']
3131
test_suites:
32-
all: bin/pytest -n 2 -vvs
32+
all: venv/bin/pytest -n 2 -vvs
3333

3434
- template: etc/ci/azure-posix.yml
3535
parameters:
3636
job_name: macos1014_cpython
3737
image_name: macos-10.14
3838
python_versions: ['3.6', '3.7', '3.8', '3.9']
3939
test_suites:
40-
all: bin/pytest -n 2 -vvs
40+
all: venv/bin/pytest -n 2 -vvs
4141

4242
- template: etc/ci/azure-posix.yml
4343
parameters:
4444
job_name: macos1015_cpython
4545
image_name: macos-10.15
4646
python_versions: ['3.6', '3.7', '3.8', '3.9']
4747
test_suites:
48-
all: bin/pytest -n 2 -vvs
48+
all: venv/bin/pytest -n 2 -vvs
4949

5050
- template: etc/ci/azure-win.yml
5151
parameters:
5252
job_name: win2016_cpython
5353
image_name: vs2017-win2016
5454
python_versions: ['3.6', '3.7', '3.8', '3.9']
5555
test_suites:
56-
all: Scripts\pytest -n 2 -vvs
56+
all: venv\Scripts\pytest -n 2 -vvs
5757

5858
- template: etc/ci/azure-win.yml
5959
parameters:
6060
job_name: win2019_cpython
6161
image_name: windows-2019
6262
python_versions: ['3.6', '3.7', '3.8', '3.9']
6363
test_suites:
64-
all: Scripts\pytest -n 2 -vvs
64+
all: venv\Scripts\pytest -n 2 -vvs
65+

configure

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set -e
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
3636
CLEANABLE="
@@ -39,7 +39,8 @@ CLEANABLE="
3939
bin
4040
Lib
4141
Scripts
42-
include"
42+
include
43+
venv"
4344

4445
# extra arguments passed to pip
4546
PIP_EXTRA_ARGS=" "
@@ -54,9 +55,12 @@ VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz
5455
CFG_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5556
CFG_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
6064
if [[ "$CFG_QUIET" == "" ]]; then
6165
CFG_QUIET=" "
6266
fi
@@ -67,7 +71,7 @@ fi
6771
# Use environment variables or a file if available.
6872
# Otherwise the latest Python by default.
6973
if [[ "$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
160168
CFG_DEV_MODE=0
161169
CFG_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

169187
create_virtualenv "$VIRTUALENV_DIR"
170188
install_packages "$CFG_REQUIREMENTS"

configure.bat

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
@rem ################################
2525

2626
@rem # Requirement arguments passed to pip and used by default or with --dev.
27-
set "REQUIREMENTS=--editable ."
28-
set "DEV_REQUIREMENTS=--editable .[testing]"
27+
set "REQUIREMENTS=--editable . --constraint requirements.txt"
28+
set "DEV_REQUIREMENTS=--editable .[testing] --constraint requirements.txt --constraint requirements-dev.txt"
2929

3030
@rem # where we create a virtualenv
31-
set "VIRTUALENV_DIR=."
31+
set "VIRTUALENV_DIR=venv"
3232

3333
@rem # Cleanable files and directories to delete with the --clean option
34-
set "CLEANABLE=build tmp bin Lib Scripts include"
34+
set "CLEANABLE=build tmp bin Lib Scripts include venv"
3535

3636
@rem # extra arguments passed to pip
3737
set "PIP_EXTRA_ARGS= "
@@ -47,6 +47,12 @@ set CFG_ROOT_DIR=%~dp0
4747
set "CFG_BIN_DIR=%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts"
4848

4949

50+
@rem ################################
51+
@rem # Thirdparty package locations and index handling
52+
set "PIP_EXTRA_ARGS=--find-links %CFG_ROOT_DIR%\thirdparty --find-links https://thirdparty.aboutcode.org/pypi" & %INDEX_ARG%
53+
@rem ################################
54+
55+
5056
@rem ################################
5157
@rem # Set the quiet flag to empty if not defined
5258
if not defined CFG_QUIET (
@@ -58,19 +64,26 @@ if not defined CFG_QUIET (
5864
@rem # Main command line entry point
5965
set CFG_DEV_MODE=0
6066
set "CFG_REQUIREMENTS=%REQUIREMENTS%"
61-
62-
if "%1" EQU "--help" (goto cli_help)
63-
if "%1" EQU "--clean" (goto clean)
64-
if "%1" EQU "--dev" (
65-
set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%"
66-
set CFG_DEV_MODE=1
67-
)
68-
if "%1" EQU "--python" (
69-
echo "The --python option is now DEPRECATED. Use the PYTHON_EXECUTABLE environment"
70-
echo "variable instead. Run configure --help for details."
71-
exit /b 0
67+
set "NO_INDEX=--no-index"
68+
69+
:again
70+
if not "%1" == "" (
71+
if "%1" EQU "--help" (goto cli_help)
72+
if "%1" EQU "--clean" (goto clean)
73+
if "%1" EQU "--dev" (
74+
set "CFG_REQUIREMENTS=%DEV_REQUIREMENTS%"
75+
set CFG_DEV_MODE=1
76+
)
77+
if "%1" EQU "--init" (
78+
set "NO_INDEX= "
79+
)
80+
shift
81+
goto again
7282
)
7383

84+
set "PIP_EXTRA_ARGS=%PIP_EXTRA_ARGS% %NO_INDEX%"
85+
86+
7487
@rem ################################
7588
@rem # find a proper Python to run
7689
@rem # Use environment variables or a file if available.
@@ -159,10 +172,14 @@ exit /b 0
159172
echo " usage: configure [options]"
160173
echo " "
161174
echo The default is to configure for regular use. Use --dev for development.
175+
echo Use the --init option if starting a new project and the project
176+
echo dependencies are not available on thirdparty.aboutcode.org/pypi/
177+
echo and requirements.txt and/or requirements-dev.txt has not been generated.
162178
echo " "
163179
echo The options are:
164180
echo " --clean: clean built and installed files and exit."
165181
echo " --dev: configure the environment for development."
182+
echo " --init: pull dependencies from PyPI. Used when first setting up a project."
166183
echo " --help: display this help message and exit."
167184
echo " "
168185
echo By default, the python interpreter version found in the path is used.

0 commit comments

Comments
 (0)