python icon indicating copy to clipboard operation
python copied to clipboard

Python2 support dropped but installation works

Open jonasdlindner opened this issue 5 years ago • 1 comments

What happened (please include outputs or screenshots): I have accidentally installed the git-Master-Branch with Python2 with these commands:

git clone --recursive https://github.com/kubernetes-client/python.git
cd python
python setup.py install

Everything works fine, but Python2 support is dropped (https://github.com/kubernetes-client/python/pull/1468)

What you expected to happen: I expect an error Message like:

  File "setup.py", line 30, in <module>
    raise RuntimeError("kubernetes-client " + CLIENT_VERSION + " requires Python 3.6+")
RuntimeError: kubernetes-client 18.0.0-snapshot requires Python 3.6+

How to reproduce it (as minimally and precisely as possible): See in "What happened". You may have to use python2 setup.py install if python --v is not 2

Anything else we need to know?: A possible fix in setup.py would be

import sys

from setuptools import setup

# Do not edit these constants. They will be updated automatically
# by scripts/update-client.sh.
CLIENT_VERSION = "18.0.0-snapshot"
PACKAGE_NAME = "kubernetes"
DEVELOPMENT_STATUS = "3 - Alpha"

# To install the library, run the following
#
# python setup.py install
#
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools

if sys.version_info < (3, 6):
    raise RuntimeError("kubernetesclient " + CLIENT_VERSION + " requires Python 3.6+")

There is also some Python2 compatibility code in the python/ and python-base repo For example:

  • https://github.com/kubernetes-client/python/blob/master/kubernetes/client/apis/init.py#L1
  • https://github.com/kubernetes-client/python-base/blob/0d4f822f4f654361764a6f8dcf7ca9bf5bbce3f9/leaderelection/leaderelection.py#L23
  • https://github.com/kubernetes-client/python-base/blob/master/watch/watch.py#L32
  • https://github.com/kubernetes-client/python-base/blob/b4d3aad42dc23e7a6c0e5c032691f8dc385a786c/dynamic/client.py#L60 Should that also be removed?

Environment:

  • Kubernetes version (kubectl version): v1.19.0
  • OS (e.g., MacOS 10.13.6): Fedora 29 (Workstation Edition)
  • Python version (python --version) Python 2.7.17
  • Python client version (pip list | grep kubernetes) 18.0.0-snapshot

jonasdlindner avatar Jun 29 '21 13:06 jonasdlindner

Thanks for reporting. Would you mind opening a PR with the change you suggested? Thanks!

roycaihw avatar Jul 19 '21 16:07 roycaihw