add validation for sdist building
Try to build the sdist and wheel for python packages. Change-Id: I6cf0ff8e7771367bce17061c9b21b7740516d31d Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
aa6ddd51e7
commit
81047e0096
@ -685,6 +685,33 @@ def validate_tarball_base(deliv, context):
|
||||
sdist, expected))
|
||||
|
||||
|
||||
@applies_to_released
|
||||
def validate_build_sdist(deliv, context):
|
||||
"Can we build an sdist for a python project?"
|
||||
|
||||
release = deliv.releases[-1]
|
||||
for project in release.projects:
|
||||
|
||||
version_exists = gitutils.commit_exists(
|
||||
context.workdir, project.repo.name, release.version,
|
||||
)
|
||||
if version_exists:
|
||||
print('version {} was already tagged, skipping'.format(
|
||||
release.version))
|
||||
continue
|
||||
|
||||
gitutils.safe_clone_repo(
|
||||
context.workdir, project.repo.name, project.hash, context)
|
||||
|
||||
try:
|
||||
pythonutils.build_sdist(
|
||||
context.workdir, project.repo.name)
|
||||
except Exception as err:
|
||||
context.error(
|
||||
'Failed to build sdist for {}: {}'.format(
|
||||
project.repo.name, err))
|
||||
|
||||
|
||||
@skip_existing_tags
|
||||
@applies_to_released
|
||||
def validate_pypi_readme(deliv, context):
|
||||
@ -1751,6 +1778,7 @@ def main():
|
||||
validate_release_type,
|
||||
validate_pypi_permissions,
|
||||
validate_pypi_readme,
|
||||
validate_build_sdist,
|
||||
validate_gitreview,
|
||||
validate_release_sha_exists,
|
||||
validate_existing_tags,
|
||||
|
@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_sdist_name(workdir, repo):
|
||||
"Check out the code."
|
||||
"Find the name of the sdist."
|
||||
dest = os.path.join(workdir, repo)
|
||||
setup_path = os.path.join(dest, 'setup.py')
|
||||
if not os.path.exists(setup_path):
|
||||
@ -59,6 +59,33 @@ def get_sdist_name(workdir, repo):
|
||||
return name
|
||||
|
||||
|
||||
def build_sdist(workdir, repo):
|
||||
"Build the sdist."
|
||||
dest = os.path.join(workdir, repo)
|
||||
setup_path = os.path.join(dest, 'setup.py')
|
||||
if not os.path.exists(setup_path):
|
||||
LOG.debug('did not find %s, maybe %s is not a python project',
|
||||
setup_path, repo)
|
||||
return
|
||||
use_tox = repo.endswith('/pbr')
|
||||
if use_tox and not os.path.exists(os.path.join(dest, '.tox', 'venv')):
|
||||
# Use tox to set up a virtualenv so we can install the
|
||||
# dependencies for the package. This only seems to be
|
||||
# necessary for pbr, but...
|
||||
processutils.check_output(
|
||||
['tox', '-e', 'venv', '--notest'],
|
||||
cwd=dest,
|
||||
)
|
||||
if use_tox:
|
||||
python = '.tox/venv/bin/python'
|
||||
else:
|
||||
python = 'python'
|
||||
# Run it once and discard the result to ensure any setup_requires
|
||||
# dependencies are installed.
|
||||
cmd = [python, 'setup.py', 'sdist', 'bdist_wheel']
|
||||
processutils.check_call(cmd, cwd=dest)
|
||||
|
||||
|
||||
def check_readme_format(workdir, repo):
|
||||
"Verify that the README format looks OK."
|
||||
dest = os.path.join(workdir, repo)
|
||||
|
Loading…
Reference in New Issue
Block a user