Skip to content

Commit ab65b2e

Browse files
authored
Merge pull request aboutcode-org#61 from nexB/add-ci
Add skeleton files to repo
2 parents fdf49a1 + 7f0b49c commit ab65b2e

24 files changed

+708
-54
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore all Git auto CR/LF line endings conversions
2+
* -text
3+
pyproject.toml export-subst

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ venv/
112112
ENV/
113113
env.bak/
114114
venv.bak/
115+
tmp
115116

116117
# Spyder project settings
117118
.spyderproject

.readthedocs.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Where the Sphinx conf.py file is located
9+
sphinx:
10+
configuration: docs/source/conf.py
11+
12+
# Setting the python version and doc build requirements
13+
python:
14+
install:
15+
- method: pip
16+
path: .
17+
extra_requirements:
18+
- docs

.travis.yml

-17
This file was deleted.

AUTHORS.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ The following organizations or individuals have contributed to this repo:
55
- Philippe Ombredanne @ pombredanne
66
- Steven Esser @ majurg
77
- Tushar Goel @ TG1999
8-
8+

CHANGELOG.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Release notes
22
-------------
33
### Version 0.0.1 2020-10-29
44

5-
Initial release
5+
Initial release

MANIFEST.in

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
graft src
2+
3+
include *.LICENSE
4+
include NOTICE
5+
include *.ABOUT
6+
include *.toml
7+
include *.yml
8+
include *.rst
9+
include setup.*
10+
include configure*
11+
include requirements*
12+
include .git*
13+
14+
global-exclude *.py[co] __pycache__ *.*~
15+

NOTICE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) nexB Inc. and others.
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# Visit https://aboutcode.org and https://github.com/nexB/ for support and download.
6+
# ScanCode is a trademark of nexB Inc.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#

README.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
*********
22
Fetchcode
33
*********
4-
It is a library to reliably fetch code via HTTP, FTP and version control systems.
4+
It is a library to reliably fetch code via HTTP, FTP and version control systems.
55

66
Installation
77
############
8-
Clone the repo using
8+
Clone the repo using
99

1010
:code:`git clone https://github.com/nexB/fetchcode`
1111

12-
Then install all the requirements using
12+
Then install all the requirements using
1313

1414
:code:`pip3 install -r requirements.txt`
1515

@@ -33,4 +33,4 @@ Usage of API to fetch HTTP/S and FTP URLs
3333
# 'scheme' scheme of the URL
3434
# 'size' size of the retrieved content in bytes
3535
# 'url' fetched URL
36-
resp = fetch(url = url)
36+
resp = fetch(url = url)

apache-2.0.LICENSE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Apache License
32
Version 2.0, January 2004
43
http://www.apache.org/licenses/
@@ -199,4 +198,4 @@
199198
distributed under the License is distributed on an "AS IS" BASIS,
200199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201200
See the License for the specific language governing permissions and
202-
limitations under the License.
201+
limitations under the License.

azure-pipelines.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
################################################################################
3+
# We use Azure to run the full tests suites on multiple Python 3.x
4+
# on multiple Windows, macOS and Linux versions all on 64 bits
5+
# These jobs are using VMs with Azure-provided Python builds
6+
################################################################################
7+
8+
jobs:
9+
10+
- template: etc/ci/azure-posix.yml
11+
parameters:
12+
job_name: ubuntu16_cpython
13+
image_name: ubuntu-16.04
14+
python_versions: ['3.6', '3.7', '3.8', '3.9']
15+
test_suites:
16+
all: tmp/bin/pytest -vvs
17+
18+
- template: etc/ci/azure-posix.yml
19+
parameters:
20+
job_name: ubuntu18_cpython
21+
image_name: ubuntu-18.04
22+
python_versions: ['3.6', '3.7', '3.8', '3.9']
23+
test_suites:
24+
all: tmp/bin/pytest -n 2 -vvs
25+
26+
- template: etc/ci/azure-posix.yml
27+
parameters:
28+
job_name: ubuntu20_cpython
29+
image_name: ubuntu-20.04
30+
python_versions: ['3.6', '3.7', '3.8', '3.9']
31+
test_suites:
32+
all: tmp/bin/pytest -n 2 -vvs
33+
34+
- template: etc/ci/azure-posix.yml
35+
parameters:
36+
job_name: macos1014_cpython
37+
image_name: macos-10.14
38+
python_versions: ['3.6', '3.7', '3.8', '3.9']
39+
test_suites:
40+
all: tmp/bin/pytest -n 2 -vvs
41+
42+
- template: etc/ci/azure-posix.yml
43+
parameters:
44+
job_name: macos1015_cpython
45+
image_name: macos-10.15
46+
python_versions: ['3.6', '3.7', '3.8', '3.9']
47+
test_suites:
48+
all: tmp/bin/pytest -n 2 -vvs
49+
50+
- template: etc/ci/azure-win.yml
51+
parameters:
52+
job_name: win2016_cpython
53+
image_name: vs2017-win2016
54+
python_versions: ['3.6', '3.7', '3.8', '3.9']
55+
test_suites:
56+
all: tmp\Scripts\pytest -n 2 -vvs
57+
58+
- template: etc/ci/azure-win.yml
59+
parameters:
60+
job_name: win2019_cpython
61+
image_name: windows-2019
62+
python_versions: ['3.6', '3.7', '3.8', '3.9']
63+
test_suites:
64+
all: tmp\Scripts\pytest -n 2 -vvs

