If I install a package from git using https://pip.pypa.io/en/stable/reference/pip_install/#git does the specific commit that was checked out logged somewhere?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You could use knittl's idea to find the nearest commit -- the only modification below is to address the fact that you are comparing the git tree to an installed package, not a git repository:
Since the installed package may lack some of the directory structure of the git repository, make a new directory for the git repo. I'll use
html5lib
for an example:Now fetch the git tree:
Copy the installed package into the git repo:
Run
git diff
to compare the current state of the repo (with the installed package's code) to each revision in the git tree:This sorts by the number of files changed, then the number of insertions, then deletions. The output will look something like this:
The last item on each line is the associated git commit.
If the git history is very long you'll want to modify
git rev-list --all
to a range of commits. For example, usegit rev-list tag1..tag2
to search between two tags. If you know approximately when the package was installed, you might have a good guess for what tags to use. Usegit tag
to show the names of the possible tags. See the docs for more options.One possible alternative is to use
pip install --editable
. In such casepip
will clone the repo to$PREFIX/src/$egg_name
(where$PREFIX
is either your virtualenv directory or current working directory), and then just create andegg-link
pointing to that path. This way, you will easily be able to check current revision for the cloned repo.On the other hand, package installed this way might have different file structure than the one installed in a regularl way. So in some cases this won't work.
It is not. If you just want to know — lookup the commit at the head of the installed branch. If you want to install a specific commit — name the commit. For example: