title: How to publish binary Python wheels for linux on a local machine
body: <p>I have a package containing C extensions that I would like to upload to pypi: <a href="https://github.com/Erotemic/netharn" rel="nofollow noreferrer">https://github.com/Erotemic/netharn</a></p>
  
  <p>I built a wheel on Ubuntu 18.04 using the command <code>python setup.py bdist_wheel --py-limited-api=cp36</code>, but when I went to upload with <code>twine upload --skip-existing dist/*</code>, but then I get the error that it has an unsupported platform tag: </p>
  
  <pre><code>HTTPError: 400 Client Error: Binary wheel 'netharn-0.0.4-cp36-abi3-linux_x86_64.whl' has an unsupported platform tag 'linux_x86_64'. for url: https://upload.pypi.org/legacy/
  </code></pre>
  
  <p>After a bit of searching I found that PEP 513 requires building a wheel to support manylinux (aka Centos5): <a href="https://github.com/pypa/manylinux" rel="nofollow noreferrer">https://github.com/pypa/manylinux</a></p>
  
  <p>They provide an example here: <a href="https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh" rel="nofollow noreferrer">https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh</a></p>
  
  <p>However, all examples I can find always build their binaries using some sort of CI server. If possible I would like to be able to build them locally. I thought that it should be simple to just replicate the docker commands and built it in a docker container on my own machine. However, I'm having issues.  (I ensured any existing build and dist directories in the repo were removed)</p>
  
  <p>The first thing I did was to dump myself in an interactive docker session so I could play with things. I chose the x8_64 image and mounted the local directory to my code repository on <code>/io</code> in the docker machine. I then started an interactive bash session. </p>
  
  <pre><code>REPO_DPATH=$HOME/code/netharn
  DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64
  PRE_CMD=""
  # Interactive test
  docker run -it --rm -v $REPO_DPATH:/io $DOCKER_IMAGE $PRE_CMD bash
  </code></pre>
  
  <p>Inside docker, I first wanted to build a wheel for python36 (really this is the only Python I'm interested in supporting at the moment). </p>
  
  <pre><code>PYBIN=/opt/python/cp36-cp36m/bin/
  </code></pre>
  
  <p>Simply installing my requirements.txt didn't seem to work, so I manually installed a few packages first. After doing that (<code>imgaug</code> was the culprit because it relies on a specific master build), installing requirements.txt seemed to work. </p>
  
  <pre><code>    cd /io
      "${PYBIN}/pip" install opencv_python
      "${PYBIN}/pip" install Cython
      "${PYBIN}/pip" install pytest
      "${PYBIN}/pip" install -e git+https://github.com/aleju/imgaug.git@master#egg=imgaug
      "${PYBIN}/pip" install torch  # this is in the requirements.txt, but will cause problems later
      "${PYBIN}/pip" install -r requirements.txt
  </code></pre>
  
  <p>I then run the wheel command and bundle external shared libraries into wheels</p>
  
  <pre><code>"${PYBIN}/pip" wheel /io/ -w wheelhouse/
  for whl in wheelhouse/*.whl; do
      auditwheel repair "$whl" -w /io/wheelhouse/
  done
  </code></pre>
  
  <p>The last step is to install the package and test</p>
  
  <pre><code>    "${PYBIN}/pip" install netharn --no-index -f /io/wheelhouse
  
      (cd "$HOME"; "${PYBIN}/python" -m xdoctest netharn all)
  </code></pre>
  
  <p>However, when I got to test it I get</p>
  
  <pre><code>ImportError: /opt/python/cp36-cp36m/lib/python3.6/site-packages/torch/_C.cpython-36m-x86_64-linux-gnu.so: ELF file OS ABI invalid
  </code></pre>
  
  <p>I guess this is because <code>torch</code> does not support Centos5.
  What I don't get is how <code>torch</code> gets away with uploading a <code>cpython-36m-x86_64-linux-gnu.so</code> shared library to pypi, but I'm having issues?</p>