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
332358for 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-
370395set +e
371396set +x
0 commit comments