Bug 269325

Summary: textproc/py-pyphen: 0.13.0 does not work with print/py-weasyprint 51
Product: Ports & Packages Reporter: Kurt Jaeger <pi>
Component: Individual Port(s)Assignee: Yuri Victorovich <yuri>
Status: Closed FIXED    
Severity: Affects Some People CC: darcy, grahamperrin, pi, yuri
Priority: --- Flags: bugzilla: maintainer-feedback? (darcy)
grahamperrin: maintainer-feedback? (yuri)
Version: Latest   
Hardware: Any   
OS: Any   
URL: https://www.freshports.org/textproc/py-pyphen/

Description Kurt Jaeger freebsd_committer freebsd_triage 2023-02-04 19:42:43 UTC
testing weasyprint (on 13.1-amd64), it fails with:

pkg_resources.DistributionNotFound: The 'Pyphen>=0.9.1' distribution was not found and is required by WeasyPrint

py39-weasyprint-51 and py39-pyphen-0.13.0 are installed.
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2023-02-06 07:14:15 UTC
Workaround and reproduction
===========================

After installing the port of WeasyPrint: 

pip install weasyprint

– pip installs a slightly superior version of Pyphen, which does work with the port of WeasyPrint. 

Then: 

pip uninstall Pyphen

– leaves the port of Pyphen not working with the port of WeasyPrint. 

----

