|
| 1 | +#!/usr/bin/env python3.5 |
| 2 | +"""Script for building 'manylinux' wheels for libsass. |
| 3 | +
|
| 4 | +Run me after putting the source distribution on pypi. |
| 5 | +
|
| 6 | +See: https://www.python.org/dev/peps/pep-0513/ |
| 7 | +""" |
| 8 | +import os |
| 9 | +import pipes |
| 10 | +import subprocess |
| 11 | +import tempfile |
| 12 | + |
| 13 | +from twine.commands import upload |
| 14 | + |
| 15 | + |
| 16 | +def check_call(*cmd): |
| 17 | + print( |
| 18 | + 'build-manylinux-wheels>> ' + |
| 19 | + ' '.join(pipes.quote(part) for part in cmd), |
| 20 | + ) |
| 21 | + subprocess.check_call(cmd) |
| 22 | + |
| 23 | + |
| 24 | +def main(): |
| 25 | + os.makedirs('dist', exist_ok=True) |
| 26 | + for python in ( |
| 27 | + 'cp26-cp26mu', |
| 28 | + 'cp27-cp27mu', |
| 29 | + 'cp34-cp34m', |
| 30 | + 'cp35-cp35m', |
| 31 | + ): |
| 32 | + with tempfile.TemporaryDirectory() as work: |
| 33 | + pip = '/opt/python/{}/bin/pip'.format(python) |
| 34 | + check_call( |
| 35 | + 'docker', 'run', '-ti', |
| 36 | + # Use this so the files are not owned by root |
| 37 | + '--user', '{}:{}'.format(os.getuid(), os.getgid()), |
| 38 | + # We'll do building in /work and copy results to /dist |
| 39 | + '-v', '{}:/work:rw'.format(work), |
| 40 | + '-v', '{}:/dist:rw'.format(os.path.abspath('dist')), |
| 41 | + 'quay.io/pypa/manylinux1_x86_64:latest', |
| 42 | + 'bash', '-exc', |
| 43 | + '{} wheel --verbose --wheel-dir /work --no-deps libsass && ' |
| 44 | + 'auditwheel repair --wheel-dir /dist /work/*.whl'.format(pip) |
| 45 | + ) |
| 46 | + dists = tuple(os.path.join('dist', p) for p in os.listdir('dist')) |
| 47 | + return upload.main(('-r', 'pypi') + dists) |
| 48 | + |
| 49 | +if __name__ == '__main__': |
| 50 | + exit(main()) |
0 commit comments