Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
421d175
New repository initialized by cvs2svn.
Feb 28, 2003
5664513
Initial commit
agustinhenze Jul 31, 2013
c7ba5bd
Initial commit
Jun 13, 2017
c83207d
Initial commit
pombredanne Jan 18, 2020
7ab4312
Merge branch 'dlt-master'
pombredanne Jan 18, 2020
77ce5e4
Check for deps in local thirdparty directory #31
JonoYang Aug 31, 2021
fa13562
Merge pull request #32 from nexB/install-from-thirdparty-dir
JonoYang Aug 31, 2021
1bcaaa5
Enforce use of requirements.txt #34
JonoYang Sep 1, 2021
e9067c8
Add scripts from scancode-toolkit/etc/release/ #33
JonoYang Sep 2, 2021
0e1f56b
Normalize license in load_pkginfo_data #33
JonoYang Sep 2, 2021
288532d
Add --init option to configure #33
JonoYang Sep 2, 2021
a5ae4f3
Update README.rst #33
JonoYang Sep 2, 2021
593e237
Use venv as virtual environment directory name #37
JonoYang Sep 3, 2021
9342bc1
Update configure.bat #33
JonoYang Sep 3, 2021
45e4a2a
Add placeholder requirements.txt files #33
JonoYang Sep 3, 2021
944fbae
Handle multiple options in configure #33
JonoYang Sep 3, 2021
3532b22
Fix path to aboutcode in utils_thirdparty.py #33
JonoYang Sep 4, 2021
9c78ddb
Update release notes in README.rst
JonoYang Sep 4, 2021
ebcfb93
Handle ExpressionParseError #33
JonoYang Sep 4, 2021
6ab9c10
Update README.rst
pombredanne Sep 7, 2021
bfdc6ff
Address review comments #33
JonoYang Sep 7, 2021
8583d7f
Merge pull request #39 from nexB/update-skeleton
JonoYang Sep 8, 2021
71d8dad
Update READMEs
JonoYang Sep 8, 2021
d3b8524
Merge pull request #40 from nexB/add-scripts-readme
JonoYang Sep 8, 2021
d2bafb9
Fixed #41 - Handled encoding issue when generating ABOUT files
chinyeungli Sep 15, 2021
c41196a
Merge pull request #42 from nexB/41_fix_encoding_error
chinyeungli Oct 4, 2021
5671563
Treat text files as text
pombredanne Oct 5, 2021
14f6a2d
Add helper to publish files in GH releases
pombredanne Oct 5, 2021
1a2a144
Add code to use curl if wget is not installed
chinyeungli Oct 6, 2021
7aa7d4c
Do not issue warning if thirdparty dir is missing
pombredanne Oct 8, 2021
51d0c5c
Merge pull request #45 from nexB/open-as-text
pombredanne Oct 11, 2021
b46d84f
Handle as_text correctly in cache
pombredanne Oct 11, 2021
255a898
Handle as_text correctly in cache
pombredanne Oct 11, 2021
7b76f4a
Merge origin/as_text-cache
pombredanne Oct 15, 2021
3a5307c
Merge pull request #47 from nexB/as_text-cache
pombredanne Oct 15, 2021
e5833d1
Add support for Python 3.10
pombredanne Oct 18, 2021
0a0ef12
Adopt black style
pombredanne Oct 29, 2021
31ed446
Drop Ubuntu 16 add Python 3.10
pombredanne Oct 29, 2021
00aaa26
Merge pull request #48 from nexB/update-system
pombredanne Oct 29, 2021
2ce7c7a
Disable Python 3.10 tests on macOS 10.14
pombredanne Oct 29, 2021
1fa3699
Merge pull request #49 from nexB/update-system
pombredanne Oct 29, 2021
2cc2c5a
Add code to remove the symlink before creating
chinyeungli Nov 10, 2021
61af9f9
Merge remote-tracking branch 'puppeter/basic' into adopt-vers-spec
pombredanne Nov 23, 2021
6b2320a
Improve handling licenses without scancode
pombredanne Nov 26, 2021
6ccff2b
Add support for deb and rpm containers
pombredanne Nov 26, 2021
6962f8b
Support licenses when ScanCode is not installed
pombredanne Nov 26, 2021
04c5de3
Merge remote-tracking branch 'rubygems/master' into refinements
pombredanne Dec 6, 2021
dd188e4
Merge pull request #14 from nexB/refinements
pombredanne Jan 10, 2022
2f77f97
Improve wheel build
pombredanne Jan 12, 2022
784e701
Aligne with latest ScanCode TK updates
pombredanne Jan 12, 2022
a7c2efd
Do not ignore setup.py
pombredanne Jan 12, 2022
b1dabd8
Update scripts
pombredanne Jan 12, 2022
0fca296
Merge latest skeleton
pombredanne Feb 9, 2022
4004ebe
Do not use pytest 7.0.0 which is buggy
pombredanne Feb 14, 2022
b15b6b7
Update `configure` to work with space in installation path
chinyeungli Feb 17, 2022
311b0a1
Remove echo statement
chinyeungli Feb 17, 2022
5351f0b
automate pypi release on a tag
TG1999 Feb 17, 2022
96b6405
Refine GH Action definition
pombredanne Feb 18, 2022
635df78
Format GH action yaml
pombredanne Feb 18, 2022
6bbeddd
Use verbose name for job
pombredanne Feb 18, 2022
840ccef
Add black codestyle test for skeleton
keshav-space Feb 22, 2022
35af643
Update configure.bat
chinyeungli Feb 23, 2022
70a2d2f
Merge pull request #55 from nexB/configure_for_path_with_spaces_on_wi…
pombredanne Feb 23, 2022
c7084ee
Merge pull request #56 from keshav-space/main
pombredanne Feb 23, 2022
9558c0c
Deprecate windows-2016 images for azure CI
AyanSinhaMahapatra Feb 23, 2022
e19a520
Remove macos 10.14 job from azure-pipelines.yml
JonoYang Mar 1, 2022
cb17d70
Merge pull request #57 from nexB/deprecate-win-2016-ci
JonoYang Mar 1, 2022
7eb4ca8
Merge pull request #58 from nexB/remove-mac-1014
JonoYang Mar 1, 2022
47da14b
Do not use Python 3.6 on Windows 2022 jobs
JonoYang Mar 1, 2022
c4678dc
Merge pull request #59 from nexB/win2022-py36
JonoYang Mar 1, 2022
ad17a42
Deprecate windows-2016 images for azure CI
AyanSinhaMahapatra Feb 23, 2022
cad3164
Remove macos 10.14 job from azure-pipelines.yml
JonoYang Mar 1, 2022
d659e09
Do not use Python 3.6 on Windows 2022 jobs
JonoYang Mar 1, 2022
b408c85
Merge pull request #60 from nexB/update-signoff
pombredanne Mar 4, 2022
c5251f4
Run tests on macOS 11
pombredanne Mar 4, 2022
a118fe7
Align configuration scripts on POSIX and Windows
pombredanne Mar 4, 2022
e810da3
Update README
pombredanne Mar 4, 2022
243f7cb
Refactor and streamline thirdparty utilities
pombredanne Mar 5, 2022
931f610
Cleanup whitespaces
pombredanne Mar 5, 2022
6e43a7a
Add usage instructions to README.rst
JonoYang Mar 9, 2022
ae73ce3
Merge pull request #61 from nexB/update-readme
JonoYang Mar 9, 2022
6238b83
Merge branch 'main' of https://github.com/nexB/skeleton into main
pombredanne Mar 9, 2022
b272e3b
Format code
pombredanne Mar 9, 2022
907e540
Merge pull request #62 from nexB/better-tpp-scripts
pombredanne Mar 9, 2022
1e4d3bc
Reorg setup sections
pombredanne Mar 9, 2022
03d4799
Do not depend on click. Use argparse.
pombredanne Mar 9, 2022
f0d5a29
Correct configure scripts
pombredanne Mar 9, 2022
6ed9983
Remove remnants of configure --init
pombredanne Mar 9, 2022
bf6bbaa
Pytyon 3.6 is not available on Windows 2022
pombredanne Mar 11, 2022
4ab834f
Add long_description_content_type
pombredanne Mar 11, 2022
4ef463f
Run fewer Azure jobs
pombredanne Mar 14, 2022
e921052
Add RTD css templates
AyanSinhaMahapatra Mar 22, 2022
bd2df2a
Add GitHub action for doc build tests
AyanSinhaMahapatra Mar 24, 2022
3e2d801
Fix conf.py to fix doc build
AyanSinhaMahapatra Mar 24, 2022
c76dff4
Merge pull request #63 from nexB/add-rtd-templates
AyanSinhaMahapatra Mar 24, 2022
eb57889
Add docs option in configure
AyanSinhaMahapatra Mar 24, 2022
2841270
Merge pull request #64 from nexB/add-docs-in-configure
AyanSinhaMahapatra Mar 29, 2022
5556e71
Add documentation contribute page
AyanSinhaMahapatra Mar 30, 2022
f3d1fcd
Merge pull request #65 from nexB/add-docs-contrib
AyanSinhaMahapatra Mar 30, 2022
5431ee5
Properly check for existance of thirdparty dir
JonoYang Apr 28, 2022
435e9ee
Merge pull request #66 from nexB/check-for-thirdparty-dir
JonoYang Apr 28, 2022
b02d5d5
Merge remote-tracking branch 'uni/main' into main
pombredanne Apr 29, 2022
c44c442
Improve GH action documentation
pombredanne Apr 29, 2022
99ba101
Use Python 3.9 as a base for actions
pombredanne Apr 29, 2022
00f4fe7
Remove variable from string in fetch_thirdparty.py
JonoYang Apr 29, 2022
5d48c1c
Improve thirdparty scripts
pombredanne May 2, 2022
6a3c5b0
Update thirdparty fetching utilities
pombredanne May 7, 2022
f2c5a48
Merge branch 'master' into latest-skeleton
pombredanne May 9, 2022
39190dc
Merge latest skeleton
pombredanne May 9, 2022
be774ae
Use correct doc settings
pombredanne May 10, 2022
b9cdafa
Remove dep on six
pombredanne May 10, 2022
b11a5ed
Sync config with SCTK
pombredanne May 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update thirdparty fetching utilities
These were buggy in some corner cases.
They have been updated such that:
* --latest-version works.
* we can reliable fetch combinations of wheels and sdists for multiple
  OS combos at once
* we now support macOS universal wheels (for ARM CPUs)

Caching is now simpler: we have essentially a single file-based cache
under .cache. PyPI indexes are fetched and not cached, unless the new
--use-cached-index is used which can be useful when fetching many
thirdparty in a short timeframe.

The first PyPI repository in a list has precendence and we never fetch
from other repositories if we find wheels and sdsists there. This avoid
pounding too much on the self-hosted repo.

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
pombredanne committed May 7, 2022
commit 6a3c5b0b9e351b9c8730836c2db878a1540cbe2a
6 changes: 3 additions & 3 deletions etc/scripts/check_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@click.command()
@click.option(
"-d",
"--dest_dir",
"--dest",
type=click.Path(exists=True, readable=True, path_type=str, file_okay=False),
required=True,
help="Path to the thirdparty directory to check.",
Expand All @@ -35,7 +35,7 @@
)
@click.help_option("-h", "--help")
def check_thirdparty_dir(
dest_dir,
dest,
wheels,
sdists,
):
Expand All @@ -45,7 +45,7 @@ def check_thirdparty_dir(
# check for problems
print(f"==> CHECK FOR PROBLEMS")
utils_thirdparty.find_problems(
dest_dir=dest_dir,
dest_dir=dest,
report_missing_sources=sdists,
report_missing_wheels=wheels,
)
Expand Down
188 changes: 78 additions & 110 deletions etc/scripts/fetch_thirdparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@
"index_urls",
type=str,
metavar="INDEX",
default=utils_thirdparty.PYPI_INDEXES,
default=utils_thirdparty.PYPI_INDEX_URLS,
show_default=True,
multiple=True,
help="PyPI index URL(s) to use for wheels and sources, in order of preferences.",
)
@click.option(
"--use-cached-index",
is_flag=True,
help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.",
)

@click.help_option("-h", "--help")
def fetch_thirdparty(
requirements_files,
Expand All @@ -116,26 +122,34 @@ def fetch_thirdparty(
wheels,
sdists,
index_urls,
use_cached_index,
):
"""
Download to --dest-dir THIRDPARTY_DIR the PyPI wheels, source distributions,
Download to --dest THIRDPARTY_DIR the PyPI wheels, source distributions,
and their ABOUT metadata, license and notices files.

Download the PyPI packages listed in the combination of:
- the pip requirements --requirements REQUIREMENT-FILE(s),
- the pip name==version --specifier SPECIFIER(s)
- any pre-existing wheels or sdsists found in --dest-dir THIRDPARTY_DIR.

Download wheels with the --wheels option for the ``--python-version`` PYVER(s)
and ``--operating_system`` OS(s) combinations defaulting to all supported combinations.
Download wheels with the --wheels option for the ``--python-version``
PYVER(s) and ``--operating_system`` OS(s) combinations defaulting to all
supported combinations.

Download sdists tarballs with the --sdists option.

Generate or Download .ABOUT, .LICENSE and .NOTICE files for all the wheels and sources fetched.
Generate or Download .ABOUT, .LICENSE and .NOTICE files for all the wheels
and sources fetched.

Download wheels and sdists the provided PyPI simple --index-url INDEX(s) URLs.
Download from the provided PyPI simple --index-url INDEX(s) URLs.
"""
if not (wheels or sdists):
print("Error: one or both of --wheels and --sdists is required.")
sys.exit(1)

print(f"COLLECTING REQUIRED NAMES & VERSIONS FROM {dest_dir}")

existing_packages_by_nv = {
(package.name, package.version): package
for package in utils_thirdparty.get_local_packages(directory=dest_dir)
Expand All @@ -151,134 +165,88 @@ def fetch_thirdparty(
required_name_versions.update(nvs)

for specifier in specifiers:
nv = utils_requirements.get_name_version(
nv = utils_requirements.get_required_name_version(
requirement=specifier,
with_unpinned=latest_version,
)
required_name_versions.add(nv)

if latest_version:
names = set(name for name, _version in sorted(required_name_versions))
required_name_versions = {(n, None) for n in names}

if not required_name_versions:
print("Error: no requirements requested.")
sys.exit(1)

if not os.listdir(dest_dir) and not (wheels or sdists):
print("Error: one or both of --wheels and --sdists is required.")
sys.exit(1)

if latest_version:
latest_name_versions = set()
names = set(name for name, _version in sorted(required_name_versions))
for name in sorted(names):
latests = utils_thirdparty.PypiPackage.sorted(
utils_thirdparty.get_package_versions(
name=name, version=None, index_urls=index_urls
)
)
if not latests:
print(f"No distribution found for: {name}")
continue
latest = latests[-1]
latest_name_versions.add((latest.name, latest.version))
required_name_versions = latest_name_versions

if TRACE:
print("required_name_versions:", required_name_versions)
if TRACE_DEEP:
print("required_name_versions:")
for n, v in required_name_versions:
print(f" {n} @ {v}")

# create the environments matrix we need for wheels
environments = None
if wheels:
# create the environments matrix we need for wheels
evts = itertools.product(python_versions, operating_systems)
environments = [utils_thirdparty.Environment.from_pyver_and_os(pyv, os) for pyv, os in evts]

wheels_not_found = {}
sdists_not_found = {}
# iterate over requirements, one at a time
# Collect PyPI repos
repos = []
for index_url in index_urls:
index_url = index_url.strip("/")
existing = utils_thirdparty.DEFAULT_PYPI_REPOS_BY_URL.get(index_url)
if existing:
existing.use_cached_index = use_cached_index
repos.append(existing)
else:
repo = utils_thirdparty.PypiSimpleRepository(
index_url=index_url,
use_cached_index=use_cached_index,
)
repos.append(repo)

wheels_fetched = []
wheels_not_found = []

sdists_fetched = []
sdists_not_found = []

for name, version in sorted(required_name_versions):
nv = name, version
existing_package = existing_packages_by_nv.get(nv)
print(f"Processing: {name} @ {version}")
if wheels:
for environment in environments:
if existing_package:
existing_wheels = list(
existing_package.get_supported_wheels(environment=environment)
)
else:
existing_wheels = None

if existing_wheels:
if TRACE_DEEP:
print(
f"====> Wheels already available: {name}=={version} on: {environment}: {existing_package.wheels!r}"
)
if all(w.is_pure() for w in existing_wheels):
break
else:
continue

if TRACE_DEEP:
print(f"Fetching wheel for: {name}=={version} on: {environment}")

try:
(
fetched_wheel_filenames,
existing_wheel_filenames,
) = utils_thirdparty.download_wheel(
name=name,
version=version,
environment=environment,
dest_dir=dest_dir,
index_urls=index_urls,
)
if TRACE:
if existing_wheel_filenames:
print(
f" ====> Wheels already available: {name}=={version} on: {environment}"
)
for whl in existing_wheel_filenames:
print(f" {whl}")
if fetched_wheel_filenames:
print(f" ====> Wheels fetched: {name}=={version} on: {environment}")
for whl in fetched_wheel_filenames:
print(f" {whl}")

fwfns = fetched_wheel_filenames + existing_wheel_filenames

if all(utils_thirdparty.Wheel.from_filename(f).is_pure() for f in fwfns):
break

except utils_thirdparty.DistributionNotFound as e:
wheels_not_found[f"{name}=={version}"] = str(e)

if sdists:
if existing_package and existing_package.sdist:
if TRACE:
print(
f" ====> Sdist already available: {name}=={version}: {existing_package.sdist!r}"
)
continue

if TRACE:
print(f" Fetching sdist for: {name}=={version}")

try:
fetched = utils_thirdparty.download_sdist(
print(f" ==> Fetching wheel for envt: {environment}")
fwfns = utils_thirdparty.download_wheel(
name=name,
version=version,
environment=environment,
dest_dir=dest_dir,
index_urls=index_urls,
repos=repos,
)
if fwfns:
wheels_fetched.extend(fwfns)
else:
wheels_not_found.append(f"{name}=={version} for: {environment}")
if TRACE:
print(f" NOT FOUND")

if sdists:
if TRACE:
print(f" ==> Fetching sdist: {name}=={version}")
fetched = utils_thirdparty.download_sdist(
name=name,
version=version,
dest_dir=dest_dir,
repos=repos,
)
if fetched:
sdists_fetched.append(fetched)
else:
sdists_not_found.append(f"{name}=={version}")
if TRACE:
if not fetched:
print(
f" ====> Sdist already available: {name}=={version}"
)
else:
print(
f" ====> Sdist fetched: {fetched} for {name}=={version}"
)

except utils_thirdparty.DistributionNotFound as e:
sdists_not_found[f"{name}=={version}"] = str(e)
print(f" NOT FOUND")

if wheels and wheels_not_found:
print(f"==> MISSING WHEELS")
Expand All @@ -291,7 +259,7 @@ def fetch_thirdparty(
print(f" {sd}")

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

# check for problems
Expand Down
22 changes: 11 additions & 11 deletions etc/scripts/gen_pypi_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ class InvalidDistributionFilename(Exception):

def get_package_name_from_filename(filename):
"""
Return the package name extracted from a package ``filename``.
Optionally ``normalize`` the name according to distribution name rules.
Return the normalized package name extracted from a package ``filename``.
Normalization is done according to distribution name rules.
Raise an ``InvalidDistributionFilename`` if the ``filename`` is invalid::

>>> get_package_name_from_filename("foo-1.2.3_rc1.tar.gz")
'foo'
>>> get_package_name_from_filename("foo-bar-1.2-py27-none-any.whl")
>>> get_package_name_from_filename("foo_bar-1.2-py27-none-any.whl")
'foo-bar'
>>> get_package_name_from_filename("Cython-0.17.2-cp26-none-linux_x86_64.whl")
'cython'
>>> get_package_name_from_filename("python_ldap-2.4.19-cp27-none-macosx_10_10_x86_64.whl")
'python-ldap'
>>> get_package_name_from_filename("foo.whl")
Traceback (most recent call last):
...
InvalidDistributionFilename: ...
>>> get_package_name_from_filename("foo.png")
Traceback (most recent call last):
...
InvalidFilePackageName: ...
>>> try:
... get_package_name_from_filename("foo.whl")
... except InvalidDistributionFilename:
... pass
>>> try:
... get_package_name_from_filename("foo.png")
... except InvalidDistributionFilename:
... pass
"""
if not filename or not filename.endswith(dist_exts):
raise InvalidDistributionFilename(filename)
Expand Down
5 changes: 2 additions & 3 deletions etc/scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
aboutcode_toolkit
github-release-retry2
attrs
commoncode
click
requests
saneyaml
romp
pip
setuptools
twine
wheel
wheel
build
19 changes: 9 additions & 10 deletions etc/scripts/utils_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# See https://github.com/nexB/skeleton for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
import os
import re
import subprocess

Expand Down Expand Up @@ -42,23 +41,23 @@ def get_required_name_versions(requirement_lines, with_unpinned=False):
if req_line.startswith("-") or (not with_unpinned and not "==" in req_line):
print(f"Requirement line is not supported: ignored: {req_line}")
continue
yield get_name_version(requirement=req_line, with_unpinned=with_unpinned)
yield get_required_name_version(requirement=req_line, with_unpinned=with_unpinned)


def get_name_version(requirement, with_unpinned=False):
def get_required_name_version(requirement, with_unpinned=False):
"""
Return a (name, version) tuple given a`requirement` specifier string.
Requirement version must be pinned. If ``with_unpinned`` is True, unpinned
requirements are accepted and only the name portion is returned.

For example:
>>> assert get_name_version("foo==1.2.3") == ("foo", "1.2.3")
>>> assert get_name_version("fooA==1.2.3.DEV1") == ("fooa", "1.2.3.dev1")
>>> assert get_name_version("foo==1.2.3", with_unpinned=False) == ("foo", "1.2.3")
>>> assert get_name_version("foo", with_unpinned=True) == ("foo", "")
>>> assert get_name_version("foo>=1.2", with_unpinned=True) == ("foo", ""), get_name_version("foo>=1.2")
>>> assert get_required_name_version("foo==1.2.3") == ("foo", "1.2.3")
>>> assert get_required_name_version("fooA==1.2.3.DEV1") == ("fooa", "1.2.3.dev1")
>>> assert get_required_name_version("foo==1.2.3", with_unpinned=False) == ("foo", "1.2.3")
>>> assert get_required_name_version("foo", with_unpinned=True) == ("foo", "")
>>> assert get_required_name_version("foo>=1.2", with_unpinned=True) == ("foo", ""), get_required_name_version("foo>=1.2")
>>> try:
... assert not get_name_version("foo", with_unpinned=False)
... assert not get_required_name_version("foo", with_unpinned=False)
... except Exception as e:
... assert "Requirement version must be pinned" in str(e)
"""
Expand Down Expand Up @@ -112,7 +111,7 @@ def get_installed_reqs(site_packages_dir):
as a text.
"""
if not os.path.exists(site_packages_dir):
raise Exception(f"site_packages directort: {site_packages_dir!r} does not exists")
raise Exception(f"site_packages directory: {site_packages_dir!r} does not exists")
# Also include these packages in the output with --all: wheel, distribute,
# setuptools, pip
args = ["pip", "freeze", "--exclude-editable", "--all", "--path", site_packages_dir]
Expand Down
Loading