@@ -95,3 +95,44 @@ def set_build_ext(dist, attr, value):
9595 root = value ['root' ]
9696 base = dist .cmdclass .get ('build_ext' , _build_ext )
9797 dist .cmdclass ['build_ext' ] = _get_build_ext_cls (base , root )
98+
99+
100+ GOLANG = 'https://storage.googleapis.com/golang/go1.7.5.linux-amd64.tar.gz'
101+ WHEEL_ARGS = '--no-deps --wheel-dir /tmp /dist/*.tar.gz'
102+
103+
104+ def build_manylinux_wheels (argv = None ): # pragma: no cover
105+ assert os .path .exists ('setup.py' )
106+ shutil .rmtree ('dist' )
107+ os .makedirs ('dist' )
108+ _check_call (('python' , 'setup.py' , 'sdist' ), cwd = '.' , env = {})
109+ _check_call (
110+ (
111+ 'docker' , 'run' ,
112+ '--volume' , '{}:/dist:rw' .format (os .path .abspath ('dist' )),
113+ # I'd use --user, but this breaks git:
114+ # http://stackoverflow.com/a/20272540/812183
115+ '--env' , 'UID={}' .format (os .getuid ()),
116+ '--env' , 'GID={}' .format (os .getgid ()),
117+ 'quay.io/pypa/manylinux1_x86_64:latest' ,
118+ 'bash' , '-exc' ,
119+ 'cd /tmp\n '
120+ 'wget {golang} -q --no-check-certificate -O /tmp/golang.tar.gz\n '
121+ 'tar -xf /tmp/golang.tar.gz\n '
122+ 'export GOROOT=/tmp/go\n '
123+ 'export PATH="$GOROOT/bin:$PATH"\n '
124+ '/opt/python/cp27-cp27mu/bin/pip wheel {wheel_args}\n '
125+ '/opt/python/cp34-cp34m/bin/pip wheel {wheel_args}\n '
126+ '/opt/python/cp35-cp35m/bin/pip wheel {wheel_args}\n '
127+ '/opt/python/cp36-cp36m/bin/pip wheel {wheel_args}\n '
128+ 'mkdir /tmp/whls\n '
129+ 'ls *.whl | xargs -n1 --verbose auditwheel repair -w /tmp/whls\n '
130+ 'cp /tmp/whls/* /dist\n '
131+ 'chown "$UID:$GID" /dist/*\n '
132+ 'ls /dist -al\n ' .format (golang = GOLANG , wheel_args = WHEEL_ARGS ),
133+ ),
134+ cwd = '.' , env = {},
135+ )
136+ print ('*' * 79 )
137+ print ('Your wheels have been built into ./dist' )
138+ print ('*' * 79 )
0 commit comments