configure

+147-22
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,169 @@
11
#!/usr/bin/env bash
22
#
3-
# Copyright (c) nexB Inc. http://www.nexb.com/ - All rights reserved.
3+
# Copyright (c) nexB Inc. and others. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/ for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
48
#
59

610
set -e
711
#set -x
812

9-
# source this script for a basic setup and configuration for local development
13+
################################
14+
# A configuration script to set things up:
15+
# create a virtualenv and install or update thirdparty packages.
16+
# Source this script for initial configuration
17+
# Use configure --help for details
18+
#
19+
# This script will search for a virtualenv.pyz app in etc/thirdparty/virtualenv.pyz
20+
# Otherwise it will download the latest from the VIRTUALENV_PYZ_URL default
21+
################################
22+
CLI_ARGS=$1
1023

11-
CONFIGURE_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
24+
################################
25+
# Defaults. Change these variables to customize this script
26+
################################
1227

28+
# Requirement arguments passed to pip and used by default or with --dev.
29+
REQUIREMENTS="--editable ."
30+
DEV_REQUIREMENTS="--editable .[testing]"
1331

14-
if [[ "$1" == "--clean" ]]; then
15-
rm -rf "$CONFIGURE_ROOT_DIR/tmp"
16-
exit
32+
# where we create a virtualenv
33+
VIRTUALENV_DIR=tmp
34+
35+
# Cleanable files and directories with the --clean option
36+
CLEANABLE="
37+
build
38+
tmp"
39+
40+
# extra arguments passed to pip
41+
PIP_EXTRA_ARGS=" "
42+
43+
# the URL to download virtualenv.pyz if needed
44+
VIRTUALENV_PYZ_URL=https://bootstrap.pypa.io/virtualenv.pyz
45+
################################
46+
47+
48+
################################
49+
# Current directory where this script lives
50+
CFG_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
51+
CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin
52+
53+
54+
################################
55+
# Set the quiet flag to empty if not defined
56+
if [[ "$CFG_QUIET" == "" ]]; then
57+
CFG_QUIET=" "
1758
fi
1859

1960

20-
if [[ "$PYTHON_EXE" == "" ]]; then
21-
PYTHON_EXE=python3
61+
################################
62+
# find a proper Python to run
63+
# Use environment variables or a file if available.
64+
# Otherwise the latest Python by default.
65+
if [[ "$PYTHON_EXECUTABLE" == "" ]]; then
66+
# check for a file named PYTHON_EXECUTABLE
67+
if [ -f "$CFG_ROOT_DIR/PYTHON_EXECUTABLE" ]; then
68+
PYTHON_EXECUTABLE=$(cat "$CFG_ROOT_DIR/PYTHON_EXECUTABLE")
69+
else
70+
PYTHON_EXECUTABLE=python3
71+
fi
2272
fi
2373

2474

