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

pip freeze doesn't show correct entry for mercurial packages that use subdirectories #7071

Closed
TonyBeswick opened this issue Sep 24, 2019 · 0 comments · Fixed by #7072
Closed
Labels
auto-locked Outdated issues that have been locked by automation C: vcs pip's interaction with version control systems like git, svn and bzr type: enhancement Improvements to functionality

Comments

@TonyBeswick
Copy link
Contributor

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

  1. 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)
  2. 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)
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Sep 24, 2019
@chrahunt chrahunt added C: vcs pip's interaction with version control systems like git, svn and bzr type: enhancement Improvements to functionality labels Oct 6, 2019
@triage-new-issues triage-new-issues bot removed S: needs triage Issues/PRs that need to be triaged labels Oct 6, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: vcs pip's interaction with version control systems like git, svn and bzr type: enhancement Improvements to functionality
Projects
None yet
2 participants