|
27 | 27 | display_path,
|
28 | 28 | hide_url,
|
29 | 29 | hide_value,
|
| 30 | + is_installable_dir, |
30 | 31 | rmtree,
|
31 | 32 | )
|
32 | 33 | from pip._internal.utils.subprocess import CommandArgs, call_subprocess, make_command
|
@@ -68,23 +69,23 @@ def make_vcs_requirement_url(repo_url, rev, project_name, subdir=None):
|
68 | 69 | return req
|
69 | 70 |
|
70 | 71 |
|
71 |
| -def find_path_to_setup_from_repo_root(location, repo_root): |
| 72 | +def find_path_to_project_root_from_repo_root(location, repo_root): |
72 | 73 | # type: (str, str) -> Optional[str]
|
73 | 74 | """
|
74 |
| - Find the path to `setup.py` by searching up the filesystem from `location`. |
75 |
| - Return the path to `setup.py` relative to `repo_root`. |
76 |
| - Return None if `setup.py` is in `repo_root` or cannot be found. |
| 75 | + Find the the Python project's root by searching up the filesystem from |
| 76 | + `location`. Return the path to project root relative to `repo_root`. |
| 77 | + Return None if the project root is `repo_root`, or cannot be found. |
77 | 78 | """
|
78 |
| - # find setup.py |
| 79 | + # find project root. |
79 | 80 | orig_location = location
|
80 |
| - while not os.path.exists(os.path.join(location, 'setup.py')): |
| 81 | + while not is_installable_dir(location): |
81 | 82 | last_location = location
|
82 | 83 | location = os.path.dirname(location)
|
83 | 84 | if location == last_location:
|
84 | 85 | # We've traversed up to the root of the filesystem without
|
85 |
| - # finding setup.py |
| 86 | + # finding a Python project. |
86 | 87 | logger.warning(
|
87 |
| - "Could not find setup.py for directory %s (tried all " |
| 88 | + "Could not find a Python project for directory %s (tried all " |
88 | 89 | "parent directories)",
|
89 | 90 | orig_location,
|
90 | 91 | )
|
@@ -296,8 +297,8 @@ def should_add_vcs_url_prefix(cls, remote_url):
|
296 | 297 | def get_subdirectory(cls, location):
|
297 | 298 | # type: (str) -> Optional[str]
|
298 | 299 | """
|
299 |
| - Return the path to setup.py, relative to the repo root. |
300 |
| - Return None if setup.py is in the repo root. |
| 300 | + Return the path to Python project root, relative to the repo root. |
| 301 | + Return None if the project root is in the repo root. |
301 | 302 | """
|
302 | 303 | return None
|
303 | 304 |
|
|
0 commit comments