[pygobject/drop-py2: 2/2] Remove Python 2 support



commit 97024e55785d971b8f86bb6659ba3f0e4b076473
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sun Mar 8 16:21:35 2020 +0100

    Remove Python 2 support
    
    Depend on setuptools to make sure we write out requires-python in all cases

 .gitlab-ci.yml          | 11 -----------
 NEWS                    |  6 ++++++
 PKG-INFO.in             |  3 ++-
 README.rst              |  6 +++---
 docs/Makefile           |  4 ++--
 docs/conf.py            |  3 +--
 docs/packagingguide.rst |  2 +-
 meson.build             | 12 +++---------
 setup.py                | 26 ++++++++------------------
 9 files changed, 26 insertions(+), 47 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f93d3847..b12e3dc5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -65,11 +65,6 @@ python3-mingw64:
     CHERE_INVOKING: "yes"
   <<: *mingw-defaults
 
-python2.7:
-  variables:
-    PYENV_VERSION: "2.7.17-debug"
-  <<: *defaults
-
 python3.5:
   variables:
     PYENV_VERSION: "3.5.9"
@@ -90,12 +85,6 @@ python3.8:
     PYENV_VERSION: "3.8.1-debug"
   <<: *defaults
 
-pypy2.7:
-  allow_failure: true
-  variables:
-    PYENV_VERSION: "pypy2.7-7.3.0"
-  <<: *defaults
-
 pypy3.6:
   allow_failure: true
   variables:
diff --git a/NEWS b/NEWS
index 552738b9..da29933f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+3.xx.x - ????-??-??
+-------------------
+
+Python 2 is no longer supported.
+
+
 3.36.0 - 2020-03-08
 -------------------
 
diff --git a/PKG-INFO.in b/PKG-INFO.in
index 34891d78..b48c9059 100644
--- a/PKG-INFO.in
+++ b/PKG-INFO.in
@@ -1,4 +1,4 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.2
 Name: PyGObject
 Version: @VERSION@
 Summary: Python bindings for GObject Introspection
@@ -18,3 +18,4 @@ Classifier: Operating System :: Microsoft :: Windows
 Classifier: Programming Language :: C
 Classifier: Programming Language :: Python
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Requires-Python: >=3.5, <4
diff --git a/README.rst b/README.rst
index cc88c289..6f9f1489 100644
--- a/README.rst
+++ b/README.rst
@@ -12,9 +12,9 @@
 <https://developer.gnome.org/glib/stable/>`__, `GIO
 <https://developer.gnome.org/gio/stable/>`__ and many more.
 
-It supports Linux, Windows and macOS and works with **Python 2.7+**, **Python
-3.5+**, **PyPy** and **PyPy3**. PyGObject, including this documentation, is
-licensed under the **LGPLv2.1+**.
+It supports Linux, Windows and macOS and works with **Python 3.5+** and
+**PyPy3**. PyGObject, including this documentation, is licensed under the
+**LGPLv2.1+**.
 
 
 ----
