From d147899a3904e8c54c7f138c44b7933083fcbe56 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Mon, 21 Jan 2019 17:45:13 +0100 Subject: [PATCH] [build] Implements twine-check on self (closes #7) --- .gitlab-ci.yml | 5 +++++ bob/devtools/bootstrap.py | 2 ++ bob/devtools/build.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35e25353..6ec7e0f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,6 +57,11 @@ build_linux_36: variables: PYTHON_VERSION: "3.6" BUILD_EGG: "true" + script: + - python3 ./bob/devtools/bootstrap.py -vv build + - source ${CONDA_ROOT}/etc/profile.d/conda.sh + - conda activate base + - python3 ./bob/devtools/build.py -vv --twine-check artifacts: expire_in: 1 week paths: diff --git a/bob/devtools/bootstrap.py b/bob/devtools/bootstrap.py index 96c8e47a..585f0132 100644 --- a/bob/devtools/bootstrap.py +++ b/bob/devtools/bootstrap.py @@ -395,6 +395,7 @@ if __name__ == '__main__': 'python', 'conda=%s' % conda_version, 'conda-build=%s' % conda_build_version, + 'twine', #required for checking readme of python (zip) distro ]) elif args.command == 'local': @@ -404,6 +405,7 @@ if __name__ == '__main__': 'python', 'conda=%s' % conda_version, 'conda-build=%s' % conda_build_version, + 'twine', #required for checking readme of python (zip) distro ]) conda_bld_path = os.path.join(args.conda_root, 'conda-bld') run_cmdline([conda_bin, 'index', conda_bld_path]) diff --git a/bob/devtools/build.py b/bob/devtools/build.py index 6c17ac62..16bfa761 100644 --- a/bob/devtools/build.py +++ b/bob/devtools/build.py @@ -433,6 +433,9 @@ if __name__ == '__main__': parser.add_argument('-p', '--python-version', default=os.environ.get('PYTHON_VERSION', '%d.%d' % sys.version_info[:2]), help='The version of python to build for [default: %(default)s]') + parser.add_argument('-T', '--twine-check', action='store_true', + default=False, help='If set, then performs the equivalent of a ' \ + '"twine check" on the generated python package (zip file)') parser.add_argument('--verbose', '-v', action='count', default=0, help='Increases the verbosity level. We always prints error and ' \ 'critical messages. Use a single ``-v`` to enable warnings, ' \ @@ -497,4 +500,17 @@ if __name__ == '__main__': conda_build.api.build(os.path.join(args.work_dir, 'conda'), config=conda_config) + # checks if long_description of python package renders fine + if args.twine_check: + from twine.commands.check import check + package = glob.glob('dist/*.zip') + failed = check(package) + + if failed: + raise RuntimeError('long_description of package %s cannot be ' \ + 'correctly parsed (twine check returned a failure)' % \ + (package[0],)) + else: + logger.info('Package %s\'s long_description: OK', package[0]) + git_clean_build(bootstrap.run_cmdline, verbose=(args.verbose >= 2)) -- GitLab