di / pytest-reqs

py.test plugin for checking requirements files
https://pypi.org/p/pytest-reqs
MIT License
25 stars 6 forks source link

VCS link with version broken #25

Open jayvdb opened 6 years ago

jayvdb commented 6 years ago

(split off from https://github.com/di/pytest-reqs/issues/16#issuecomment-404087084)

There are two scenarios with VCS links which are broken, and packaging doesnt provide a solution yet: https://github.com/pypa/packaging/issues/133

VCS links with versions like git+https://github.com/baz/foo#egg=foo-1.1 become package names with version embedded like foo-1.1

{'comes_from': '-r vcs-link.txt (line 1)', 'req': <Requirement('foo-1.1')>, 'target_dir': None, '_wheel_cache': None, 'use_user_site': False, 'original_link': <Link git+https://github.com/baz/foo#egg=foo-1.1>, 'satisfied_by': None, '_egg_info_path': None, 'isolated': False, 'markers': None, 'source_dir': None, 'nothing_to_uninstall': False, 'uninstalled': None, 'as_egg': False, '_ideal_build_dir': None, 'conflicts_with': None, '_temp_build_dir': None, 'editable': False, 'update': True, 'prepared': False, 'link': <Link git+https://github.com/baz/foo#egg=foo-1.1>, 'pycompile': True, 'install_succeeded': None, 'constraint': False, 'extras': set([]), 'options': {}}

and the req object is

{'url': None, 'specifier': <SpecifierSet('')>, 'extras': set([]), 'name': u'foo-1.1', 'marker': None}

The project / package name is broken. The 1.1 should be the version. https://github.com/pypa/setuptools/blob/master/docs/setuptools.txt#L722

Little chance that pip is going to fix that in v9


If I have installed https://gitlab.com/coala/package_manager (master), the installed distribution looks like

>>> d['dependency-management']
dependency-management 0.5.0.dev0 (/home/jayvdb/projects/coala/libraries/package_manager)

Now if we use the following requirement, which works for pip and setuptools

git+https://gitlab.com/coala/package_manager#egg=dependency-management

We will have

<InstallRequirement object: dependency-management from git+https://github.com/baz/foo#egg=dependency-management (from -r vcs-link.txt (line 1)) editable=False>

with specifier <SpecifierSet('')>

Now the fun part. The empty specifier rejects the .dev0 in the installed version

>>> req.specifier.contains(d['dependency-management'].version)
False

When I reinstall with .dev0 removed, specifier.contains(..) becomes True.

Now I cant fault the logic of Specifer('') not matching develop versions. Matching dev versions should require something explicit to indicate that non-official releases are desired. (I havent tested with .post1 and other suffixes.)

The problem is that the requirement given doesnt have any specifiers.

Then the real kicker ; this also doesnt work:

--pre git+https://github.com/baz/foo#egg=dependency-management