0

I have python 2.7 and 3.7 installed on Windows 10.

In the end I set up completely separate environments for each, and each version appears to be comfortable in its own environment.

My task is to migrate some libraries from 2.7 to 3.x.

In my 2.7 environment I can build the libraries with no problems.

As I've just started this task I've run my source code through 2to3, and not much more. There is nothing to indicate any issues with the conversion.

I then attempt to build a wheel in my python 3.7 environment. Setup.py contains

python_requires='>=3.7'

and the classifiers explicitly state

"Programming Language :: PYTHON :: 3"

I run

setup.py bdist_wheel

My setup.py is set to bail out if python 3.7 is not used with the setup file.

The wheel that is generated is my_library_-py2-none-any.whl

My pip version is 19.0.3.

I don't want to upgrade PIP as I want to be sure of 2.7 support and I know I'll be stuck with 2.7 for a good while to come.

Why is my wheel indicating python 2 support only?

Chris G
  • 115
  • 1
  • 9
  • 1
    you should use virtual environments for each python project you do. You can choose which python you want to use when you create it and it prevents polution of the global namespace and problems like you have above – Craicerjack Sep 19 '19 at 11:52
  • Possible duplicate of [How do I tell a Python script to use a particular version](https://stackoverflow.com/questions/11170827/how-do-i-tell-a-python-script-to-use-a-particular-version) – ivan_pozdeev Sep 19 '19 at 11:58

1 Answers1

0
  • Add #!python3 as the first line of your setup.py; or
  • Run it as py -3 setup.py

In Windows, running a file directly feeds it to a program associated with its extension. Since Py3, the .py extension is associated with the "py launcher". It accepts a command line argument of which version to use and, if you don't specify one (which is what happens if you run the file directly), looks for a UNIX-like shebang in the file to determine which version to use.

ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152