Skip to content

Add a script to build manylinux wheels #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ omit =
/usr/*
*/tmp*
*/setup.py
*/build_manylinux_wheels.py
*/upload_appveyor_builds.py

[report]
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
50 changes: 50 additions & 0 deletions build_manylinux_wheels.py
Original file line number Diff line number Diff line change
@@ -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())