25-
function setup {
26-
# create a virtualenv on Python
27-
mkdir -p $CONFIGURE_ROOT_DIR/tmp
28-
wget -O $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz https://bootstrap.pypa.io/virtualenv.pyz
29-
$PYTHON_EXE $CONFIGURE_ROOT_DIR/tmp/virtualenv.pyz $CONFIGURE_ROOT_DIR/tmp
30-
source $CONFIGURE_ROOT_DIR/tmp/bin/activate
31-
$CONFIGURE_ROOT_DIR/tmp/bin/pip install --upgrade pip virtualenv setuptools wheel
75+
################################
76+
cli_help() {
77+
echo An initial configuration script
78+
echo " usage: ./configure [options]"
79+
echo
80+
echo The default is to configure for regular use. Use --dev for development.
81+
echo
82+
echo The options are:
83+
echo " --clean: clean built and installed files and exit."
84+
echo " --dev: configure the environment for development."
85+
echo " --help: display this help message and exit."
86+
echo
87+
echo By default, the python interpreter version found in the path is used.
88+
echo Alternatively, the PYTHON_EXECUTABLE environment variable can be set to
89+
echo configure another Python executable interpreter to use. If this is not
90+
echo set, a file named PYTHON_EXECUTABLE containing a single line with the
91+
echo path of the Python executable to use will be checked last.
92+
set +e
93+
exit
3294
}
3395

3496

35-
setup
97+
clean() {
98+
# Remove cleanable file and directories and files from the root dir.
99+
echo "* Cleaning ..."
100+
for cln in $CLEANABLE;
101+
do rm -rf "${CFG_ROOT_DIR:?}/${cln:?}";
102+
done
103+
set +e
104+
exit
105+
}
36106

37-
$CONFIGURE_ROOT_DIR/tmp/bin/pip install -e .[testing]
38-
$CONFIGURE_ROOT_DIR/tmp/bin/pip install fetchcode
39107

40-
if [ -f "$CONFIGURE_ROOT_DIR/tmp/bin/activate" ]; then
41-
source "$CONFIGURE_ROOT_DIR/tmp/bin/activate"
42-
fi
108+
create_virtualenv() {
109+
# create a virtualenv for Python
110+
# Note: we do not use the bundled Python 3 "venv" because its behavior and
111+
# presence is not consistent across Linux distro and sometimes pip is not
112+
# included either by default. The virtualenv.pyz app cures all these issues.
113+
114+
VENV_DIR="$1"
115+
if [ ! -f "$CFG_BIN_DIR/python" ]; then
116+
117+
mkdir -p "$CFG_ROOT_DIR/$VENV_DIR"
118+
119+
if [ -f "$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz" ]; then
120+
VIRTUALENV_PYZ="$CFG_ROOT_DIR/etc/thirdparty/virtualenv.pyz"
121+
else
122+
VIRTUALENV_PYZ="$CFG_ROOT_DIR/$VENV_DIR/virtualenv.pyz"
123+
wget -O "$VIRTUALENV_PYZ" "$VIRTUALENV_PYZ_URL"
124+
fi
125+
126+
$PYTHON_EXECUTABLE "$VIRTUALENV_PYZ" \
127+
--wheel embed --pip embed --setuptools embed \
128+
--seeder pip \
129+
--never-download \
130+
--no-periodic-update \
131+
--no-vcs-ignore \
132+
$CFG_QUIET \
133+
"$CFG_ROOT_DIR/$VENV_DIR"
134+
fi
135+
}
136+
137+
138+
install_packages() {
139+
# install requirements in virtualenv
140+
# note: --no-build-isolation means that pip/wheel/setuptools will not
141+
# be reinstalled a second time and reused from the virtualenv and this
142+
# speeds up the installation.
143+
# We always have the PEP517 build dependencies installed already.
144+
145+
"$CFG_BIN_DIR/pip" install \
146+
--upgrade \
147+
--no-build-isolation \
148+
$CFG_QUIET \
149+
$PIP_EXTRA_ARGS \
150+
$1
151+
}
152+
153+
154+
################################
155+
# Main command line entry point
156+
CFG_DEV_MODE=0
157+
CFG_REQUIREMENTS=$REQUIREMENTS
158+
159+
case "$CLI_ARGS" in
160+
--help) cli_help;;
161+
--clean) clean;;
162+
--dev) CFG_REQUIREMENTS="$DEV_REQUIREMENTS" && CFG_DEV_MODE=1;;
163+
esac
164+
165+
create_virtualenv "$VIRTUALENV_DIR"
166+
install_packages "$CFG_REQUIREMENTS"
167+
. "$CFG_BIN_DIR/activate"
43168

44-
set +e
169+
set +e

0 commit comments

Comments
 (0)