Merge branch 'feature/drop-pkg-resources'

This commit is contained in:
James R. Barlow
2021-09-14 00:31:36 -07:00
6 changed files with 26 additions and 13 deletions
+1
View File
@@ -6,6 +6,7 @@ on:
- master
- ci
- release/*
- feature/*
tags:
- v*
paths-ignore:
+3 -4
View File
@@ -56,7 +56,7 @@ master_doc = 'index'
# General information about the project.
project = 'ocrmypdf'
copyright = (
'2020, James R. Barlow. Licensed under Creative Commons Attribution-ShareAlike 4.0.'
'2021, James R. Barlow. Licensed under Creative Commons Attribution-ShareAlike 4.0.'
)
author = 'James R. Barlow'
@@ -88,11 +88,10 @@ if on_rtd:
]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
from pkg_resources import get_distribution, DistributionNotFound
from importlib_metadata import version as package_version
# The full version, including alpha/beta/rc tags.
release = get_distribution('ocrmypdf').version
release = package_version('ocrmypdf').version
version = '.'.join(release.split('.')[:2])
+2 -1
View File
@@ -49,12 +49,13 @@ install_requires =
cffi>=1.9.1 # must be a setup and install requirement
coloredlogs>=14.0 # strictly optional
img2pdf>=0.3.0,<0.5 # pure Python
importlib-metadata>=4 # until Python 3.8
importlib-resources>=5 # until Python 3.9
pdfminer.six!=20200720,>=20191110,<=20201018
pikepdf>=2.10.0
pikepdf<3;implementation_name=="pypy" and python_version=='3.6'
pluggy>=0.13.0,<2
reportlab>=3.5.66
setuptools
tqdm>=4
python_requires = >=3.6
include_package_data = True
+2 -2
View File
@@ -5,9 +5,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import pkg_resources
from importlib_metadata import version as _package_version
PROGRAM_NAME = 'ocrmypdf'
# Official PEP 396
__version__ = pkg_resources.get_distribution('ocrmypdf').version
__version__ = _package_version('ocrmypdf')
+8
View File
@@ -0,0 +1,8 @@
# © 2021 James R. Barlow: github.com/jbarlow83
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""Data files used to generate certain PDFs."""
+10 -6
View File
@@ -13,13 +13,17 @@ import base64
from pathlib import Path
from typing import Dict, Iterator, Union
import importlib_resources
import pikepdf
import pkg_resources
import pkg_resources # deprecated
# Deprecated
ICC_PROFILE_RELPATH = 'data/sRGB.icc'
# Deprecated
SRGB_ICC_PROFILE = pkg_resources.resource_filename('ocrmypdf', ICC_PROFILE_RELPATH)
SRGB_ICC_PROFILE_NAME = 'sRGB.icc'
def _postscript_objdef(
alias: str,
@@ -97,12 +101,12 @@ def generate_pdfa_ps(target_filename: Path, icc: str = 'sRGB'):
References:
Adobe PDFMARK Reference: https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdfmark_reference.pdf
"""
if icc == 'sRGB':
icc_profile = SRGB_ICC_PROFILE
else:
if icc != 'sRGB':
raise NotImplementedError("Only supporting sRGB")
bytes_icc_profile = Path(icc_profile).read_bytes()
bytes_icc_profile = importlib_resources.read_binary(
'ocrmypdf.data', SRGB_ICC_PROFILE_NAME
)
ps = '\n'.join(_make_postscript(icc, bytes_icc_profile, 3))
# We should have encoded everything to pure ASCII by this point, and