Skip to content

Commit 6296000

Browse files
authored
Merge pull request #2627 from nexB/release_creation_speed
Improve release creation speed
2 parents 030f398 + 7b8215d commit 6296000

File tree

4 files changed

+179
-92
lines changed

4 files changed

+179
-92
lines changed

configure

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,17 @@ CFG_BIN_DIR=$CFG_ROOT_DIR/$VIRTUALENV_DIR/bin
6767

6868
################################
6969
# scancode-specific: Thirdparty package locations and index handling
70-
# Do we have thirdparty/files? use the mit.LICENSE as a proxy
71-
if [[ -f "$CFG_ROOT_DIR/thirdparty/mit.LICENSE" ]]; then
72-
LINKS=$CFG_ROOT_DIR/thirdparty
70+
if [[ "$PYPI_LINKS" == "" ]]; then
71+
# Do we have thirdparty/files? use the mit.LICENSE as a proxy
72+
if [[ -f "$CFG_ROOT_DIR/thirdparty/mit.LICENSE" ]]; then
73+
LINKS=$CFG_ROOT_DIR/thirdparty
74+
else
75+
LINKS=https://thirdparty.aboutcode.org/pypi
76+
fi
7377
else
74-
LINKS=https://thirdparty.aboutcode.org/pypi
78+
LINKS=$PYPI_LINKS
7579
fi
80+
7681
PIP_EXTRA_ARGS="--no-index --find-links $LINKS"
7782
################################
7883

etc/release/fetch_requirements.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
# See https://github.com/nexB/scancode-toolkit for support or download.
99
# See https://aboutcode.org for more information about nexB OSS projects.
1010
#
11+
import itertools
12+
1113
import click
1214

1315
import utils_thirdparty
14-
import itertools
1516

1617

1718
@click.command()
@@ -63,6 +64,15 @@
6364
is_flag=True,
6465
help='Fetch only the corresponding source distributions.',
6566
)
67+
@click.option('-u', '--remote-links-url',
68+
type=str,
69+
metavar='URL',
70+
default=utils_thirdparty.REMOTE_LINKS_URL,
71+
show_default=True,
72+
help='URL to a PyPI-like links web site. '
73+
'Or local path to a directory with wheels.',
74+
)
75+
6676
@click.help_option('-h', '--help')
6777
def fetch_requirements(
6878
requirements_file,
@@ -73,6 +83,7 @@ def fetch_requirements(
7383
with_about,
7484
allow_unpinned,
7585
only_sources,
86+
remote_links_url=utils_thirdparty.REMOTE_LINKS_URL,
7687
):
7788
"""
7889
Fetch and save to THIRDPARTY_DIR all the required wheels for pinned
@@ -82,7 +93,9 @@ def fetch_requirements(
8293
Also fetch the corresponding .ABOUT, .LICENSE and .NOTICE files together
8394
with a virtualenv.pyz app.
8495
85-
Use exclusively our remote repository (and not PyPI).
96+
Use exclusively wheel not from PyPI but rather found in the PyPI-like link
97+
repo ``remote_links_url`` if this is a URL. Treat this ``remote_links_url``
98+
as a local directory path to a wheels directory if this is not a a URL.
8699
"""
87100

88101
# fetch wheels
@@ -93,23 +106,28 @@ def fetch_requirements(
93106
if not only_sources:
94107
envs = itertools.product(python_versions, operating_systems)
95108
envs = (utils_thirdparty.Environment.from_pyver_and_os(pyv, os) for pyv, os in envs)
109+
96110
for env, reqf in itertools.product(envs, requirements_files):
111+
97112
for package, error in utils_thirdparty.fetch_wheels(
98113
environment=env,
99114
requirements_file=reqf,
100115
allow_unpinned=allow_unpinned,
101116
dest_dir=thirdparty_dir,
117+
remote_links_url=remote_links_url,
102118
):
103119
if error:
104120
print('Failed to fetch wheel:', package, ':', error)
105121

106122
# optionally fetch sources
107123
if with_sources or only_sources:
124+
108125
for reqf in requirements_files:
109126
for package, error in utils_thirdparty.fetch_sources(
110127
requirements_file=reqf,
111128
allow_unpinned=allow_unpinned,
112129
dest_dir=thirdparty_dir,
130+
remote_links_url=remote_links_url,
113131
):
114132
if error:
115133
print('Failed to fetch source:', package, ':', error)

etc/release/scancode-create-release.sh

Lines changed: 83 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
# Create, test and publish release archives, wheels and sdists.
99
# Use the --test to also run basic smoke tests of the built archives
1010
#
11+
# To use a local checkout of https://github.com/nexB/thirdparty-packages/ rather
12+
# than https://thirdparty.aboutcode.org/ set the variable PYPI_LINKS to point
13+
# to your thirdparty-packages/pypi local directory (this speeds up the release
14+
# creation and allow to work mostly offline.
15+
#
1116
################################################################################
1217

1318
# Supported current app Python version and OS
@@ -202,51 +207,36 @@ function clean_build {
202207
clean_egg_info
203208
}
204209

205-
backup_previous_release
206-
clean_build
207-
mkdir release
208-
209-
echo "## RELEASE: Setup environment"
210-
211-
echo "## RELEASE: Clean and configure, then regen license index"
212-
./configure --clean
213-
./configure
214-
source bin/activate
215-
scancode --reindex-licenses
216-
217-
218-
219-
echo "## RELEASE: Install release requirements"
220-
# We do not need a full env for releasing
221-
bin/pip install $QUIET -r etc/release/requirements.txt
222-
223-
224210
################################
225211
# PyPI wheels and sdist: these are not Python version- or OS-dependent
226212
################################
227-
echo " "
228-
echo "## RELEASE: Building a wheel and a source distribution"
229-
clean_egg_info
230-
bin/python setup.py $QUIET sdist bdist_wheel
213+
function build_wheels {
214+
# Build scancode wheels and dist for PyPI
215+
# Arguments:
231216

232-
mv dist release/pypi
217+
echo " "
218+
echo "## RELEASE: Building a wheel and a source distribution"
219+
clean_egg_info
220+
bin/python setup.py $QUIET sdist bdist_wheel
233221

222+
mv dist release/pypi
234223

235-
echo " "
236-
echo "## RELEASE: Building a mini wheel and a source distribution"
237-
clean_egg_info
238-
mv setup.cfg setup-full.cfg
239-
cp setup-mini.cfg setup.cfg
240-
rm -rf build
241-
bin/python setup.py $QUIET sdist bdist_wheel
242-
mv setup-full.cfg setup.cfg
224+
echo " "
225+
echo "## RELEASE: Building a mini wheel and a source distribution"
226+
clean_egg_info
227+
mv setup.cfg setup-full.cfg
228+
cp setup-mini.cfg setup.cfg
229+
rm -rf build
230+
bin/python setup.py $QUIET sdist bdist_wheel
231+
mv setup-full.cfg setup.cfg
243232

244-
cp dist/* release/pypi/
233+
cp dist/* release/pypi/
245234

246-
clean_egg_info
247-
echo "## RELEASE: full and mini, wheel and source distribution(s) built and ready for PyPI upload"
248-
find release -ls
235+
clean_egg_info
236+
echo "## RELEASE: full and mini, wheel and source distribution(s) built and ready for PyPI upload"
237+
find release -ls
249238

239+
}
250240

251241
################################
252242
# Build OSes and Pythons-specific release archives
@@ -268,34 +258,44 @@ function build_app_archive {
268258
echo " "
269259
echo "## RELEASE: Building archive for Python $python_app_version on operating system: $operating_system"
270260

271-
clean_build
272-
mkdir -p thirdparty
273-
274261
if [ "$operating_system" == "windows" ]; then
275262
# create a zip only on Windows
276263
formats=zip
277-
echo -n "py -$python_app_dot_version">PYTHON_EXECUTABLE
264+
formats_ext=.zip
278265
else
279266
formats=xztar
280-
echo -n "python$python_app_dot_version">PYTHON_EXECUTABLE
267+
formats_ext=.tar.xz
281268
fi
282269

283-
# 1. Collect thirdparty deps only for the subset for this Python/operating_system
284-
bin/python etc/release/fetch_requirements.py \
285-
--requirements-file=requirements.txt \
286-
--thirdparty-dir=thirdparty \
287-
--python-version=$python_app_version \
288-
--operating-system=$operating_system \
289-
--with-about
270+
if [ ! -f release/archives/scancode-toolkit-*_py$python_app_version-$operating_system$formats_ext ]; then
271+
clean_build
272+
mkdir -p thirdparty
273+
274+
if [ "$operating_system" == "windows" ]; then
275+
echo -n "py -$python_app_dot_version">PYTHON_EXECUTABLE
276+
else
277+
echo -n "python$python_app_dot_version">PYTHON_EXECUTABLE
278+
fi
279+
280+
# 1. Collect thirdparty deps only for the subset for this Python/operating_system
281+
bin/python etc/release/fetch_requirements.py \
282+
--requirements-file=requirements.txt \
283+
--thirdparty-dir=thirdparty \
284+
--python-version=$python_app_version \
285+
--operating-system=$operating_system \
286+
--with-about \
287+
--remote-links-url=$PYPI_LINKS
288+
289+
# 2. Create tarball or zip.
290+
# For now as a shortcut we use the Python setup.py sdist to create a tarball.
291+
# This is hackish and we should instead use our own archiving code that
292+
# would take a distutils manifest-like input
293+
bin/python setup.py $QUIET sdist --formats=$formats
294+
bin/python etc/release/scancode_rename_archives.py dist/ _py$python_app_version-$operating_system
295+
mkdir -p release/archives
296+
mv dist/* release/archives/
297+
fi
290298

291-
# 2. Create tarball or zip.
292-
# For now as a shortcut we use the Python setup.py sdist to create a tarball.
293-
# This is hackish and we should instead use our own archiving code that
294-
# would take a distutils manifest-like input
295-
bin/python setup.py $QUIET sdist --formats=$formats
296-
bin/python etc/release/scancode_rename_archives.py dist/ _py$python_app_version-$operating_system
297-
mkdir -p release/archives
298-
mv dist/* release/archives/
299299
}
300300

301301

@@ -314,7 +314,8 @@ function build_source_archive {
314314
--requirements-file=requirements.txt \
315315
--thirdparty-dir=thirdparty \
316316
--with-about \
317-
--only-sources
317+
--only-sources \
318+
--remote-links-url=$PYPI_LINKS
318319

319320
# 2. Create tarball
320321
# For now as a shortcut we use the Python setup.py sdist to create a tarball.
@@ -328,6 +329,31 @@ function build_source_archive {
328329
}
329330

330331

332+
if [ "$CLI_ARGS" != "--continue" ]; then
333+
echo "############# Reset release creation #############################"
334+
backup_previous_release
335+
clean_build
336+
mkdir release
337+
338+
echo "## RELEASE: Setup environment"
339+
340+
echo "## RELEASE: Clean and configure, then regen license index"
341+
./configure --clean
342+
PYPI_LINKS=$PYPI_LINKS ./configure --local
343+
source bin/activate
344+
scancode --reindex-licenses
345+
346+
echo "## RELEASE: Install release requirements"
347+
# We do not need a full env for releasing
348+
bin/pip install $QUIET -r etc/release/requirements.txt
349+
else
350+
echo "############# Continuing previous release creation #############################"
351+
fi
352+
353+
354+
# wheels
355+
build_wheels
356+
331357
# build the app combos on the current App Python
332358
for operating_system in $OPERATING_SYSTEMS
333359
do
@@ -366,6 +392,5 @@ echo "### RELEASE is ready for publishing ###"
366392
# ping on chat and twitter
367393
# send email
368394

369-
370395
set +e
371396
set +x

0 commit comments

Comments
 (0)