From 6264bc4f7d621a998ed3ae690a528c9ccec32f0d Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Mon, 31 Aug 2020 10:48:20 +0530 Subject: [PATCH 1/3] add changelog --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index ff5059d..3a4b955 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ pip install pyxpdf_data I would love to ship them with pyxpdf but some of these files have different license than pyxpdf so we have to distribute them seprately. + ## License While pyxpdf is licensed under the GPL, these encoding files have different license, and thus distributed separately. @@ -29,3 +30,19 @@ package see fonts/COPYING.affero The rest of module is licensed under MIT. + +## Changelog + +### v1.1.0 (04/08/2020) +- remove default settings for pyxpdf (now resides in pyxpdf itself) +- add option to disable rewriting of xpdfrc in `get_xpdfrc()` +- add 35 Postscript base fonts from ghostscript + +### v1.0.1 (31/03/2020) +- Fix `xpdfrc` path not readable when installed in system site package + +### v1.0 (20/03/2020) +- Initial Version + + + From 20ec55490d1c8225813810b1f511c325feab158b Mon Sep 17 00:00:00 2001 From: Manorit Chawdhry <40723245+manorit2001@users.noreply.github.com> Date: Tue, 22 Dec 2020 23:54:15 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a4b955..5f635bd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![Python package](https://github.com/ashutoshvarma/pyxpdf_data/workflows/Python%20package/badge.svg) -![PyPI](https://img.shields.io/pypi/v/pyxpdf_data) +[![Python package](https://github.com/ashutoshvarma/pyxpdf_data/workflows/Python%20package/badge.svg)](https://github.com/ashutoshvarma/pyxpdf_data/actions) +[![PyPI](https://img.shields.io/pypi/v/pyxpdf_data)](https://pypi.org/project/pyxpdf-data/) # pyxpdf_data This python package consists of encoding files for use with [pyxpdf](https://github.com/ashutoshvarma/pyxpdf). From 028b97d09e1afc09f1a315cc6467546ce84558bc Mon Sep 17 00:00:00 2001 From: mush42 Date: Mon, 15 Feb 2021 12:24:06 +0200 Subject: [PATCH 3/3] * Added pyxpdf_data.get_xpdfrc_path function to dynamically generate the pyxpdf_rc file based on the current location of the package. This make the package compatible with code freezing tools such as PyInstaller. * This commit adds a PyPI dep 'appdirs' to the pyxpdf_data package. --- pyxpdf_data/__init__.py | 28 +++++++++++++++++++++++++--- setup.py | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pyxpdf_data/__init__.py b/pyxpdf_data/__init__.py index 1e81e6f..b7a5fa5 100644 --- a/pyxpdf_data/__init__.py +++ b/pyxpdf_data/__init__.py @@ -1,13 +1,15 @@ import os import time -from distutils.sysconfig import get_python_lib from pathlib import Path +from hashlib import md5 +from appdirs import AppDirs from .encodings import _get_encodings_block from .fonts import _get_fonts_block, get_fonts from .utils import POPPLER_DATA_DIR __version__ = "1.1.0" +PYXPDF_RC_PATH = "PYXPDF_RC_PATH" def _xpdfrc_header(): @@ -32,6 +34,25 @@ def generate_xpdfrc(): def get_poppler_dir(): return str(POPPLER_DATA_DIR) + +def get_xpdfrc_path(): + """ + Get the path of xpdfrc file. + + First try to get the path from an environment variable named `PYXPDF_RC_PATH`. + If the variable does not exist, fall back to the user application data directory + using appdirs package. + """ + if PYXPDF_RC_PATH in os.environ: + xpdf_rc_path = Path(os.environ[PYXPDF_RC_PATH]) + else: + pyxpdf_user_data_dir = AppDirs("pyxpdf", version=__version__).user_config_dir + # Make sure that this config file is unique to this instance as multiple pyxpdf_data installations + # may exist in one system (i.e. virtual environments and/or freezed applications). + data_path_hash = md5(str(POPPLER_DATA_DIR.resolve()).encode('utf-8')).hexdigest() + xpdf_rc_path = Path(pyxpdf_user_data_dir).joinpath(data_path_hash, "default.xpdf") + return xpdf_rc_path + def get_xpdfrc(force_rewrite=True): """ @@ -43,12 +64,13 @@ def get_xpdfrc(force_rewrite=True): generate xpdfrc again even if it exists already. Helpful if somehow xpdfrc file got corrupted. """ - xpdfrc_path = Path(get_python_lib(), "default.xpdf") + xpdfrc_path = get_xpdfrc_path() if (not xpdfrc_path.exists()) or force_rewrite: xpdfrc = generate_xpdfrc() + xpdfrc_path.parent.mkdir(parents=True, exist_ok=True) with open(str(xpdfrc_path), "w") as fp: fp.write(xpdfrc) - return str(xpdfrc_path.absolute()) + return str(xpdfrc_path.absolute().resolve()) __all__ = [get_fonts, get_xpdfrc, get_poppler_dir, generate_xpdfrc] diff --git a/setup.py b/setup.py index e41ded6..aecd588 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ author_email="ashutoshvarma11@live.com", url="https://github.com/ashutoshvarma/pyxpdf_data", license="MIT", + install_requires=["appdirs",], classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3.4",