anntzer / pypi2pkgbuild

A PyPI to PKGBUILD converter.
MIT License
71 stars 6 forks source link

Do not install optional dependencies #27

Closed Real-Gecko closed 2 years ago

Real-Gecko commented 2 years ago

I've created package for https://pypi.org/project/djlint/ and it added optional dependencies as normal dependencies.

Take a look at here: https://github.com/Riverside-Healthcare/djLint/blob/master/pyproject.toml

coverage = { version = "^6.3.1", optional = true }
pytest = { version = "^7.0.1", optional = true }
pytest-cov = { version = "^3.0.0", optional = true }

image

As you can see they're not marked as optional during installation.

anntzer commented 2 years ago

The metadata reported by djlint (e.g. in djlint-1.9.3.dist-info/METADATA) is

Requires-Dist: PyYAML (>=6.0,<7.0)
Requires-Dist: click (>=8.0.1,<9.0.0)
Requires-Dist: colorama (>=0.4.4,<0.5.0)
Requires-Dist: coverage (>=6.3.1,<7.0.0)
Requires-Dist: cssbeautifier (>=1.14.4,<2.0.0)
Requires-Dist: html-tag-names (>=0.1.2,<0.2.0)
Requires-Dist: html-void-elements (>=0.1.0,<0.2.0)
Requires-Dist: importlib-metadata (>=4.11.0,<5.0.0)
Requires-Dist: jsbeautifier (>=1.14.4,<2.0.0)
Requires-Dist: pathspec (>=0.9.0,<0.10.0)
Requires-Dist: pytest (>=7.0.1,<8.0.0)
Requires-Dist: pytest-cov (>=3.0.0,<4.0.0)
Requires-Dist: regex (>=2022.1.18,<2023.0.0)
Requires-Dist: tomli (>=2.0.1,<3.0.0); python_version < "3.11"
Requires-Dist: tqdm (>=4.62.2,<5.0.0)

As you can see, the optionalness of coverage, pytest, and pytest-cov have been lost. I would believe that it is poetry's job to tag these dependencies as extras (e.g., following https://packaging.python.org/en/latest/specifications/core-metadata/#requires-dist-multiple-use) and perhaps you can report that to them(?); pypi2pkgbuild just follows whatever pip reports.

Real-Gecko commented 2 years ago

Well actually I believe this three shall be in dev category. I'm just curious why this packages were not marked as optional. How does pypi2pkgbuild know that dependency is optional?

anntzer commented 2 years ago

It doesn't know that, that's the point here...

Real-Gecko commented 2 years ago

So pypi2pkgbuild does not have such possibility at all? Or is it just this particular case with djlint?

anntzer commented 2 years ago

This is not currently supported by pypi2pkgbuild, but as noted above, poetry doesn't actually report that the dependencies are optional, in any case.

Real-Gecko commented 2 years ago

Can you please explain how do you get info from poetry?

Real-Gecko commented 2 years ago

As far as I can see they've already fixed it on djLint side. https://github.com/Riverside-Healthcare/djLint/issues/322 Yet, I'm still curious if this feature can be added to pypi2pkgbuild.

anntzer commented 2 years ago

As noted in the issue you linked, this was incorrect/buggy metadata on djilint's side.

Real-Gecko commented 2 years ago

But they were marked as optional in pyproject.toml. https://github.com/Riverside-Healthcare/djLint/blob/b4c835ca213e02a640d87916a8e165d5c6a22516/pyproject.toml#L39 So is it poetry incorrectly reporting "optionality" or is it something else?

anntzer commented 2 years ago

Yes.