1
1
"""Metadata generation logic for source distributions.
2
2
"""
3
3
4
+ import logging
5
+ import os
6
+
7
+ from pip ._internal .utils .misc import call_subprocess , ensure_dir
8
+ from pip ._internal .utils .setuptools_build import make_setuptools_shim_args
4
9
from pip ._internal .utils .typing import MYPY_CHECK_RUNNING
5
10
6
11
if MYPY_CHECK_RUNNING :
7
- from typing import Callable
12
+ from typing import Callable , List
8
13
from pip ._internal .req .req_install import InstallRequirement
9
14
15
+ logger = logging .getLogger (__name__ )
16
+
10
17
11
18
def get_metadata_generator (install_req ):
12
19
# type: (InstallRequirement) -> Callable[[InstallRequirement], None]
@@ -18,7 +25,34 @@ def get_metadata_generator(install_req):
18
25
19
26
def _generate_metadata_legacy (install_req ):
20
27
# type: (InstallRequirement) -> None
21
- install_req .run_egg_info ()
28
+ req_details_str = install_req .name or "from {}" .format (install_req .link )
29
+ logger .debug (
30
+ 'Running setup.py (path:%s) egg_info for package %s' ,
31
+ install_req .setup_py_path , req_details_str ,
32
+ )
33
+
34
+ # Compose arguments for subprocess call
35
+ base_cmd = make_setuptools_shim_args (install_req .setup_py_path )
36
+ if install_req .isolated :
37
+ base_cmd += ["--no-user-cfg" ]
38
+
39
+ # For non-editable installs, don't put the .egg-info files at the root,
40
+ # to avoid confusion due to the source code being considered an installed
41
+ # egg.
42
+ egg_base_option = [] # type: List[str]
43
+ if not install_req .editable :
44
+ egg_info_dir = os .path .join (install_req .setup_py_dir , 'pip-egg-info' )
45
+ egg_base_option = ['--egg-base' , egg_info_dir ]
46
+
47
+ # setuptools complains if the target directory does not exist.
48
+ ensure_dir (egg_info_dir )
49
+
50
+ with install_req .build_env :
51
+ call_subprocess (
52
+ base_cmd + ["egg_info" ] + egg_base_option ,
53
+ cwd = install_req .setup_py_dir ,
54
+ command_desc = 'python setup.py egg_info' ,
55
+ )
22
56
23
57
24
58
def _generate_metadata (install_req ):
0 commit comments