You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ra...@apache.org on 2019/02/01 20:00:19 UTC

[trafficcontrol] branch master updated: fixed minor issue preventing package installation in Python2 (#3273)

This is an automated email from the ASF dual-hosted git repository.

rawlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 3533edb  fixed minor issue preventing package installation in Python2 (#3273)
3533edb is described below

commit 3533edb88bd8ebd5490bccab5d8e1a665e99ad28
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Fri Feb 1 13:00:12 2019 -0700

    fixed minor issue preventing package installation in Python2 (#3273)
    
    * fixed minor issue preventing package installation in Python2
    
    * Added versioning stategy documentation
    
    Also added some deprecation warnings about Python2 support and some
    Python version enforcement to 'setup.py'. Also fixed double-documenting
    of things in Python client (__all__ with non-private, top-level
    constructs in submodules not in it is a big oof).
---
 docs/source/tools/python_client.rst                | 15 ++---------
 traffic_control/clients/python/README.rst          |  4 ++-
 traffic_control/clients/python/setup.py            | 30 ++++++++++++++--------
 .../clients/python/trafficops/__version__.py       | 26 ++++++++++++++++---
 traffic_control/clients/python/trafficops/utils.py |  2 ++
 5 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/docs/source/tools/python_client.rst b/docs/source/tools/python_client.rst
index 3356116..500dc27 100644
--- a/docs/source/tools/python_client.rst
+++ b/docs/source/tools/python_client.rst
@@ -22,27 +22,16 @@ Apache-TrafficControl Package
 Package Contents
 ================
 .. automodule:: trafficops
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-TOSession
----------
-.. automodule:: trafficops.tosession
 	:members:
 	:undoc-members:
 	:show-inheritance:
 
-RestAPI
--------
-.. automodule:: trafficops.restapi
+.. automodule:: trafficops.utils
 	:members:
 	:undoc-members:
 	:show-inheritance:
 
-Utils
------
-.. automodule:: trafficops.utils
+.. automodule:: trafficops.__version__
 	:members:
 	:undoc-members:
 	:show-inheritance:
diff --git a/traffic_control/clients/python/README.rst b/traffic_control/clients/python/README.rst
index ad58702..1e89173 100644
--- a/traffic_control/clients/python/README.rst
+++ b/traffic_control/clients/python/README.rst
@@ -5,7 +5,7 @@ This is the Traffic Ops Python Client for Python 2.x and Python 3.x.
 
 .. attention:: Traffic Control version 3.0.0 officially deprecates Python 2.x support. Starting with Traffic Control version 4.0.0, Python 2.x support will be dropped, and only Python 3.x will be supported. Users and developers are encouraged to switch to Python 3 as soon as possible.
 
-.. note:: This client has only been tested against Python 2.7 and Python 3.6. Other versions may or may not work.
+.. note:: This client has only been tested against Python 2.7, 3.4, and 3.6. Other versions may or may not work.
 
 Installation
 ============
@@ -63,6 +63,8 @@ Development Dependencies
 ------------------------
 To install the development dependencies, first ensure that your system has ``pip`` and ``setuptools`` then use ``pip`` to install the development environment.
 
+.. note:: Currently, the development environment only "requires" `Pylint <https://www.pylint.org/>`_, which is a simple linter for which a configuration file is provided at :file:`traffic_control/clients/python/pylint.rc`. This linter might be nice to catch common mistakes, but is in no way enforced by the project at this time. Once Python2 support is dropped with the release of the Apache-TrafficControl package 2.0, it will hopefully be refined and put to use. In the meantime, feel free [...]
+
 .. code-block:: shell
 	:caption: Development Dependencies Installation
 
diff --git a/traffic_control/clients/python/setup.py b/traffic_control/clients/python/setup.py
index 9e1cc53..f32219c 100755
--- a/traffic_control/clients/python/setup.py
+++ b/traffic_control/clients/python/setup.py
@@ -19,14 +19,15 @@
 Setuptools build/install script for the Python Traffic Control client
 """
 
-import sys
+import io
 import os
+import sys
 from setuptools import setup, find_packages
 
 HERE = os.path.abspath(os.path.dirname(__file__))
 
 about = {}
-with open(os.path.join(HERE, 'trafficops', '__version__.py'), mode='r', encoding='utf-8') as f:
+with io.open(os.path.join(HERE, 'trafficops', '__version__.py'), mode='r', encoding='utf-8') as f:
 	exec(f.read(), about)
 
 with open(os.path.join(HERE, "README.rst")) as fd:
@@ -36,7 +37,7 @@ with open(os.path.join(HERE, "README.rst")) as fd:
 	       author="Apache Software Foundation",
 	       author_email="dev@trafficcontrol.apache.org",
 	       description="Python API Client for Traffic Control",
-	       long_description=fd.read(),
+	       long_description='\n'.join((fd.read(), about["__doc__"])),
 	       url="http://trafficcontrol.apache.org/",
 	       license="http://www.apache.org/licenses/LICENSE-2.0",
 	       classifiers=[
@@ -47,6 +48,8 @@ with open(os.path.join(HERE, "README.rst")) as fd:
 	           'Operating System :: OS Independent',
 	           'Programming Language :: Python :: 2.7',
 	           'Programming Language :: Python :: 3',
+	           'Programming Language :: Python :: 3.4',
+	           'Programming Language :: Python :: 3.5',
 	           'Programming Language :: Python :: 3.6',
 	           'Programming Language :: Python :: 3.7',
 	           'Programming Language :: Python :: 3.8',
@@ -63,13 +66,20 @@ with open(os.path.join(HERE, "README.rst")) as fd:
 	       ],
 	       extras_require={
 	           "dev": [
-	               "pylint"
+	               "pylint>=2.0,<3.0"
 	           ]
-	       }
+	       },
+	       # This will only be enforced by pip versions >=9.0 (18.1 being current at the time of
+	       # this writing) - i.e. not the pip installed as python34-pip from elrepo on CentOS
+	       python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*'
 	)
 
-if ((sys.version_info[0] == 2 and sys.version_info < (2, 7))
-   or (sys.version_info[0] == 3 and sys.version_info < (3, 6))):
-	MSG = ('WARNING: This library may not work properly with Python {0}, '
-		   'as it is untested for this version.')
-	print(MSG.format(sys.version.split(' ', 1)[0]))
+pyversion = sys.version_info
+if pyversion.major < 3:
+	sys.stderr.write(
+		"Python 2 is deprecated, and will not be supported in version 2 of this package (by 2020)\n"
+	)
+elif pyversion.major == 3 and (pyversion.minor < 4 or pyversion.minor > 6):
+	MSG = ('WARNING: This library may not work properly with Python {0.major}.{0.minor}.{0.micro}, '
+	       'as it is untested for this version. (3.4 <= version <=3.6 recommended)\n')
+	sys.stderr.write(MSG.format(pyversion))
diff --git a/traffic_control/clients/python/trafficops/__version__.py b/traffic_control/clients/python/trafficops/__version__.py
index f51aabd..854f684 100644
--- a/traffic_control/clients/python/trafficops/__version__.py
+++ b/traffic_control/clients/python/trafficops/__version__.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -14,4 +12,26 @@
 # limitations under the License.
 #
 
-__version__ = '1.1.1'
+"""
+Versioning
+==========
+The :mod:`trafficops.__version__` module contains only the :data:`__version__` "constant" which
+gives the version of this *Apache-TrafficControl package* and **not** the version of
+*Apache Traffic Control* for which it was made. The two are versioned separately, to allow the
+client to grow in a version-controlled manner without being tied to the release cadence of Apache
+Traffic Control as a whole.
+
+Version 1.0 is supported for use with Apache Traffic Control version 3.0 (release pending at the
+time of this writing). New functionality will be added as the :ref:`to-api` evolves, but changes to
+this client will remain non-breaking for existing code using it until the next major version is
+released.
+
+.. deprecated:: 1.0
+	The v1.0 release of this client deprecates support of Python2. Versions 2.0 and onward will
+	*only* support Python3 (v3.4+). Note that this release is expected either by the time Python2
+	reaches its end-of-life at the end of 2019, or with the release of Apache Traffic Control v4.0,
+	should that happen first. Users and developers are encouraged to switch to Python3 as soon as
+	possible.
+"""
+
+__version__ = '1.1.2'
diff --git a/traffic_control/clients/python/trafficops/utils.py b/traffic_control/clients/python/trafficops/utils.py
index dc81f6c..669ca8b 100644
--- a/traffic_control/clients/python/trafficops/utils.py
+++ b/traffic_control/clients/python/trafficops/utils.py
@@ -15,6 +15,8 @@
 #
 
 """
+utils
+=====
 Useful utility methods
 """