diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 448bcd3c64dd655c4d4f57d18ffd684231315f27..f496a872523dc13fd5f234e4875c81eb6ca9013c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -121,7 +121,7 @@ pypi: script: - source ${CONDA_ROOT}/etc/profile.d/conda.sh - conda activate bdt - - bdt ci pypi -vv + - bdt ci pypi -vv dist/*.zip dependencies: - build_linux_36 - build_macosx_36 diff --git a/bob/devtools/scripts/ci.py b/bob/devtools/scripts/ci.py index 60f8680773c8d1813ce3cca368e9a175ef7173a9..7a33f5a5c063e3d04de9a678aa953d0a9754ccf6 100644 --- a/bob/devtools/scripts/ci.py +++ b/bob/devtools/scripts/ci.py @@ -143,14 +143,54 @@ def deploy(dry_run): remote_path=remote_path) +@ci.command(epilog=''' +Examples: + + 1. Checks the long description of setup.py (correctly parseable and will + display nicely at PyPI). Notice this step requires the zip python + packages: + + $ bdt ci readme -vv dist/*.zip + +''') +@click.argument('package', required=True, type=click.Path(file_okay=True, + dir_okay=False, exists=True), nargs=-1) +@verbosity_option() +@bdt.raise_on_error +def readme(package): + """Checks setup.py's ``long_description`` syntax + + This program checks the syntax of the contents of the ``long_description`` + field at the package's ``setup()`` function. It verifies it will be + correctly displayed at PyPI. + """ + + for k in package: + + logger.info('Checking python package %s', k) + #twine check dist/*.zip + + from twine.commands.check import check + failed = check(k) + + if failed: + raise RuntimeError('long_description of package %s cannot be ' \ + 'correctly parsed (twine check returned a failure)' % \ + (k,)) + else: + logger.info('Package %s\'s long_description: OK', k) + + @ci.command(epilog=''' Examples: 1. Deploys current build artifacts to the Python Package Index (PyPI): - $ bdt ci pypi -vv + $ bdt ci pypi -vv dist/*.zip ''') +@click.argument('package', required=True, type=click.Path(file_okay=True, + dir_okay=False, exists=True), nargs=-1) @click.option('-d', '--dry-run/--no-dry-run', default=False, help='Only goes through the actions, but does not execute them ' \ '(combine with the verbosity flags - e.g. ``-vvv``) to enable ' \ @@ -180,21 +220,6 @@ def pypi(dry_run): 'You must follow the relevant software disclosure procedures ' \ 'and set this repository to "public" before trying again.' % package) - # finds the package that should be published - zip_glob = os.path.join(os.environ['CI_PROJECT_DIR'], 'dist', '*-*.zip') - zip_files = glob.glob(zip_glob) - - if len(zip_files) == 0: - raise RuntimeError('Cannot find .zip files on the "dist" directory') - - if len(zip_files) > 1: - raise RuntimeError('There are %d .zip files on the "dist" directory: ' \ - '%s - I\'m confused on what to publish to PyPI...' % \ - (len(zip_files), ', '.join(zip_files))) - - logger.info('Deploying python package %s to PyPI', zip_files[0]) - #twine upload --skip-existing --username ${PYPIUSER} --password ${PYPIPASS} - #dist/*.zip from ..constants import CACERT from twine.settings import Settings @@ -207,8 +232,12 @@ def pypi(dry_run): if not dry_run: from twine.commands.upload import upload - upload(settings, zip_files) - logger.info('Deployment to PyPI successful') + + for k in packages: + + logger.info('Deploying python package %s to PyPI', k) + upload(settings, [k]) + logger.info('%s: Deployed to PyPI - OK', k) @ci.command(epilog=''' diff --git a/setup.py b/setup.py index f879c51e2c5cbb99c4d26998e21c83813c053244..f687ff05862e857270484d33a52191c210fe0f2b 100644 --- a/setup.py +++ b/setup.py @@ -57,6 +57,7 @@ setup( 'bdt.ci.cli': [ 'build = bob.devtools.scripts.ci:build', 'deploy = bob.devtools.scripts.ci:deploy', + 'readme = bob.devtools.scripts.ci:readme', 'pypi = bob.devtools.scripts.ci:pypi', ], },