Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce a warning when the installation of both pypdf & fpdf2 packages is detected #1042

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ This can also be enabled programmatically with `warnings.simplefilter('default',

## [2.7.7] - Not released yet
### Added
* basic support for `<image>` elements in SVG vector graphics inserted
* SVG importing now supports clipping paths, and `defs` tags anywhere in the SVG file
* Basic support for `<image>` elements in SVG vector graphics inserted
* SVG importing now supports clipping paths, and `<defs>` tags anywhere in the SVG file
* [`FPDF.fonts.FontFace`](https://py-pdf.github.io/fpdf2/fpdf/fonts.html#fpdf.fonts.FontFace): Now has a static `combine` method that allows overriding a default FontFace (e.g. for specific cells in a table). Unspecified properties of the override FontFace retain the values of the default.
* [`TextColumns()`](https://py-pdf.github.io/fpdf2/TextColumns.html) can now have images inserted (both raster and vector).
* [`TextColumns()`](https://py-pdf.github.io/fpdf2/TextColumns.html) can now advance to the next column with the new `new_column()` method or a FORM_FEED character (`\u000c`) in the text.
Expand Down
15 changes: 14 additions & 1 deletion fpdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* `fpdf.template.FlexTemplate`
"""

import sys
import warnings, sys

from .enums import Align, TextMode, XPos, YPos
from .errors import FPDFException
Expand All @@ -31,6 +31,19 @@
from .template import Template, FlexTemplate
from .deprecation import WarnOnDeprecatedModuleAttributes

try:
# This module only exists in PyFPDF, it has been removed in fpdf2 since v2.5.7:
# pylint: disable=import-self
from . import ttfonts

warnings.warn(
"You have both PyFPDF & fpdf2 installed. "
"Both packages cannot be installed at the same time as they share the same module namespace. "
"To only keep fpdf2, run: pip uninstall --yes pypdf && pip install --upgrade fpdf2"
)
except ImportError:
pass # no PyFPDF installation detected

FPDF_VERSION = _FPDF_VERSION
"Current fpdf2 version, also available as `__version__`"

Expand Down