From 9ab665c8f0d72a371aa7a0b6f27388f3280a7f26 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Thu, 14 Sep 2023 09:55:50 +0300 Subject: [PATCH] Drop support for Python <= 3.7 --- .github/workflows/main.yaml | 6 +++--- HISTORY.rst | 4 ++-- README.rst | 4 ++-- ci/before-script.sh | 2 +- pdfkit/__init__.py | 2 +- pdfkit/pdfkit.py | 12 ++++-------- setup.py | 7 ------- tox.ini | 2 +- 8 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 72b597e..c50ff91 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -7,13 +7,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11] + python-version: [3.8, 3.9, '3.10', 3.11] fail-fast: false steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -26,4 +26,4 @@ jobs: pip install nose - name: Run tests - run: nosetests -w tests \ No newline at end of file + run: nosetests -w tests diff --git a/HISTORY.rst b/HISTORY.rst index f0abb06..7470f24 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,7 +1,7 @@ Changelog --------- -* `1.0.1` - * Add support for Python 3.10 and Python 3.11 +* `2.0.0` + * Drop support for Python <= 3.7 * `1.0.0` * By default PDFKit now passes "quiet" option to wkhtmltopdf. Now if you need to get output you should pass "verbose=True" to API calls * Fix different issues with searching for wkhtmltopdf binary diff --git a/README.rst b/README.rst index 602d2e2..f0c9bd3 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ Python-PDFKit: HTML to PDF wrapper .. image:: https://badge.fury.io/py/pdfkit.svg :target: http://badge.fury.io/py/pdfkit -Python 2 and 3 wrapper for wkhtmltopdf utility to convert HTML to PDF using Webkit. +Python 3 wrapper for wkhtmltopdf utility to convert HTML to PDF using Webkit. This is adapted version of `ruby PDFKit `_ library, so big thanks to them! @@ -19,7 +19,7 @@ Installation .. code-block:: bash - $ pip install pdfkit (or pip3 for python3) + $ pip install pdfkit 2. Install wkhtmltopdf: diff --git a/ci/before-script.sh b/ci/before-script.sh index 81fda49..96d2536 100644 --- a/ci/before-script.sh +++ b/ci/before-script.sh @@ -2,6 +2,6 @@ WKHTML2PDF_VERSION='0.12.6-1' -sudo apt-get install -y build-essential xorg libssl-dev libxrender-dev wget gdebi +sudo apt-get install -y build-essential xorg libssl-dev libxrender-dev wget gdebi-core wget "https://github.com/wkhtmltopdf/packaging/releases/download/${WKHTML2PDF_VERSION}/wkhtmltox_${WKHTML2PDF_VERSION}.bionic_amd64.deb" sudo gdebi --n wkhtmltox_${WKHTML2PDF_VERSION}.bionic_amd64.deb diff --git a/pdfkit/__init__.py b/pdfkit/__init__.py index 31c052e..027c95c 100644 --- a/pdfkit/__init__.py +++ b/pdfkit/__init__.py @@ -4,7 +4,7 @@ """ __author__ = 'Golovanov Stanislav' -__version__ = '1.0.1' +__version__ = '2.0.0' __license__ = 'MIT' from .pdfkit import PDFKit diff --git a/pdfkit/pdfkit.py b/pdfkit/pdfkit.py index cde58d1..88b3c92 100644 --- a/pdfkit/pdfkit.py +++ b/pdfkit/pdfkit.py @@ -8,10 +8,6 @@ import io import codecs -# Python 2.x and 3.x support for checking string types -basestring = str.__mro__[-2] -unicode = type(u'') - class PDFKit(object): """ @@ -113,7 +109,7 @@ def _command(self, path=None): if self.source.isString() or self.source.isFileObj(): yield '-' else: - if isinstance(self.source.source, basestring): + if isinstance(self.source.source, str): yield self.source.to_s() else: for s in self.source.source: @@ -158,7 +154,7 @@ def to_pdf(self, path=None): args = self.command(path) if sys.platform == 'win32': - #hide cmd window + # hide cmd window startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE @@ -241,8 +237,8 @@ def _normalize_options(self, options): for optval in value: yield (normalized_key, optval) else: - normalized_value = '' if isinstance(value,bool) else value - yield (normalized_key, unicode(normalized_value) if value else value) + normalized_value = '' if isinstance(value, bool) else value + yield (normalized_key, str(normalized_value) if value else value) def _normalize_arg(self, arg): return arg.lower() diff --git a/setup.py b/setup.py index 99262c4..4006a34 100644 --- a/setup.py +++ b/setup.py @@ -39,13 +39,6 @@ def long_description(): author_email='stgolovanov@gmail.com', classifiers=[ 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.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', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', diff --git a/tox.ini b/tox.ini index a193343..2ccafd3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,py35,py36,py37,py38,py39,py310,py311 +envlist = py38,py39,py310,py311 [testenv] deps = pytest