pip freeze doesn't show correct entry for mercurial packages that use subdirectories · Issue #7071 · pypa/pip (original) (raw)
Environment
- pip version: 19.2.3
- Python version: 2.7.15 & 3.7.3
- OS: win10 & Ubuntu 18.04.3 LTS
Description
When a package is installed from a Mercurial (hg) repo and it uses either:
- a
setup.py
file that isn't located in the root directory of the repo, or - a package directory that isn't located in the root directory of the repo (e.g. uses a src directory)
Then pip freeze will output: # Editable install with no version control
for that package and omit the reference to version control.
#3258 added the ability for pip freeze
and pip list -e
to work correctly when either setup.py
or the source code is not in the root directory of a Git repository. This implementation was Git specific, the problem solved by #3258 still exists for Mercurial repositories.
How to Reproduce
- pip install a mercurial repository that has:
- a
setup.py
file that isn't located in the root directory of the repo, or - a package directory that isn't located in the root directory of the repo (e.g. uses a src directory)
- a
- run
pip freeze
and look for# Editable install with no version control
Its difficult to find such a repository publicly, so here is some test code that can be added to tests/functional/test_freeze.py
@need_mercurial
def test_freeze_mercurial_clone_srcdir(script, tmpdir):
"""
Test freezing a Mercurial clone where setup.py is in a subdirectory
relative to the repo root and the source code is in a subdirectory
relative to setup.py.
"""
# Returns path to a generated package called "version_pkg"
pkg_version = _create_test_package_with_srcdir(script, vcs='hg')
result = script.run(
'hg', 'clone', pkg_version, 'pip-test-package',
expect_stderr=True,
)
repo_dir = script.scratch_path / 'pip-test-package'
result = script.run(
'python', 'setup.py', 'develop',
cwd=repo_dir / 'subdir',
expect_stderr=True,
)
result = script.pip('freeze', expect_stderr=True)
expected = textwrap.dedent(
"""
...-e hg+...#egg=version_pkg&subdirectory=subdir
...
"""
).strip()
_check_output(result.stdout, expected)
result = script.pip(
'freeze', '-f', '%s#egg=pip_test_package' % repo_dir,
expect_stderr=True,
)
expected = textwrap.dedent(
"""
-f %(repo)s#egg=pip_test_package...
-e hg+...#egg=version_pkg&subdirectory=subdir
...
""" % {'repo': repo_dir},
).strip()
_check_output(result.stdout, expected)