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

Fixed issue #609 - method to detect VCS backend #636

Closed
wants to merge 3 commits into from

Conversation

fabiocerqueira
Copy link

http://stackoverflow.com/questions/11935786/pip-freeze-reports-version-number-instead-of-git-sha-for-certain-package

After I saw this question I tried fix this, I don't know if is the best way, but now works ok.

@travisbot
Copy link

This pull request fails (merged 3870f51 into 1749343).

@qwcode
Copy link
Contributor

qwcode commented Aug 15, 2012

this issue is different than #609.
#609 is concerned with why pip freeze doesn't report the vcs url when you leave off the "-e".
in this stackoverflow, piplint is being installed with "-e" but pip freeze is still not reporting the vcs url for whatever reason.

@qwcode
Copy link
Contributor

qwcode commented Aug 15, 2012

hey @fabiocerqueira, can you help me out and explain what you think the issue is with piplint and why pip freeze fails to do what we expect for it?

@fabiocerqueira
Copy link
Author

@qwcode pip freeze verify if a package is editable through of directory to a VCS(.svn, .git, .hg, .bzr), but the dist.location to piplint doesn't have a directory like this.

The dist.location return: ~/.virtualenvs/pip/src/piplint/src, where doesn't have a .git, the git directory is on parent path.

@qwcode
Copy link
Contributor

qwcode commented Aug 15, 2012

thanks, so piplint's packages are nested under src and it's using package_dir={'': 'src'} in it's setup.py.
Pip using pkg_resources.distribution.location to try to find the vcs directory is just not good enough here.
so, you've got failures from TravisBot. maybe you can sort that out and come up with a better fix for this.
I'm not sure right off what the best way to handle this is w/o digging deeper.

@fabiocerqueira
Copy link
Author

I'm trying a new approach to solve the problem of VCS backend detection, but when I run the tests return a fail in test_git_works_with_editable_non_origin_repo.

I don't understand what this test is making. Can someone explain?

FAIL: tests.test_vcs_backends.test_git_works_with_editable_non_origin_repo
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/fabiocerqueira/sandbox/pip/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/Users/fabiocerqueira/sandbox/pip/tests/test_vcs_backends.py", line 142, in test_git_works_with_editable_non_origin_repo
    assert "Error when trying to get requirement" in result.stderr
AssertionError```

@travisbot
Copy link

This pull request fails (merged 1067bef into 1749343).

@travisbot
Copy link

This pull request passes (merged 54ad39f into 1749343).

@qwcode
Copy link
Contributor

qwcode commented Aug 21, 2012

one thought on another way to handle this w/o resorting to the respective VCS commands.

-- grab one of the egg-info lines out of dist.get_metadata('SOURCES.txt')
e.g. src/piplint.egg-info/PKG-INFO
-- split on dist.project_name, and use the first item to trim down the dist.location.
-- and I think that should leave you with the dir that should contain the VCS dir like .git or .hg

@mcdonc
Copy link
Contributor

mcdonc commented Sep 7, 2012

Random note about the attached patch: in the check_repository methods that were added, the "except Exception" clause (that presumably is meant to catch errors raised by subprocess.Popen or os.chdir, etc) will catch all exceptions. But the logic within the clause doesn't reraise, and "proc" will not be defined when it continues, and that will result in a name error.

e = sys.exc_info()[1]
logger.warn(
"Error %s while executing command %s" % (e, ' '.join(cmd)))
proc.wait()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the same issue @mcdonc mentioned in the VCS methods below - if an error is raised before the proc = line in the try block, this line will raise a NameError.

@qwcode
Copy link
Contributor

qwcode commented Feb 10, 2013

@fabiocerqueira, thanks for raising the awareness on this issue.
closing this pull, since I'm inclined to go with a solution like in #717 (although that's currently stalled)
If that falls thru for some reason, I'll keep this pull in mind.

@qwcode qwcode closed this Feb 10, 2013
sbidoul pushed a commit to sbidoul/pip that referenced this pull request Nov 21, 2015
Identify the likely root directory to pass to the vcs.get_backend_name instead of simply using dist.location. This is necessary to support version control systems such as git and mercurial where the VCS metadata directory only exists off of the root directory.

This is a fix for pypa#713, where "pip freeze" outputs the wrong value for a repository checked out from git if the package puts files in the "src"  directory.

This change is based on @qwcode's comments at pypa#636 (comment).
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants