diff --git a/.coveragerc b/.coveragerc index 3e590dd2..6607d979 100644 --- a/.coveragerc +++ b/.coveragerc @@ -8,6 +8,7 @@ omit = /usr/* */tmp* */setup.py + */build_manylinux_wheels.py */upload_appveyor_builds.py [report] diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index a202d7fe..d92c5cb6 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -56,6 +56,8 @@ Here's a brief check list for releasing a new version: takes longer than an hour. These wheels are not automatically uploaded, but there's upload_appveyor_builds.py script that downloads built wheels and uploads them to PyPI. +- Run build_manylinux_wheels.py to build linux wheels and upload them to + PyPI (takes ~10 minutes). - The `docs website`__ also has to be updated. It's currently a static website deployed on GitHub Pages. Use ``python setup.py upload_doc`` command. diff --git a/build_manylinux_wheels.py b/build_manylinux_wheels.py new file mode 100755 index 00000000..37650155 --- /dev/null +++ b/build_manylinux_wheels.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3.5 +"""Script for building 'manylinux' wheels for libsass. + +Run me after putting the source distribution on pypi. + +See: https://www.python.org/dev/peps/pep-0513/ +""" +import os +import pipes +import subprocess +import tempfile + +from twine.commands import upload + + +def check_call(*cmd): + print( + 'build-manylinux-wheels>> ' + + ' '.join(pipes.quote(part) for part in cmd), + ) + subprocess.check_call(cmd) + + +def main(): + os.makedirs('dist', exist_ok=True) + for python in ( + 'cp26-cp26mu', + 'cp27-cp27mu', + 'cp34-cp34m', + 'cp35-cp35m', + ): + with tempfile.TemporaryDirectory() as work: + pip = '/opt/python/{}/bin/pip'.format(python) + check_call( + 'docker', 'run', '-ti', + # Use this so the files are not owned by root + '--user', '{}:{}'.format(os.getuid(), os.getgid()), + # We'll do building in /work and copy results to /dist + '-v', '{}:/work:rw'.format(work), + '-v', '{}:/dist:rw'.format(os.path.abspath('dist')), + 'quay.io/pypa/manylinux1_x86_64:latest', + 'bash', '-exc', + '{} wheel --verbose --wheel-dir /work --no-deps libsass && ' + 'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip) + ) + dists = tuple(os.path.join('dist', p) for p in os.listdir('dist')) + return upload.main(('-r', 'pypi') + dists) + +if __name__ == '__main__': + exit(main())