diff --git a/docs/Makefile b/docs/Makefile
index 55525c52..bdba909a 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -7,10 +7,10 @@ images/%.svg: images/%.dia
        dia $< --export=$@ --filter=dia-svg
 
 _build: Makefile *.rst devguide/*.rst guide/*/*.rst guide/*.rst conf.py images/*.png $(DIA_SVGS) 
../README.rst ../NEWS
-       sphinx-build -b html . _build
+       python3 -m sphinx -b html . _build
 
 linkcheck:
-       sphinx-build -b linkcheck -n . _build
+       python3 -m sphinx -b linkcheck -n . _build
 
 clean:
        rm -R _build
diff --git a/docs/conf.py b/docs/conf.py
index 96099741..d7236c25 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -12,8 +12,7 @@ intersphinx_mapping = {
     'glib': ('https://lazka.github.io/pgi-docs/GLib-2.0', None),
     'gdk': ('https://lazka.github.io/pgi-docs/Gdk-3.0', None),
     'gio': ('https://lazka.github.io/pgi-docs/Gio-2.0', None),
-    'python2': ('https://docs.python.org/2.7', None),
-    'python3': ('https://docs.python.org/3', None),
+    'python': ('https://docs.python.org/3', None),
     'cairo': ('https://pycairo.readthedocs.io/en/latest', None),
 }
 
diff --git a/docs/packagingguide.rst b/docs/packagingguide.rst
index eae5d752..e1715eb9 100644
--- a/docs/packagingguide.rst
+++ b/docs/packagingguide.rst
@@ -23,7 +23,7 @@ Runtime dependencies:
     * glib
     * libgirepository (gobject-introspection)
     * libffi
-    * Python 2 or 3
+    * Python 3
 
     The overrides directory contains various files which includes various
     Python imports mentioning gtk, gdk etc. They are only used when the
diff --git a/meson.build b/meson.build
index aaf1d22f..948a09f0 100644
--- a/meson.build
+++ b/meson.build
@@ -15,8 +15,8 @@ platform_version = '@0@.0'.format(pygobject_version_major)
 pymod = import('python')
 python = pymod.find_installation(get_option('python'))
 
-if python.language_version().version_compare('< 3.0') and host_machine.system() == 'windows'
-  error('Python 2 on Windows no longer supported since 3.35. Use Python 3 instead.')
+if python.language_version().version_compare('< 3.5')
+  error('Requires Python >= 3.5')
 endif
 
 python_dep = python.dependency()
@@ -54,14 +54,8 @@ if with_pycairo
     endif
   endif
 
-  if python.language_version().version_compare('>= 3.0')
-    pycairo_name = 'py3cairo'
-  else
-    pycairo_name = 'pycairo'
-  endif
-
   pycairo_dep = dependency(
-    pycairo_name,
+    'py3cairo',
     version: pycairo_version_req,
     fallback: ['pycairo', 'pycairo_dep'],
     default_options: ['python=' + get_option('python')],
diff --git a/setup.py b/setup.py
index 5de34b40..d1727ace 100755
--- a/setup.py
+++ b/setup.py
@@ -28,11 +28,7 @@ import posixpath
 
 from email import parser
 
-try:
-    from setuptools import setup
-except ImportError:
-    from distutils.core import setup
-
+from setuptools import setup
 from distutils.core import Extension, Distribution, Command
 from distutils.errors import DistutilsSetupError, DistutilsOptionError
 from distutils.ccompiler import new_compiler
@@ -63,10 +59,6 @@ def get_command_class(name):
     return Distribution({}).get_command_class(name)
 
 
-def get_pycairo_pkg_config_name():
-    return "py3cairo" if sys.version_info[0] == 3 else "pycairo"
-
-
 def get_version_requirement(pkg_config_name):
     """Given a pkg-config module name gets the minimum version required"""
 
@@ -74,7 +66,7 @@ def get_version_requirement(pkg_config_name):
         "gobject-introspection-1.0": GI_VERSION_REQUIRED,
         "glib-2.0": GLIB_VERSION_REQUIRED,
         "gio-2.0": GLIB_VERSION_REQUIRED,
-        get_pycairo_pkg_config_name(): PYCAIRO_VERSION_REQUIRED,
+        "py3cairo": PYCAIRO_VERSION_REQUIRED,
         "libffi": LIBFFI_VERSION_REQUIRED,
         "cairo": "0",
         "cairo-gobject": "0",
@@ -837,7 +829,7 @@ def get_pycairo_include_dir():
     Raises if pycairo isn't found or it's too old.
     """
 
-    pkg_config_name = get_pycairo_pkg_config_name()
+    pkg_config_name = "py3cairo"
     min_version = get_version_requirement(pkg_config_name)
     min_version_info = tuple(int(p) for p in min_version.split("."))
 
@@ -1111,9 +1103,6 @@ class build_ext(du_build_ext):
             add_ext_compiler_flags(gi_cairo_ext, compiler)
 
     def run(self):
-        if os.name == "nt" and sys.version_info[0] == 2:
-            raise SystemExit("Python 2 on Windows no longer supported since 3.35. Use Python 3 instead.")
-
         self._write_config_h()
         self._setup_extensions()
         du_build_ext.run(self)
@@ -1197,6 +1186,9 @@ class install(du_install):
 
 
 def main():
+    if sys.version_info[0] < 3:
+        raise Exception("Python 2 no longer supported")
+
     script_dir = get_script_dir()
     pkginfo = parse_pkg_info(script_dir)
     gi_dir = os.path.join(script_dir, "gi")
@@ -1235,8 +1227,7 @@ def main():
         )
         ext_modules.append(gi_cairo_ext)
         install_requires.append(
-            "pycairo>=%s" % get_version_requirement(
-                get_pycairo_pkg_config_name()))
+            "pycairo>=%s" % get_version_requirement("py3cairo"))
 
     version = pkginfo["Version"]
     if is_dev_version():
@@ -1275,8 +1266,7 @@ def main():
             "install_pkgconfig": install_pkgconfig,
         },
         install_requires=install_requires,
-        python_requires=(
-            '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4'),
+        python_requires=pkginfo["Requires-Python"],
         data_files=[
             ('include/pygobject-3.0', ['gi/pygobject.h']),
         ],


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]