Search code examples
pythonpython-wheel

bdist_wheel creates py37 wheel instead of py36


In order to generate a pip wheel of sagemaker-training repository [https://github.com/aws/sagemaker-training-toolkit.git]

I ran

python setup.py bdist_wheel

It results in creation of python 37 compatible wheel

ls dist/
sagemaker_training-3.6.3.dev0-cp37-cp37m-linux_x86_64.whl

I checked the setup.py; it doesn't specifically mention py37.

Is there a way to create a binary [pip wheel] that's compatible with python36?

Why do I need py36 compatible binary?

Because py36 can't consume py37 wheel

RUN pip3 install sagemaker_training-3.6.3.dev0-cp37-cp37m-linux_x86_64.whl
 ---> Running in ca56241af5fa
ERROR: sagemaker_training-3.6.3.dev0-cp37-cp37m-linux_x86_64.whl is not a supported wheel on this platform.

Solution

  • This is because the wheel is compatible with the invoking Python interpreter, that is, you're probably have installed Python 3.7, you can quickly verify this by running which python.

    Solution

    Consider pyenv, as example I'll be using python 3.6.1

    pyenv install 3.6.1
    

    you could verify the installation by running

    ls ~/.pyenv/versions/
    

    and set the installed version as global or local (for the purposes of this example I'll be setting it as global).

    pyenv global 3.6.1
    

    if you want you could verify this with

    python -V
    

    Finally, you can create a wheel compatible with Python3.6.

    python setup.py bdist_wheel
    

    References

    1. Intro to Pyenv (Real Python). URL: https://realpython.com/intro-to-pyenv/