From 61ab1e7f6dee6cfe3c837b3c4907f604b53eb74b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 26 Dec 2016 19:36:08 +0000 Subject: [PATCH] build sdist/wheel only once for both Github and PyPI This makes sure we upload the same files to Github Releases and PyPI. Currently we were building them twice, with the risk of different files being uploaded to the two repositories. --- .travis.yml | 3 ++- .travis/before_deploy.sh | 12 +++++++++--- setup.py | 21 +++++++++++++++++++++ tox.ini | 20 ++++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4475bc9b0..2de3ee595 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,8 @@ deploy: user: anthrotype password: secure: Dz3x8kh4ergBV6qZUgcGVDOEzjoCEFzzQiO5WVw4Zfi04DD8+d1ghmMz2BY4UvoVKSsFrfKDuEB3MCWyqewJsf/zoZQczk/vnWVFjERROieyO1Ckzpz/WkCvbjtniIE0lxzB7zorSV+kGI9VigGAaRlXJyU7mCFojeAFqD6cjS4= - distributions: "sdist bdist_wheel" + skip_cleanup: true + distributions: pass on: tags: true repo: fonttools/fonttools diff --git a/.travis/before_deploy.sh b/.travis/before_deploy.sh index 9e983d7d7..1ded8f0f9 100755 --- a/.travis/before_deploy.sh +++ b/.travis/before_deploy.sh @@ -3,7 +3,13 @@ set -e set -x -if [[ $BUILD_DIST == true ]]; then - python -m pip install --upgrade wheel - python setup.py sdist bdist_wheel +# build sdist and wheel distribution packages in ./dist folder. +# Travis runs the `before_deploy` stage before each deployment, but +# we only want to build them once, as we want to use the same +# files for both Github and PyPI +if $(ls ./dist/fonttools*.zip > /dev/null 2>&1) && \ + $(ls ./dist/fonttools*.whl > /dev/null 2>&1); then + echo "Distribution packages already exists; skipping" +else + tox -e bdist fi diff --git a/setup.py b/setup.py index e4d699eb1..a6e2e7867 100755 --- a/setup.py +++ b/setup.py @@ -239,6 +239,26 @@ class release(Command): return u"".join(changes) +class PassCommand(Command): + """ This is used with Travis `dpl` tool so that it skips creating sdist + and wheel packages, but simply uploads to PyPI the files found in ./dist + folder, that were previously built inside the tox 'bdist' environment. + This ensures that the same files are uploaded to Github Releases and PyPI. + """ + + description = "do nothing" + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + pass + + setup( name="fonttools", version="3.4.1.dev0", @@ -272,6 +292,7 @@ setup( }, cmdclass={ "release": release, + 'pass': PassCommand, }, **classifiers ) diff --git a/tox.ini b/tox.ini index 0e8d76270..5ccdd2093 100644 --- a/tox.ini +++ b/tox.ini @@ -44,3 +44,23 @@ ignore_outcome = true commands = coverage combine codecov --env TOXENV + +[testenv:bdist] +basepython = {env:TOXPYTHON:python3.5} +deps = + setuptools + wheel +skip_install = true +install_command = + # make sure we use the latest setuptools and wheel + pip install --upgrade {opts} {packages} +whitelist_externals = + rm +commands = + # clean up build/ and dist/ folders + rm -rf {toxinidir}/dist + python setup.py clean --all + # build sdist + python setup.py sdist --dist-dir {toxinidir}/dist + # build wheel from sdist + pip wheel -v --no-deps --no-index --wheel-dir {toxinidir}/dist --find-links {toxinidir}/dist fonttools