% pip install weasyprint
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: weasyprint in /usr/local/lib/python3.9/site-packages (51)
Requirement already satisfied: setuptools>=39.2.0 in ./.local/lib/python3.9/site-packages (from weasyprint) (67.1.0)
Requirement already satisfied: cffi>=0.6 in ./.local/lib/python3.9/site-packages (from weasyprint) (1.15.1)
Requirement already satisfied: html5lib>=0.999999999 in ./.local/lib/python3.9/site-packages (from weasyprint) (1.1)
Requirement already satisfied: cairocffi>=0.9.0 in /usr/local/lib/python3.9/site-packages (from weasyprint) (1.4.0)
Requirement already satisfied: tinycss2>=1.0.0 in /usr/local/lib/python3.9/site-packages (from weasyprint) (1.2.1)
Requirement already satisfied: cssselect2>=0.1 in /usr/local/lib/python3.9/site-packages (from weasyprint) (0.7.0)
Requirement already satisfied: CairoSVG>=2.4.0 in /usr/local/lib/python3.9/site-packages (from weasyprint) (2.6.0)
Collecting Pyphen>=0.9.1
  Downloading pyphen-0.13.2-py3-none-any.whl (2.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 785.0 kB/s eta 0:00:00
Requirement already satisfied: defusedxml in /usr/local/lib/python3.9/site-packages (from CairoSVG>=2.4.0->weasyprint) (0.7.1)
Requirement already satisfied: pillow in ./.local/lib/python3.9/site-packages (from CairoSVG>=2.4.0->weasyprint) (9.4.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=0.6->weasyprint) (2.21)
Requirement already satisfied: webencodings in /usr/local/lib/python3.9/site-packages (from cssselect2>=0.1->weasyprint) (0.5.1)
Requirement already satisfied: six>=1.9 in /usr/local/lib/python3.9/site-packages (from html5lib>=0.999999999->weasyprint) (1.16.0)
Installing collected packages: Pyphen
Successfully installed Pyphen-0.13.2
% man weasyprint
No manual entry for weasyprint
% weasyprint
usage: weasyprint [-h] [--version] [-i] [-e ENCODING] [-f {pdf,png}] [-s STYLESHEET] [-m MEDIA_TYPE] [-r RESOLUTION] [-u BASE_URL] [-a ATTACHMENT] [-p] [-v] [-d] [-q] input output
weasyprint: error: the following arguments are required: input, output
% which weasyprint
/usr/local/bin/weasyprint
% pkg provides /usr/local/bin/weasyprint
Name    : py39-weasyprint-51
Comment : Converts HTML/CSS documents to PDF
Repo    : FreeBSD
Filename: usr/local/bin/weasyprint
% weasyprint --version
WeasyPrint version 51
% pip uninstall Pyphen
Found existing installation: pyphen 0.13.2
Uninstalling pyphen-0.13.2:
  Would remove:
    /usr/home/grahamperrin/.local/lib/python3.9/site-packages/pyphen-0.13.2.dist-info/*
    /usr/home/grahamperrin/.local/lib/python3.9/site-packages/pyphen/*
Proceed (Y/n)? Y
  Successfully uninstalled pyphen-0.13.2
% weasyprint --version
Traceback (most recent call last):
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 617, in _build_master
    ws.require(__requires__)
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 956, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 861, in _resolve_dist
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pyphen 0.0.0 (/usr/local/lib/python3.9/site-packages), Requirement.parse('Pyphen>=0.9.1'), {'WeasyPrint'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 33, in <module>
    sys.exit(load_entry_point('WeasyPrint==51', 'console_scripts', 'weasyprint')())
  File "/usr/local/bin/weasyprint", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/lib/python3.9/site-packages/weasyprint/__init__.py", line 440, in <module>
    from .css import preprocess_stylesheet  # noqa isort:skip
  File "/usr/local/lib/python3.9/site-packages/weasyprint/css/__init__.py", line 30, in <module>
    from . import computed_values, media_queries
  File "/usr/local/lib/python3.9/site-packages/weasyprint/css/computed_values.py", line 18, in <module>
    from .. import text
  File "/usr/local/lib/python3.9/site-packages/weasyprint/text.py", line 16, in <module>
    import pyphen
  File "/usr/local/lib/python3.9/site-packages/pyphen/__init__.py", line 25, in <module>
    from pkg_resources import resource_filename
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3249, in <module>
    def _initialize_master_working_set():
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3223, in _call_aside
    f(*args, **kwargs)
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3261, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 619, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 632, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(
  File "/home/grahamperrin/.local/lib/python3.9/site-packages/pkg_resources/__init__.py", line 856, in _resolve_dist
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Pyphen>=0.9.1' distribution was not found and is required by WeasyPrint
% pkg info -x pyphen
py39-pyphen-0.13.0
%
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2023-02-06 07:23:57 UTC
Re: comment #1

I do not know Python, but 0.0.0 below appears wrong to me: 

% pkg info --list textproc/py-pyphen
py39-pyphen-0.13.0:
        /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/PKG-INFO
        /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/SOURCES.txt
        /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/dependency_links.txt
        /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/requires.txt
        /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/top_level.txt
        /usr/local/lib/python3.9/site-packages/pyphen/__init__.py
        /usr/local/lib/python3.9/site-packages/pyphen/__pycache__/__init__.cpython-39.opt-1.pyc
        /usr/local/lib/python3.9/site-packages/pyphen/__pycache__/__init__.cpython-39.pyc
        /usr/local/share/licenses/py39-pyphen-0.13.0/GPLv2
        /usr/local/share/licenses/py39-pyphen-0.13.0/LGPL21
        /usr/local/share/licenses/py39-pyphen-0.13.0/LICENSE
        /usr/local/share/licenses/py39-pyphen-0.13.0/MPL11
        /usr/local/share/licenses/py39-pyphen-0.13.0/catalog.mk
% head -n 3 /usr/local/lib/python3.9/site-packages/pyphen-0.0.0-py3.9.egg-info/PKG-INFO
Metadata-Version: 2.1
Name: pyphen
Version: 0.0.0
%
Comment 3 Yuri Victorovich freebsd_committer freebsd_triage 2023-02-06 10:04:32 UTC
textproc/py-pyphen is changed to pep517.

Please retest.
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-02-06 10:05:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=458573c3a6d4b44ac1e10714b674d34ebe703f88

commit 458573c3a6d4b44ac1e10714b674d34ebe703f88
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-02-06 10:02:57 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-02-06 10:04:32 +0000

    textproc/py-pyphen: Change build to pep517

    PR:             269325
    Reported by:    pi@

 textproc/py-pyphen/Makefile | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
Comment 5 Kurt Jaeger freebsd_committer freebsd_triage 2023-02-06 12:44:16 UTC
(In reply to Yuri Victorovich from comment #3)
Thanks, worked!