Skip to content
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

Add a check for python version in make and gracefully exit rather than fail on python version 2. #7109

Closed
akshayaurora opened this issue Sep 27, 2020 · 15 comments · Fixed by #7110

Comments

@akshayaurora
Copy link
Member

akshayaurora commented Sep 27, 2020

Software Versions

  • Python:
  • OS: OSX 10.15.6
  • Kivy: master 27 sept 2020
  • Kivy installation method: clone master and make

Describe the bug
Make fails with python referring to python2 does not fail gracefully

Expected behavior

 kivy % make 
python setup.py build_ext —inplace
Python version 2 is not supported, please use python3

To Reproduce

> git clone github.com/kivy/kivy
> cd kivy
> make 

Code and Logs and screenshots

 kivy % make 
python setup.py build_ext --inplace
  File "setup.py", line 1050
    def glob_paths(*patterns, excludes=('.pyc', )):
                                     ^
SyntaxError: invalid syntax
make: *** [build] Error 1

Additional context
Add any other context about the problem here.

@tshirtman
Copy link
Member

tshirtman commented Sep 27, 2020

maybe something like

PYTHON_MINIMUM_VERSION = (3, 6, 0)

if sys.version_info < PYTHON_MINIMUM_VERSION:
     logger.error("Kivy requires at least Python%d.%d.%d", *PYTHON_MININUM_VERSION)

@akshayaurora
Copy link
Member Author

@tshirtman your solution is already implemented in setup.py, issue is it fails due to syntax error in py2 while it works with py3

@tshirtman
Copy link
Member

Oh right, makes sense.

@tshirtman
Copy link
Member

but in which situation does the one in makefile helps?

@akshayaurora
Copy link
Member Author

akshayaurora commented Sep 27, 2020

If you try to run make to compile kivy and your python points to a version < 3.6 it would now simply give you this error.

kivy % make
Makefile:12: *** "detected Python 2.7 need Python >= 3.6".  Stop.

instead of

kivy % make 
python setup.py build_ext --inplace
  File "setup.py", line 1050
    def glob_paths(*patterns, excludes=('.pyc', )):
                                     ^
SyntaxError: invalid syntax
make: *** [build] Error 1

@tshirtman
Copy link
Member

right, but few users actually do that, right?

Maybe we should use a stub setup.py that is python2 compatible if we want that, and only conditionally import/run the actual (renamed) setup.py from it if we detect that we have a supported python version, then?

@akshayaurora
Copy link
Member Author

akshayaurora commented Sep 27, 2020

@tshirtman I am not really sure of the consequences of that but #7111 does that, feel free to merge which ever method you feel works.

@matham
Copy link
Member

matham commented Sep 27, 2020

Eh. I'm not sure we should have non standard setup.py (msetup.py) just for make users, which are pretty rare these days (except for us core-devs). The default cade should be for 3+, not 2.

@matham
Copy link
Member

matham commented Sep 27, 2020

The makefile itself should check for 2.7 and fail, rather than putting the work in Python code itself. And for 3.x support, there's a standard python_requires or something similar metadata for minimum python version. This can be added to the config file.

@tshirtman
Copy link
Member

tshirtman commented Sep 27, 2020

the other setup.py is not for make users, it's to allow anyone to run setup.py and get a legible error if they are using python2.7, it might be a bit heavy handed, but i don't see another way to avoid the syntax error otherwise (or avoiding using python3 syntax in setup.py).

the effect would be something like

$ python2.7 setup.py
Kivy requires Python >= (3, 6, 0)  detected: (2, 7, 15)

$ python3.7 setup.py
(everything happens as usual)

@matham
Copy link
Member

matham commented Sep 27, 2020 via email

@akshayaurora
Copy link
Member Author

Honestly my personal use case is using make, that’s why I wanted to add the Make only solution. This is good enough for users that compile from git.

For the setup.py change I fear doing it this way is begging for consequences down the line….

@tshirtman
Copy link
Member

Even editable install is installed with pip initially. So we just need to
add the appropriate metada and hopefully pip not even try to run setup.py
if the min version is violated.

Hm, i assumed because pip runs setup.py, it was a better solution, and i don't really see the point of having an error when you already have it installed, is that for when you run make without enabling your venv or something?

@akshayaurora
Copy link
Member Author

is that for when you run make without enabling your venv or something?

Yes. Default python on osx is still python2, lol

@tshirtman
Copy link
Member

ok, i understand better, i guess the less intrusive fix is with the makefile then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants