Repository: btel/svg_utils (language: python)

Issue:
Plans for dropping support for end-of-life Python 2.7 and 3.5?
Hi!

The oldest version of Python that has *not* [reached end of life](https://endoflife.date/python) as of today is Python 3.6. The svgutils code base currently supports 2.7 and 3.5 officially and in practice. I have seen people have vastly different opinions on which versions of Python should be supported by a project in 2021, before. So I would just like to hear what the current plan or approach about end-of-life Python is, and then see how and if I can help.
A benefit of dropping support for old versions, is that we could e.g. start using [f-strings](https://www.python.org/dev/peps/pep-0498/) and [type hints](https://docs.python.org/3/library/typing.html) in this code base if we wanted, in general.

Best, Sebastian

Plans for dropping support for end-of-life Python 2.7 and 3.5?
Hi!

The oldest version of Python that has *not* [reached end of life](https://endoflife.date/python) as of today is Python 3.6. The svgutils code base currently supports 2.7 and 3.5 officially and in practice. I have seen people have vastly different opinions on which versions of Python should be supported by a project in 2021, before. So I would just like to hear what the current plan or approach about end-of-life Python is, and then see how and if I can help.
A benefit of dropping support for old versions, is that we could e.g. start using [f-strings](https://www.python.org/dev/peps/pep-0498/) and [type hints](https://docs.python.org/3/library/typing.html) in this code base if we wanted, in general.

Best, Sebastian



Discussion / hints:
sure, I am fine with dropping Python 2.x or even <=3.5 in 0.4.0. Especially if some features of >3.5 will be useful in the code base.
Okay, I'll prepare a pull request in a minute.
sure, I am fine with dropping Python 2.x or even <=3.5 in 0.4.0. Especially if some features of >3.5 will be useful in the code base.
Okay, I'll prepare a pull request in a minute.

Fix patch:
diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml
index 7a9bd04..2cf8799 100644
--- a/.github/workflows/black.yml
+++ b/.github/workflows/black.yml
@@ -9,3 +9,5 @@ jobs:
       - uses: actions/checkout@v2.3.4
       - uses: actions/setup-python@v2.1.4
       - uses: psf/black@20.8b1
+        env:
+          INPUT_BLACK_ARGS: --target-version py36
diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml
index e38c6a2..9e20097 100644
--- a/.github/workflows/python-publish.yml
+++ b/.github/workflows/python-publish.yml
@@ -20,12 +20,12 @@ jobs:
         python-version: '3.x'
     - name: Install dependencies
       run: |
-        python -m pip install --upgrade pip
-        pip install setuptools wheel twine
+        python3 -m pip install --upgrade pip
+        pip3 install setuptools wheel twine
     - name: Build and publish
       env:
         TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
         TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
       run: |
-        python setup.py sdist bdist_wheel
+        python3 setup.py sdist bdist_wheel
         twine upload dist/*
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ad879de..5867440 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,4 +3,5 @@ repos:
     rev: 20.8b1
     hooks:
       - id: black
-        language_version: python3 
+        language_version: python3
+        args: ['--target-version', 'py36']
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index a31a0f4..3cfe5c5 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -18,7 +18,7 @@ This project uses [black](https://github.com/psf/black) for automatically format
 You can run the check and formatting hooks using pre-commit:
 
 ```
-pip install pre-commit
+pip3 install pre-commit
 pre-commit run --all
 ```
 
diff --git a/README.rst b/README.rst
index 4c8b391..d80b6a6 100644
--- a/README.rst
+++ b/README.rst
@@ -23,11 +23,11 @@ Install
 From PyPI
 `````````
 
-You can install `svgutils` from Python Package Index (PyPI) using the `pip` utility::
+You can install `svgutils` from Python Package Index (PyPI) using the `pip3` utility::
 
-   pip install svgutils --user
+   pip3 install svgutils --user
 
-Note that the `pip` will attempt to install `lxml` library if it is not already installed.
+Note that the `pip3` will attempt to install `lxml` library if it is not already installed.
 For the installation to be sucessful, you need development libraries of `libxml2` and `libxslt1`.
 On Ubuntu and other Debian-derived Linux distributions you can install them via::
 
@@ -52,12 +52,12 @@ From sources
 
 To install system-wide (needs administrator privilages)::
 
-   python setup.py install
+   python3 setup.py install
 
 To install locally (do not forget to add
-``$HOME/python/lib/python2.6/site-packages/`` to your Python path)::
+``$HOME/python/lib/python3.6/site-packages/`` to your Python path)::
 
-   python setup.py install --user
+   python3 setup.py install --user
 
 License
 -------
diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst
index 505e415..099ac9d 100644
--- a/docs/source/getting_started.rst
+++ b/docs/source/getting_started.rst
@@ -10,11 +10,11 @@ Install
 From PyPI
 `````````
 
-You can install `svgutils` from Python Package Index (PyPI) using the `pip` utility::
+You can install `svgutils` from Python Package Index (PyPI) using the `pip3` utility::
 
-   pip install svgutils --user
+   pip3 install svgutils --user
 
-Note that the `pip` will attempt to install `lxml` library if it is not already installed.
+Note that the `pip3` will attempt to install `lxml` library if it is not already installed.
 For the installation to be sucessful, you need development libraries of `libxml2` and `libxslt1`.
 On Ubuntu and other Debian-derived Linux distributions you can install them via::
 
@@ -39,9 +39,9 @@ From sources
 
 To install system-wide (needs administrator privilages)::
 
-   python setup.py install
+   python3 setup.py install
 
 To install locally (do not forget to add
-``$HOME/python/lib/python2.6/site-packages/`` to your Python path)::
+``$HOME/python/lib/python3.6/site-packages/`` to your Python path)::
 
-   python setup.py install --user
+   python3 setup.py install --user
diff --git a/docs/source/tutorials/figures/Makefile b/docs/source/tutorials/figures/Makefile
index 108af65..655eaad 100644
--- a/docs/source/tutorials/figures/Makefile
+++ b/docs/source/tutorials/figures/Makefile
@@ -1,5 +1,5 @@
 all:
-	python ../scripts/anscombe.py
-	python ../scripts/sigmoid_fit.py
-	python ../scripts/fig_final.py
-	python ../scripts/fig_compose.py
+	python3 ../scripts/anscombe.py
+	python3 ../scripts/sigmoid_fit.py
+	python3 ../scripts/fig_final.py
+	python3 ../scripts/fig_compose.py
diff --git a/docs/source/tutorials/scripts/anscombe.py b/docs/source/tutorials/scripts/anscombe.py
index 1d87871..ba9aca0 100644
--- a/docs/source/tutorials/scripts/anscombe.py
+++ b/docs/source/tutorials/scripts/anscombe.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 
 Edward Tufte uses this example from Anscombe to show 4 datasets of x
diff --git a/docs/source/tutorials/scripts/composing_multipanel_figures_examples.py b/docs/source/tutorials/scripts/composing_multipanel_figures_examples.py
index 1afe056..d4fc1a0 100644
--- a/docs/source/tutorials/scripts/composing_multipanel_figures_examples.py
+++ b/docs/source/tutorials/scripts/composing_multipanel_figures_examples.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 from svgutils.compose import *
 
diff --git a/docs/source/tutorials/scripts/fig_compose.py b/docs/source/tutorials/scripts/fig_compose.py
index 2a711ff..cbb3705 100644
--- a/docs/source/tutorials/scripts/fig_compose.py
+++ b/docs/source/tutorials/scripts/fig_compose.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from svgutils.compose import *
diff --git a/examples/compose_example.py b/examples/compose_example.py
index 7cd22e3..de4c80e 100644
--- a/examples/compose_example.py
+++ b/examples/compose_example.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from svgutils.compose import *
diff --git a/examples/stack_plots.py b/examples/stack_plots.py
index 8b0552c..5f73e7b 100644
--- a/examples/stack_plots.py
+++ b/examples/stack_plots.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 import numpy as np
diff --git a/examples/stack_svg.py b/examples/stack_svg.py
index af97f63..09dcaba 100644
--- a/examples/stack_svg.py
+++ b/examples/stack_svg.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from svgutils.transform import fromfile
diff --git a/setup.py b/setup.py
index 3e31e66..d2c2f5a 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from setuptools import setup
@@ -24,19 +24,18 @@
         "Intended Audience :: Science/Research",
         "License :: OSI Approved :: MIT License",
         "Operating System :: OS Independent",
+        "Programming Language :: Python :: 3 :: Only",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.6",
-        "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 2.7",
-        "Programming Language :: Python :: 2",
         "Topic :: Multimedia :: Graphics :: Editors :: Vector-Based",
         "Topic :: Scientific/Engineering :: Visualization",
         "Topic :: Text Processing :: Markup",
     ],
     package_dir={"": "src"},
+    python_requires=">=3.6",
     install_requires=["lxml"],
     download_url="https://github.com/btel/svg_utils/archive/v{}.tar.gz".format(
         version_str
diff --git a/src/svgutils/compose.py b/src/svgutils/compose.py
index 5aa6486..8a30a3b 100644
--- a/src/svgutils/compose.py
+++ b/src/svgutils/compose.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 """SVG definitions designed for easy SVG composing
 
diff --git a/src/svgutils/templates.py b/src/svgutils/templates.py
index d34a51c..e20c08d 100644
--- a/src/svgutils/templates.py
+++ b/src/svgutils/templates.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from svgutils.transform import SVGFigure, GroupElement


Test patch:
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index cfaa8c2..d1f45c7 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -12,7 +12,7 @@ jobs:
     name: Run the test suite
     strategy:
       matrix:
-        python-version: [2.7, 3.5, 3.9]  # no explicit need for 3.6, 3.7, 3.8
+        python-version: [3.6, 3.9]  # no explicit need for 3.7, 3.8
         runs-on: [macos-latest, ubuntu-latest]
     runs-on: ${{ matrix.runs-on }}
     steps:
@@ -22,9 +22,9 @@ jobs:
         python-version: ${{ matrix.python-version }}
     - name: Install runtime dependencies
       run: |
-        python --version
-        pip install --user -r requirements.txt
-        pip install --user -e .
+        python3 --version
+        pip3 install --user -r requirements.txt
+        pip3 install --user -e .
         echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}"
     - name: Run the test suite
       env:
diff --git a/tests/letter_spacing.py b/tests/letter_spacing.py
index 76aedea..a583dac 100644
--- a/tests/letter_spacing.py
+++ b/tests/letter_spacing.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 
 from svgutils import transform
diff --git a/tests/test_transform.py b/tests/test_transform.py
index 710c3be..7074ea6 100644
--- a/tests/test_transform.py
+++ b/tests/test_transform.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # coding=utf-8
 from tempfile import NamedTemporaryFile