mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
support &subdirectory option with freeze and git
This commit is contained in:
parent
23d86c90b6
commit
c1176b01dc
2 changed files with 35 additions and 1 deletions
|
@ -75,6 +75,9 @@
|
||||||
and when ``package_dir`` is used, so ``pip freeze`` works in more
|
and when ``package_dir`` is used, so ``pip freeze`` works in more
|
||||||
cases (:pull:`3258`)
|
cases (:pull:`3258`)
|
||||||
|
|
||||||
|
* Correctly freeze Git develop packages in presence of the &subdirectory
|
||||||
|
option (:pull:`3258`)
|
||||||
|
|
||||||
|
|
||||||
**7.1.2 (2015-08-22)**
|
**7.1.2 (2015-08-22)**
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,33 @@ class Git(VersionControl):
|
||||||
rv[ref_name] = commit
|
rv[ref_name] = commit
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
|
def _get_subdirectory(self, location):
|
||||||
|
"""Return the relative path of setup.py to the git repo root."""
|
||||||
|
# find the repo root
|
||||||
|
git_dir = self.run_command(['rev-parse', '--git-dir'],
|
||||||
|
show_stdout=False, cwd=location).strip()
|
||||||
|
if not os.path.isabs(git_dir):
|
||||||
|
git_dir = os.path.join(location, git_dir)
|
||||||
|
root_dir = os.path.join(git_dir, '..')
|
||||||
|
# find setup.py
|
||||||
|
orig_location = location
|
||||||
|
while not os.path.exists(os.path.join(location, 'setup.py')):
|
||||||
|
last_location = location
|
||||||
|
location = os.path.dirname(location)
|
||||||
|
if location == last_location:
|
||||||
|
# We've traversed up to the root of the filesystem without
|
||||||
|
# finding setup.py
|
||||||
|
logger.warning(
|
||||||
|
"Could not find setup.py for directory %s (tried all "
|
||||||
|
"parent directories)",
|
||||||
|
orig_location,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
# relative path of setup.py to repo root
|
||||||
|
if os.path.samefile(root_dir, location):
|
||||||
|
return None
|
||||||
|
return os.path.relpath(location, root_dir)
|
||||||
|
|
||||||
def get_src_requirement(self, dist, location, find_tags):
|
def get_src_requirement(self, dist, location, find_tags):
|
||||||
repo = self.get_url(location)
|
repo = self.get_url(location)
|
||||||
if not repo.lower().startswith('git:'):
|
if not repo.lower().startswith('git:'):
|
||||||
|
@ -214,7 +241,11 @@ class Git(VersionControl):
|
||||||
else:
|
else:
|
||||||
full_egg_name = '%s-dev' % egg_project_name
|
full_egg_name = '%s-dev' % egg_project_name
|
||||||
|
|
||||||
return '%s@%s#egg=%s' % (repo, current_rev, full_egg_name)
|
req = '%s@%s#egg=%s' % (repo, current_rev, full_egg_name)
|
||||||
|
subdirectory = self._get_subdirectory(location)
|
||||||
|
if subdirectory:
|
||||||
|
req += '&subdirectory=' + subdirectory
|
||||||
|
return req
|
||||||
|
|
||||||
def get_url_rev(self):
|
def get_url_rev(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue