Skip to content

Commit b4c76b9

Browse files
committed
Merge remote-tracking branch 'skeleton/main' into main
2 parents 82335cf + 4dc2521 commit b4c76b9

File tree

6 files changed

+118
-43
lines changed

6 files changed

+118
-43
lines changed

.github/workflows/pypi-release.yml

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,83 @@
1-
name: Release library as a PyPI wheel and sdist on GH release creation
1+
name: Create library release archives, create a GH release and publish PyPI wheel and sdist on tag in main branch
2+
3+
4+
# This is executed automatically on a tag in the main branch
5+
6+
# Summary of the steps:
7+
# - build wheels and sdist
8+
# - upload wheels and sdist to PyPI
9+
# - create gh-release and upload wheels and dists there
10+
# TODO: smoke test wheels and sdist
11+
# TODO: add changelog to release text body
12+
13+
# WARNING: this is designed only for packages building as pure Python wheels
214

315
on:
4-
release:
5-
types: [created]
16+
workflow_dispatch:
17+
push:
18+
tags:
19+
- "v*.*.*"
620

721
jobs:
8-
build-and-publish-to-pypi:
22+
build-pypi-distribs:
923
name: Build and publish library to PyPI
1024
runs-on: ubuntu-20.04
25+
26+
steps:
27+
- uses: actions/checkout@master
28+
- name: Set up Python
29+
uses: actions/setup-python@v1
30+
with:
31+
python-version: 3.9
32+
33+
- name: Install pypa/build
34+
run: python -m pip install build --user
35+
36+
- name: Build a binary wheel and a source tarball
37+
run: python -m build --sdist --wheel --outdir dist/
38+
39+
- name: Upload built archives
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: pypi_archives
43+
path: dist/*
44+
45+
46+
create-gh-release:
47+
name: Create GH release
48+
needs:
49+
- build-pypi-distribs
50+
runs-on: ubuntu-20.04
51+
52+
steps:
53+
- name: Download built archives
54+
uses: actions/download-artifact@v3
55+
with:
56+
name: pypi_archives
57+
path: dist
58+
59+
- name: Create GH release
60+
uses: softprops/action-gh-release@v1
61+
with:
62+
draft: true
63+
files: dist/*
64+
65+
66+
create-pypi-release:
67+
name: Create PyPI release
68+
needs:
69+
- create-gh-release
70+
runs-on: ubuntu-20.04
71+
1172
steps:
12-
- uses: actions/checkout@master
13-
- name: Set up Python
14-
uses: actions/setup-python@v1
15-
with:
16-
python-version: 3.9
17-
- name: Install pypa/build
18-
run: python -m pip install build --user
19-
- name: Build a binary wheel and a source tarball
20-
run: python -m build --sdist --wheel --outdir dist/
21-
.
22-
- name: Publish distribution to PyPI
23-
if: startsWith(github.ref, 'refs/tags')
24-
uses: pypa/gh-action-pypi-publish@master
25-
with:
26-
password: ${{ secrets.PYPI_API_TOKEN }}
27-
73+
- name: Download built archives
74+
uses: actions/download-artifact@v3
75+
with:
76+
name: pypi_archives
77+
path: dist
78+
79+
- name: Publish to PyPI
80+
if: startsWith(github.ref, 'refs/tags')
81+
uses: pypa/gh-action-pypi-publish@master
82+
with:
83+
password: ${{ secrets.PYPI_API_TOKEN }}

configure

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ CFG_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5252
CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin
5353

5454

55+
################################
56+
# Install with or without and index. With "--no-index" this is using only local wheels
57+
# This is an offline mode with no index and no network operations
58+
# NO_INDEX="--no-index "
59+
NO_INDEX=""
60+
61+
5562
################################
5663
# Thirdparty package locations and index handling
57-
# Find packages from the local thirdparty directory or from thirdparty.aboutcode.org
58-
if [ -d "$CFG_ROOT_DIR/thirdparty" ]; then
59-
PIP_EXTRA_ARGS="--find-links $CFG_ROOT_DIR/thirdparty"
64+
# Find packages from the local thirdparty directory if present
65+
THIRDPARDIR=$CFG_ROOT_DIR/thirdparty
66+
if [[ "$(echo $THIRDPARDIR/*.whl)x" != "$THIRDPARDIR/*.whlx" ]]; then
67+
PIP_EXTRA_ARGS="$NO_INDEX --find-links $THIRDPARDIR"
6068
fi
61-
PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS --find-links https://thirdparty.aboutcode.org/pypi/simple/links.html"
6269

6370

6471
################################
@@ -183,6 +190,7 @@ while getopts :-: optchar; do
183190
esac
184191
done
185192

193+
186194
PIP_EXTRA_ARGS="$PIP_EXTRA_ARGS"
187195

188196
find_python

configure.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ set "CFG_BIN_DIR=%CFG_ROOT_DIR%\%VIRTUALENV_DIR%\Scripts"
5252

5353
@rem ################################
5454
@rem # Thirdparty package locations and index handling
55-
@rem # Find packages from the local thirdparty directory or from thirdparty.aboutcode.org
55+
@rem # Find packages from the local thirdparty directory
5656
if exist "%CFG_ROOT_DIR%\thirdparty" (
5757
set PIP_EXTRA_ARGS=--find-links "%CFG_ROOT_DIR%\thirdparty"
5858
)
59-
set "PIP_EXTRA_ARGS=%PIP_EXTRA_ARGS% --find-links https://thirdparty.aboutcode.org/pypi/simple/links.html"
6059

6160

6261
@rem ################################
@@ -69,7 +68,6 @@ if not defined CFG_QUIET (
6968
@rem ################################
7069
@rem # Main command line entry point
7170
set "CFG_REQUIREMENTS=%REQUIREMENTS%"
72-
set "NO_INDEX=--no-index"
7371

7472
:again
7573
if not "%1" == "" (

docs/source/conf.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2929
# ones.
3030
extensions = [
31-
'sphinx.ext.intersphinx',
31+
"sphinx.ext.intersphinx",
3232
]
3333

3434
# This points to aboutcode.readthedocs.io
3535
# In case of "undefined label" ERRORS check docs on intersphinx to troubleshoot
3636
# Link was created at commit - https://github.com/nexB/aboutcode/commit/faea9fcf3248f8f198844fe34d43833224ac4a83
3737

3838
intersphinx_mapping = {
39-
'aboutcode': ('https://aboutcode.readthedocs.io/en/latest/', None),
40-
'scancode-workbench': ('https://scancode-workbench.readthedocs.io/en/develop/', None),
39+
"aboutcode": ("https://aboutcode.readthedocs.io/en/latest/", None),
40+
"scancode-workbench": ("https://scancode-workbench.readthedocs.io/en/develop/", None),
4141
}
4242

4343

@@ -62,7 +62,7 @@
6262
# so a file named "default.css" will overwrite the builtin "default.css".
6363
html_static_path = ["_static"]
6464

65-
master_doc = 'index'
65+
master_doc = "index"
6666

6767
html_context = {
6868
"display_github": True,
@@ -72,9 +72,7 @@
7272
"conf_py_path": "/docs/source/", # path in the checkout to the docs root
7373
}
7474

75-
html_css_files = [
76-
'_static/theme_overrides.css'
77-
]
75+
html_css_files = ["_static/theme_overrides.css"]
7876

7977

8078
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.

etc/scripts/fetch_thirdparty.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
is_flag=True,
111111
help="Use on disk cached PyPI indexes list of packages and versions and do not refetch if present.",
112112
)
113-
114113
@click.help_option("-h", "--help")
115114
def fetch_thirdparty(
116115
requirements_files,

etc/scripts/utils_thirdparty.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def download_sdist(name, version, dest_dir=THIRDPARTY_DIR, repos=tuple()):
311311

312312
return fetched_sdist_filename
313313

314+
314315
################################################################################
315316
#
316317
# Core models
@@ -1064,16 +1065,16 @@ def get_sdist_name_ver_ext(filename):
10641065
if version.isalpha():
10651066
return False
10661067

1067-
# non-pep 440 version
1068+
# non-pep 440 version
10681069
if "-" in version:
10691070
return False
10701071

1071-
# single version
1072+
# single version
10721073
if version.isdigit() and len(version) == 1:
10731074
return False
10741075

1075-
# r1 version
1076-
if len(version) == 2 and version[0]=="r" and version[1].isdigit():
1076+
# r1 version
1077+
if len(version) == 2 and version[0] == "r" and version[1].isdigit():
10771078
return False
10781079

10791080
# dotless version (but calver is OK)
@@ -1588,6 +1589,7 @@ def tags(self):
15881589
)
15891590
)
15901591

1592+
15911593
################################################################################
15921594
#
15931595
# PyPI repo and link index for package wheels and sources
@@ -1629,7 +1631,9 @@ class PypiSimpleRepository:
16291631
use_cached_index = attr.ib(
16301632
type=bool,
16311633
default=False,
1632-
metadata=dict(help="If True, use any existing on-disk cached PyPI index files. Otherwise, fetch and cache."),
1634+
metadata=dict(
1635+
help="If True, use any existing on-disk cached PyPI index files. Otherwise, fetch and cache."
1636+
),
16331637
)
16341638

16351639
def _get_package_versions_map(self, name):
@@ -1674,6 +1678,7 @@ def get_package_version(self, name, version=None):
16741678
"""
16751679
if not version:
16761680
versions = list(self._get_package_versions_map(name).values())
1681+
# return the latest version
16771682
return versions and versions[-1]
16781683
else:
16791684
return self._get_package_versions_map(name).get(version)
@@ -1724,7 +1729,9 @@ class LinksRepository:
17241729
use_cached_index = attr.ib(
17251730
type=bool,
17261731
default=False,
1727-
metadata=dict(help="If True, use any existing on-disk cached index files. Otherwise, fetch and cache."),
1732+
metadata=dict(
1733+
help="If True, use any existing on-disk cached index files. Otherwise, fetch and cache."
1734+
),
17281735
)
17291736

17301737
def __attrs_post_init__(self):
@@ -1790,6 +1797,7 @@ def from_url(cls, url=ABOUT_BASE_URL, _LINKS_REPO={}, use_cached_index=False):
17901797
_LINKS_REPO[url] = cls(url=url, use_cached_index=use_cached_index)
17911798
return _LINKS_REPO[url]
17921799

1800+
17931801
################################################################################
17941802
# Globals for remote repos to be lazily created and cached on first use for the
17951803
# life of the session together with some convenience functions.
@@ -1803,6 +1811,7 @@ def get_local_packages(directory=THIRDPARTY_DIR):
18031811
"""
18041812
return list(PypiPackage.packages_from_dir(directory=directory))
18051813

1814+
18061815
################################################################################
18071816
#
18081817
# Basic file and URL-based operations using a persistent file-based Cache
@@ -1953,6 +1962,7 @@ def fetch_and_save(
19531962
fo.write(content)
19541963
return content
19551964

1965+
19561966
################################################################################
19571967
#
19581968
# Functions to update or fetch ABOUT and license files
@@ -2051,7 +2061,9 @@ def get_other_dists(_package, _dist):
20512061
# if has key data we may look to improve later, but we can move on
20522062
if local_dist.has_key_metadata():
20532063
local_dist.save_about_and_notice_files(dest_dir=dest_dir)
2054-
local_dist.fetch_license_files(dest_dir=dest_dir, use_cached_index=use_cached_index)
2064+
local_dist.fetch_license_files(
2065+
dest_dir=dest_dir, use_cached_index=use_cached_index
2066+
)
20552067
continue
20562068

20572069
# lets try to fetch remotely
@@ -2089,7 +2101,9 @@ def get_other_dists(_package, _dist):
20892101
# if has key data we may look to improve later, but we can move on
20902102
if local_dist.has_key_metadata():
20912103
local_dist.save_about_and_notice_files(dest_dir=dest_dir)
2092-
local_dist.fetch_license_files(dest_dir=dest_dir, use_cached_index=use_cached_index)
2104+
local_dist.fetch_license_files(
2105+
dest_dir=dest_dir, use_cached_index=use_cached_index
2106+
)
20932107
continue
20942108

20952109
# try to get data from pkginfo (no license though)
@@ -2107,6 +2121,7 @@ def get_other_dists(_package, _dist):
21072121
lic_errs = "\n".join(lic_errs)
21082122
print(f"Failed to fetch some licenses:: {lic_errs}")
21092123

2124+
21102125
################################################################################
21112126
#
21122127
# Functions to build new Python wheels including native on multiple OSes
@@ -2210,6 +2225,7 @@ def download_wheels_with_pip(
22102225
downloaded = existing ^ set(os.listdir(dest_dir))
22112226
return sorted(downloaded), error
22122227

2228+
22132229
################################################################################
22142230
#
22152231
# Functions to check for problems

0 commit comments

Comments
 (0)