Skip to content

Commit

Permalink
Fix from-source and Python 3.12 build by removing hard-coded version (#…
Browse files Browse the repository at this point in the history
…922) (#923)

* fix(ci): update versions of everything including python

* docs: add changelog entry

* fix(ci): use black from last year

* fix(ci): fix linting and typechecking issues

* docs: put CHANGELOG entries in the right place

* fix(ci): use older pip/setuptools to tolerate bogus -VERSION-

* fix(ci): skip 3.12 for now, fix remaining nox

* chore: ignore

* fix: use setuptools_git_versioning instead of hack

* fix(ci): re-enable python 3.12

* fix(ci): remove version hack from release workflow

* fix(test): ensure path for tools in tests on 3.12

* Update documentation for minimum python version

* Update CHANGELOG.md

* Fix GitHub workflow by removing upper bound on pip and setuptools

* Fix test imports by always importing from root

* Fix import error in test_converter.py

* black

---------

Co-authored-by: Pieter Marsman <[email protected]>
  • Loading branch information
dhdaines and pietermarsman authored Dec 28, 2023
1 parent 997424d commit 38d48aa
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 45 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python ${{ env.default-python }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ env.default-python }}
- name: Upgrade pip, Install nox
Expand All @@ -75,7 +75,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ] # should have 3.12 too!
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -132,16 +132,6 @@ jobs:
uses: actions/checkout@v4
- name: Install dependencies
run: python -m pip install wheel
- name: Set version
run: |
if [[ "${{ github.ref }}" == "refs/tags/"* ]]
then
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,' | sed -e 's/^v//')
else
VERSION=$(date +%Y%m%d).$(date +%H%M%S)
fi
echo ${VERSION}
sed -i "s/__VERSION__/${VERSION}/g" pdfminer/__init__.py
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Generate changelog
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Pipfile.lock
.vscode/
pyproject.toml
poetry.lock
.eggs
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Small typo's and issues in the documentation ([#828](https://github.com/pdfminer/pdfminer.six/pull/828))
- Ignore non-Unicode cmaps in TrueType fonts ([#806](https://github.com/pdfminer/pdfminer.six/pull/806))

### Changed

- Using non-hardcoded version string and setuptools-git-versioning to enable installation from source and building on Python 3.12 ([#922](https://github.com/pdfminer/pdfminer.six/issues/922))


### Deprecated

- Usage of `if __name__ == "__main__"` where it was only intended for testing purposes ([#756](https://github.com/pdfminer/pdfminer.six/pull/756))

### Removed

- Support for Python 3.6 and 3.7 because they are end-of-life ([#923](https://github.com/pdfminer/pdfminer.six/pull/923))

## [20220524]

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import nox


PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] # should have 3.12
PYTHON_ALL_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
PYTHON_MODULES = ["pdfminer", "tools", "tests", "noxfile.py", "setup.py"]


Expand Down Expand Up @@ -37,16 +37,16 @@ def types(session):

@nox.session(python=PYTHON_ALL_VERSIONS)
def tests(session):
session.install("pip<23")
session.install("setuptools<58")
session.install("pip")
session.install("setuptools")
session.install("-e", ".[dev]")
session.run("pytest")


@nox.session
def docs(session):
session.install("pip<23")
session.install("setuptools<58")
session.install("pip")
session.install("setuptools")
session.install("-e", ".[docs]")
session.run(
"python", "-m", "sphinx", "-b", "html", "docs/source", "docs/build/html"
Expand Down
8 changes: 7 additions & 1 deletion pdfminer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
__version__ = "__VERSION__" # auto replaced with tag in github actions
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("pdfminer.six")
except PackageNotFoundError:
# package is not installed, return default
__version__ = "0.0"

if __name__ == "__main__":
print(__version__)
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import sys
from pathlib import Path

from setuptools import setup
from os import path

sys.path.append(str(Path(__file__).parent))
import pdfminer as package # noqa: E402

with open(path.join(path.abspath(path.dirname(__file__)), "README.md")) as f:
root_dir = Path(__file__).parent
with open(root_dir / "README.md", "rt") as f:
readme = f.read()

setup(
name="pdfminer.six",
version=package.__version__,
setuptools_git_versioning={
"enabled": True,
},
setup_requires=["setuptools-git-versioning<2"],
packages=["pdfminer"],
package_data={"pdfminer": ["cmap/*.pickle.gz", "py.typed"]},
install_requires=[
"charset-normalizer >= 2.0.0",
"cryptography >= 36.0.0",
'typing_extensions; python_version < "3.8"',
'importlib_metadata; python_version < "3.8"',
],
extras_require={
"dev": ["pytest", "nox", "black", "mypy == 0.931"],
Expand All @@ -45,10 +44,11 @@
python_requires=">=3.6",
classifiers=[
"Programming Language :: Python",
"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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand Down
Empty file added tests/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_converter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import io
from tempfile import TemporaryFile

from helpers import absolute_sample_path
from pdfminer.converter import PDFLayoutAnalyzer, PDFConverter
from pdfminer.high_level import extract_pages
from pdfminer.layout import LTChar, LTContainer, LTRect, LTLine, LTCurve
from pdfminer.pdfinterp import PDFGraphicState
from tests.helpers import absolute_sample_path


class TestPaintPath:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_font_size.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from helpers import absolute_sample_path
from pdfminer.high_level import extract_pages
from pdfminer.layout import LTChar, LTTextBox
from tests.helpers import absolute_sample_path


def test_font_size():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_highlevel_extracttext.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

from helpers import absolute_sample_path
from pdfminer.high_level import extract_text, extract_pages
from pdfminer.high_level import extract_pages, extract_text
from pdfminer.layout import LAParams, LTTextContainer
from tests.helpers import absolute_sample_path


def run_with_string(sample_path, laparams=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
LTTextBoxVertical,
)
from pdfminer.utils import Plane
from helpers import absolute_sample_path
from tests.helpers import absolute_sample_path


class TestGroupTextLines(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pdfdocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest

from helpers import absolute_sample_path
from pdfminer.pdfdocument import PDFDocument, PDFNoPageLabels
from pdfminer.pdfparser import PDFParser
from pdfminer.pdftypes import PDFObjectNotFound, dict_value, int_value
from tests.helpers import absolute_sample_path


class TestPdfDocument(object):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pdfpage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from helpers import absolute_sample_path
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfparser import PDFParser
from tests.helpers import absolute_sample_path


class TestPdfPage(object):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_tools_dumppdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from helpers import absolute_sample_path
from tempfilepath import TemporaryFilePath
from tests.helpers import absolute_sample_path
from tests.tempfilepath import TemporaryFilePath
from tools import dumppdf


Expand Down
6 changes: 3 additions & 3 deletions tests/test_tools_pdf2txt.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import filecmp
import os
from shutil import rmtree
from tempfile import mkdtemp
import filecmp

import tools.pdf2txt as pdf2txt
from helpers import absolute_sample_path
from tempfilepath import TemporaryFilePath
from tests.helpers import absolute_sample_path
from tests.tempfilepath import TemporaryFilePath


def run(sample_path, options=None):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import pytest

from helpers import absolute_sample_path
from pdfminer.layout import LTComponent
from pdfminer.utils import (
open_filename,
Plane,
shorten_str,
format_int_roman,
format_int_alpha,
format_int_roman,
open_filename,
shorten_str,
)
from tests.helpers import absolute_sample_path


class TestOpenFilename:
Expand Down

0 comments on commit 38d48aa

Please sign in to comment.