Skip to content

Commit 6cf0585

Browse files
authored
Merge pull request #3046 from nexB/macos-12-test
Improve release scripts #3040
2 parents ffc47b1 + f3e7534 commit 6cf0585

File tree

12 files changed

+485
-141
lines changed

12 files changed

+485
-141
lines changed

.github/workflows/scancode-release.yml

Lines changed: 311 additions & 58 deletions
Large diffs are not rendered by default.

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ Installation
133133
============
134134

135135
Before installing ScanCode make sure that you have installed the prerequisites
136-
properly. This means installing Python 3.98 for x86/64 architectures. (Python 3.7+ is supported).
136+
properly. This means installing Python 3.8 for x86/64 architectures.
137+
We support Python 3.7, 3.8, 3.9 and 3.10.
137138

138139
See `prerequisites <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#prerequisites>`_
139140
for detailed information on the support platforms and Python versions.
140141

141142
There are a few common ways to `install ScanCode <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html>`_.
142143

143-
- **Installation as an application: Install Python 3.9, download a release archive, extract and run**. `This is the recommended installation method.
144+
- **Installation as an application: Install Python 3.8, download a release archive, extract and run**. `This is the recommended installation method.
144145
<https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#installation-as-an-application-downloading-releases>`_
145146

146147
- `Development installation from source code using a git clone

azure-pipelines.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ jobs:
123123
test_suites:
124124
all: venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
125125

126+
- template: etc/ci/azure-posix.yml
127+
parameters:
128+
job_name: macos12_cpython
129+
image_name: macos-12
130+
python_versions: ['3.7', '3.8', '3.9', '3.10']
131+
python_architecture: x64
132+
test_suites:
133+
all: venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
134+
126135
- template: etc/ci/azure-win.yml
127136
parameters:
128137
job_name: win2019_cpython_1
@@ -218,6 +227,14 @@ jobs:
218227
test_suites:
219228
all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e .[dev] && venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
220229

230+
- template: etc/ci/azure-posix.yml
231+
parameters:
232+
job_name: macos12_cpython_latest_from_pip
233+
image_name: macos-12
234+
python_versions: ['3.7', '3.8', '3.9', '3.10']
235+
test_suites:
236+
all: venv/bin/pip install --upgrade-strategy eager --force-reinstall --upgrade -e .[dev] && venv/bin/pytest -n 2 -vvs tests/scancode/test_cli.py
237+
221238
- template: etc/ci/azure-win.yml
222239
parameters:
223240
job_name: win2019_cpython_latest_from_pip

configure

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,16 @@ CLI_ARGS=$1
141141
# Defaults. Change these variables to customize this script
142142
################################
143143

144+
BASE=".[packages]"
145+
BASE_DEV=".[packages,testing]"
146+
if [[ $OSTYPE == 'darwin'* ]]; then
147+
BASE="."
148+
BASE_DEV=".[testing]"
149+
fi
150+
144151
# Requirement arguments passed to pip and used by default or with --dev.
145-
REQUIREMENTS="--editable .[packages] --constraint requirements.txt"
146-
DEV_REQUIREMENTS="--editable .[testing,packages] --constraint requirements.txt --constraint requirements-dev.txt"
152+
REQUIREMENTS="--editable $BASE --constraint requirements.txt --constraint requirements-linux.txt"
153+
DEV_REQUIREMENTS="--editable $BASE_DEV --constraint requirements.txt --constraint requirements-linux.txt --constraint requirements-dev.txt"
147154
DOCS_REQUIREMENTS="--editable .[docs] --constraint requirements.txt"
148155

149156
# where we create a virtualenv

etc/release/scancode_release_tests.py

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99
# See https://aboutcode.org for more information about nexB OSS projects.
1010
#
1111

12-
import hashlib
1312
import os
1413
import shutil
1514
import subprocess
1615
import sys
1716

18-
# TODO: also test a pip install with a find-links option to our new PyPI repo
1917

20-
21-
def run_pypi_smoke_tests(pypi_archive):
18+
def run_pypi_smoke_tests(pypi_archive, venv_prefix="venv/bin/"):
2219
"""
2320
Run basic install and "smoke" scancode tests for a PyPI archive.
2421
"""
2522
# archive is either a wheel or an sdist as in
2623
# scancode_toolkit-21.1.21-py3-none-any.whl or scancode-toolkit-21.1.21.tar.gz
27-
run_command(["pip", "install", pypi_archive + "[full]"])
24+
run_command([venv_prefix + "pip", "install", pypi_archive + "[full]"])
2825

2926
with open("some.file", "w") as sf:
3027
sf.write("license: gpl-2.0")
3128

32-
run_command(["scancode", "-clipeu", "--json-pp", "-", "some.file"])
29+
run_command([venv_prefix + "scancode", "-clipeu", "--json-pp", "-", "some.file"])
3330

3431

3532
def run_app_smoke_tests(app_archive):
@@ -42,36 +39,61 @@ def run_app_smoke_tests(app_archive):
4239
# We split the name on "_" to extract the laft hand side which is name of
4340
# the root directory inside the archive e.g. "scancode-toolkit-21.1.21"
4441
# where the archive gest extracted
45-
extract_dir, _, _py_ver_ext = app_archive.partition("_")
42+
43+
_base, _, fn = app_archive.partition("/")
44+
extract_dir, _, _py_ver_ext = fn.partition("_")
45+
print("run_app_smoke_tests: cwd:", os.getcwd())
46+
print("run_app_smoke_tests:", "extracting archive:", app_archive, "to:", extract_dir)
4647
shutil.unpack_archive(app_archive)
47-
print()
48-
print("cwd:", os.getcwd())
4948

5049
extract_loc = os.path.normpath(os.path.abspath(os.path.expanduser(extract_dir)))
51-
print("extract_loc:", extract_loc)
50+
print("run_app_smoke_tests: extract_loc:", extract_loc)
5251
for f in os.listdir(extract_loc):
5352
print(" ", f)
5453
print()
5554

5655
os.chdir(extract_loc)
5756

57+
print(f"Configuring scancode for release: {app_archive}")
58+
run_command([
59+
os.path.join(extract_loc, "configure"),
60+
])
61+
5862
# minimal tests: update when new scans are available
5963
args = [
6064
os.path.join(extract_loc, "scancode"),
61-
"-clipeu",
65+
"--license",
66+
"--license-text",
67+
"--license-clarity-score",
68+
69+
"--copyright",
70+
"--info",
71+
"--email",
72+
"--url",
73+
"--generated",
74+
75+
"--package",
76+
"--system-package",
77+
78+
"--summary",
79+
"--tallies",
6280
"--classify",
81+
"--consolidate",
82+
6383
"--verbose",
64-
"--json",
65-
"test_scan.json",
66-
"--csv",
67-
"test_scan.csv",
68-
"--html",
69-
"test_scan.html",
70-
"--spdx-tv",
71-
"test_scan.spdx",
72-
"--json-pp",
73-
"-",
74-
os.path.join(extract_loc, "apache-2.0.LICENSE"),
84+
85+
"--yaml", "test_scan.yml",
86+
"--json", "test_scan.json",
87+
"--json-lines", "test_scan.json-lines",
88+
"--csv", "test_scan.csv",
89+
"--html", "test_scan.html",
90+
"--cyclonedx", "test_scan.cdx",
91+
"--cyclonedx-xml", "test_scan.cdx.xml",
92+
"--spdx-tv", "test_scan.spdx",
93+
94+
"--debian", "test_scan.debian.copyright",
95+
"--json-pp", "-",
96+
"apache-2.0.LICENSE"
7597
]
7698

7799
print(f"Testing scancode release: {app_archive}")
@@ -100,18 +122,14 @@ def run_command(args):
100122

101123
if __name__ == "__main__":
102124
args = sys.argv[1:]
103-
action, archive, sha_arch, sha_py = args
104-
105-
with open(archive, "rb") as arch:
106-
current_sha_arch = hashlib.sha256(arch.read()).hexdigest()
107-
assert current_sha_arch == sha_arch
108-
109-
with open(__file__, "rb") as py:
110-
current_sha_py = hashlib.sha256(py.read()).hexdigest()
111-
assert current_sha_py == sha_py
125+
action = args[0]
126+
archive = args[1]
112127

113128
if action == "pypi":
114-
run_pypi_smoke_tests(archive)
115-
else:
116-
# action =='app':
129+
venv_prefix = args[2]
130+
run_pypi_smoke_tests(archive, venv_prefix)
131+
elif action == 'app':
117132
run_app_smoke_tests(archive)
133+
else:
134+
raise Exception("Usage: scancode_release_tests.py <pypi or app> <archive-to-test>")
135+

etc/scripts/fetch_thirdparty.py

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import itertools
1313
import os
1414
import sys
15+
from collections import defaultdict
1516

1617
import click
1718

@@ -110,6 +111,39 @@
110111
is_flag=True,
111112
help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.",
112113
)
114+
@click.option(
115+
"--sdist-only",
116+
"sdist_only",
117+
type=str,
118+
metavar="SDIST",
119+
default=tuple(),
120+
show_default=False,
121+
multiple=True,
122+
help="Package name(s) that come only in sdist format (no wheels). "
123+
"The command will not fail and exit if no wheel exists for these names",
124+
)
125+
@click.option(
126+
"--wheel-only",
127+
"wheel_only",
128+
type=str,
129+
metavar="WHEEL",
130+
default=tuple(),
131+
show_default=False,
132+
multiple=True,
133+
help="Package name(s) that come only in wheel format (no sdist). "
134+
"The command will not fail and exit if no sdist exists for these names",
135+
)
136+
@click.option(
137+
"--no-dist",
138+
"no_dist",
139+
type=str,
140+
metavar="DIST",
141+
default=tuple(),
142+
show_default=False,
143+
multiple=True,
144+
help="Package name(s) that do not come either in wheel or sdist format. "
145+
"The command will not fail and exit if no distribution exists for these names",
146+
)
113147
@click.help_option("-h", "--help")
114148
def fetch_thirdparty(
115149
requirements_files,
@@ -122,6 +156,9 @@ def fetch_thirdparty(
122156
sdists,
123157
index_urls,
124158
use_cached_index,
159+
sdist_only,
160+
wheel_only,
161+
no_dist,
125162
):
126163
"""
127164
Download to --dest THIRDPARTY_DIR the PyPI wheels, source distributions,
@@ -204,58 +241,62 @@ def fetch_thirdparty(
204241
)
205242
repos.append(repo)
206243

207-
wheels_fetched = []
208-
wheels_not_found = []
209-
210-
sdists_fetched = []
211-
sdists_not_found = []
244+
wheels_or_sdist_not_found = defaultdict(list)
212245

213246
for name, version in sorted(required_name_versions):
214247
nv = name, version
215248
print(f"Processing: {name} @ {version}")
216249
if wheels:
217250
for environment in environments:
251+
218252
if TRACE:
219253
print(f" ==> Fetching wheel for envt: {environment}")
220-
fwfns = utils_thirdparty.download_wheel(
254+
255+
fetched = utils_thirdparty.download_wheel(
221256
name=name,
222257
version=version,
223258
environment=environment,
224259
dest_dir=dest_dir,
225260
repos=repos,
226261
)
227-
if fwfns:
228-
wheels_fetched.extend(fwfns)
229-
else:
230-
wheels_not_found.append(f"{name}=={version} for: {environment}")
262+
if not fetched:
263+
wheels_or_sdist_not_found[f"{name}=={version}"].append(environment)
231264
if TRACE:
232265
print(f" NOT FOUND")
233266

234-
if sdists:
267+
if (sdists or
268+
(f"{name}=={version}" in wheels_or_sdist_not_found and name in sdist_only)
269+
):
235270
if TRACE:
236271
print(f" ==> Fetching sdist: {name}=={version}")
272+
237273
fetched = utils_thirdparty.download_sdist(
238274
name=name,
239275
version=version,
240276
dest_dir=dest_dir,
241277
repos=repos,
242278
)
243-
if fetched:
244-
sdists_fetched.append(fetched)
245-
else:
246-
sdists_not_found.append(f"{name}=={version}")
279+
if not fetched:
280+
wheels_or_sdist_not_found[f"{name}=={version}"].append("sdist")
247281
if TRACE:
248282
print(f" NOT FOUND")
249283

250-
if wheels and wheels_not_found:
251-
print(f"==> MISSING WHEELS")
252-
for wh in wheels_not_found:
253-
print(f" {wh}")
284+
mia = []
285+
for nv, dists in wheels_or_sdist_not_found.items():
286+
name, _, version = nv.partition("==")
287+
if name in no_dist:
288+
continue
289+
sdist_missing = sdists and "sdist" in dists and not name in wheel_only
290+
if sdist_missing:
291+
mia.append(f"SDist missing: {nv} {dists}")
292+
wheels_missing = wheels and any(d for d in dists if d != "sdist") and not name in sdist_only
293+
if wheels_missing:
294+
mia.append(f"Wheels missing: {nv} {dists}")
254295

255-
if sdists and sdists_not_found:
256-
print(f"==> MISSING SDISTS")
257-
for sd in sdists_not_found:
258-
print(f" {sd}")
296+
if mia:
297+
for m in mia:
298+
print(m)
299+
raise Exception(mia)
259300

260301
print(f"==> FETCHING OR CREATING ABOUT AND LICENSE FILES")
261302
utils_thirdparty.fetch_abouts_and_licenses(dest_dir=dest_dir, use_cached_index=use_cached_index)

requirements-linux.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packagedcode-msitools==0.101.210706
2+
regipy==3.1.0
3+
rpm-inspector-rpm==4.16.1.3.210404

requirements.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ jaraco.functools==3.5.1
3434
javaproperties==0.8.1
3535
Jinja2==3.1.2
3636
jsonstreams==0.6.0
37-
libfwsi-python==20220123
3837
license-expression==30.0.0
3938
lxml==4.9.1
4039
MarkupSafe==2.1.1
4140
more-itertools==8.13.0
4241
normality==2.3.3
43-
packagedcode-msitools==0.101.210706
4442
packageurl-python==0.10.0
4543
packaging==21.3
4644
parameter-expansion-patched==0.3.1
@@ -61,9 +59,7 @@ pyparsing==3.0.9
6159
pytz==2022.1
6260
PyYAML==6.0
6361
rdflib==6.2.0
64-
regipy==3.0.2
6562
requests==2.28.1
66-
rpm-inspector-rpm==4.16.1.3.210404
6763
saneyaml==0.5.2
6864
six==1.16.0
6965
soupsieve==2.3.2.post1
@@ -72,6 +68,7 @@ text-unidecode==1.3
7268
toml==0.10.2
7369
typecode==30.0.0
7470
typecode-libmagic==5.39.210531
71+
typing-extensions==4.3.0
7572
urllib3==1.26.11
7673
urlpy==0.5
7774
wcwidth==0.2.5

0 commit comments

Comments
 (0)