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

After install python packages 'Brotli' and 'zopfli' are not in 'Requires' list of 'weasyprint' package #1568

Closed
mPyth opened this issue Feb 11, 2022 · 7 comments

Comments

@mPyth
Copy link
Contributor

mPyth commented Feb 11, 2022

Problem is observed in two distinct virtual environments (one based on python 3.7 and another one on python 3.10), with older and the newest pip (v22.0.3), with the newest version of weasyprint (v54.1).

It is simple to reproduce by using command pip show weasyprint or pipdeptree (that command needs previous install of the same name python package).

Here is example of running pipdeptree in my environment:

(vEnvDjango32) c:\pyth\virtEnvs>pipdeptree
Brotli==1.0.9
cx-Oracle==8.3.0
Django==3.2
  - asgiref [required: >=3.3.2,<4, installed: 3.5.0]
    - typing-extensions [required: Any, installed: 4.0.1]
  - pytz [required: Any, installed: 2021.3]
  - sqlparse [required: >=0.2.2, installed: 0.4.2]
openpyxl==3.0.9
  - et-xmlfile [required: Any, installed: 1.1.0]
pendulum==2.1.2
  - python-dateutil [required: >=2.6,<3.0, installed: 2.8.2]
    - six [required: >=1.5, installed: 1.16.0]
  - pytzdata [required: >=2020.1, installed: 2020.1]
pipdeptree==2.2.1
  - pip [required: >=6.0.0, installed: 20.1.1]
psycopg2-binary==2.9.3
schedule==1.1.0
setuptools==47.1.0
weasyprint==54.1
  - cffi [required: >=0.6, installed: 1.15.0]
    - pycparser [required: Any, installed: 2.21]
  - cssselect2 [required: >=0.1, installed: 0.4.1]
    - tinycss2 [required: Any, installed: 1.1.1]
      - webencodings [required: >=0.4, installed: 0.5.1]
    - webencodings [required: Any, installed: 0.5.1]
  - fonttools [required: >=4.0.0, installed: 4.29.1]
  - html5lib [required: >=1.1, installed: 1.1]
    - six [required: >=1.9, installed: 1.16.0]
    - webencodings [required: Any, installed: 0.5.1]
  - Pillow [required: >=4.0.0, installed: 9.0.1]
  - pydyf [required: >=0.0.3, installed: 0.1.2]
  - Pyphen [required: >=0.9.1, installed: 0.12.0]
  - tinycss2 [required: >=1.0.0, installed: 1.1.1]
    - webencodings [required: >=0.4, installed: 0.5.1]
zopfli==0.1.9

After install of weasyprint two packages (Brotli and zopfli) are shown in 'root' layer of installed packages which is not expected (they should be indented inside weasyprint section). All other packages from this example have correct dependencies.
Command pip show weasyprint confirms this - in line Requires there is no those two packages.

@liZe
Copy link
Member

liZe commented Feb 12, 2022

Hello!

Brotli and Zopfli are optional dependencies of Fonttools. I don’t know why pipdeptree is not able to detect this, but I suppose that it’s not able to detect optional dependencies.

@mPyth
Copy link
Contributor Author

mPyth commented Feb 14, 2022

I've also thought that pipdeptree doesn't work as expected in the case of WeasyPrint. But, as I've mentioned, command pip show weasyprint does not show Brotli and zopfli as dependent packages, and those two packages appeared after install of WeasyPrint, so I concluded something is wrong with WeasyPrint.
I have impression that if problematic packages are optional dependencies of FontTools (that means FontTools does not depends on them), but because they are needed for WeasyPrint those two packages should become 'standard' dependencies of the WeasyPrint. Remark: I don't have experience with Python packaging, I'm just think out loud.

@liZe
Copy link
Member

liZe commented Feb 14, 2022

I have impression that if problematic packages are optional dependencies of FontTools (that means FontTools does not depends on them), but because they are needed for WeasyPrint those two packages should become 'standard' dependencies of the WeasyPrint.

WeasyPrint depends on fonttools[woff], and it means that it automatically installs these dependencies. Everything is explicit in WeasyPrint and in Fonttools, that’s why the packages are installed when you install WeasyPrint :). There’s nothing wrong in WeasyPrint, there’s nothing wrong in Fonttools.

@mPyth
Copy link
Contributor Author

mPyth commented Feb 22, 2022

Something is definitely not OK. It is possible to make simple experiment on freshly new virtual environment - by installing latest version of WeasyPrint and pipdeptree and call sequence of next commands (pipdeptree is not so important for further analysis):

Command pip show weasyprint in last two lines shows next output:

Requires: Pillow, tinycss2, Pyphen, fonttools, html5lib, cssselect2, pydyf, cffi
Required-by:

Observe: Requires does not show Brotli and zopfli which is likely OK because they are not direct dependencies. Required-by is empty and correct.

Command pip show html5lib in last two lines shows next output:

Requires: six, webencodings
Required-by: weasyprint

Observe: Required-by contains weasyprint which is correct. Requires shows six and webencodings . pipDepTree shows exactly this dependency.

Command pip show fonttools in last two lines shows next output:

Requires:
Required-by: weasyprint

Observe: Requires is empty, and it should probably contain Brotli and zopfli.

Command pip show Brotli in last two lines shows next output (the same output gives command pip show zopfli):

Requires:
Required-by:

Observe: Required-by is empty which means that libs Brotli and zopfli are not required by any other lib which does not correspond to the truth (the result is such as those two packages are installed directly by using pip).

The same command could be called for cssselect2 and output is correct.
The result is not expected (and not correct) only for fonttools (section Requires), Brotli and zopfli (section Required-by). I have impression that Brotli and zopfli must be required by fonttools (more likely) or WeasyPrint (less likely).
Maybe it could be a bug in fonttools packaging.
What do you think ?

@liZe
Copy link
Member

liZe commented Feb 22, 2022

What do you think ?

pip show is not able to show optional dependencies. That’s a feature missing in pip: pypa/pip#4824.

@liZe liZe closed this as completed Feb 22, 2022
@mPyth
Copy link
Contributor Author

mPyth commented Feb 23, 2022

Uuuh, I didn't expect that, they make possible to have optional (extra) dependencies but not possible to see them after install !
Nice catch.

@ralphie0112358
Copy link

pipdeptree has a related ticket. tox-dev/pipdeptree#107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants