codrsquad / pickley

Automate installation of standalone python CLIs
MIT License
45 stars 7 forks source link

Some way of installing with extras #30

Open thatch opened 9 months ago

thatch commented 9 months ago

I'd like to be able to pickley install 'honesty[orjson]==0.3.0b1' but pickley appears to just split on == and assume the lhs is the project name.

The standard way of parsing these is:

>>> from packaging.requirements import Requirement
>>> req = Requirement("Honesty[orjson]==0.3.0b1")
>>> req.name # note that req.name is not canonicalized.
'Honesty'
>>> req.extras
{'orjson'}
>>> req.specifier
<SpecifierSet('==0.3.0b1')>
>>> str(req.specifier)
'==0.3.0b1'

>>> from packaging.version import Version
>>> list(req.specifier.filter([Version("0.2.1"), Version("0.3.0a5"), Version("0.3.0b1")]))
[<Version('0.3.0b1')>]

If you need to support legacy versions this gets only slightly harder, using packaging_legacy instead of legacy.