Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/pip/_internal/operations/build/metadata_legacy.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """Metadata generation logic for legacy source distributions. | |
2 """ | |
3 | |
4 import logging | |
5 import os | |
6 | |
7 from pip._internal.exceptions import InstallationError | |
8 from pip._internal.utils.setuptools_build import make_setuptools_egg_info_args | |
9 from pip._internal.utils.subprocess import call_subprocess | |
10 from pip._internal.utils.temp_dir import TempDirectory | |
11 from pip._internal.utils.typing import MYPY_CHECK_RUNNING | |
12 | |
13 if MYPY_CHECK_RUNNING: | |
14 from pip._internal.build_env import BuildEnvironment | |
15 | |
16 logger = logging.getLogger(__name__) | |
17 | |
18 | |
19 def _find_egg_info(directory): | |
20 # type: (str) -> str | |
21 """Find an .egg-info subdirectory in `directory`. | |
22 """ | |
23 filenames = [ | |
24 f for f in os.listdir(directory) if f.endswith(".egg-info") | |
25 ] | |
26 | |
27 if not filenames: | |
28 raise InstallationError( | |
29 f"No .egg-info directory found in {directory}" | |
30 ) | |
31 | |
32 if len(filenames) > 1: | |
33 raise InstallationError( | |
34 "More than one .egg-info directory found in {}".format( | |
35 directory | |
36 ) | |
37 ) | |
38 | |
39 return os.path.join(directory, filenames[0]) | |
40 | |
41 | |
42 def generate_metadata( | |
43 build_env, # type: BuildEnvironment | |
44 setup_py_path, # type: str | |
45 source_dir, # type: str | |
46 isolated, # type: bool | |
47 details, # type: str | |
48 ): | |
49 # type: (...) -> str | |
50 """Generate metadata using setup.py-based defacto mechanisms. | |
51 | |
52 Returns the generated metadata directory. | |
53 """ | |
54 logger.debug( | |
55 'Running setup.py (path:%s) egg_info for package %s', | |
56 setup_py_path, details, | |
57 ) | |
58 | |
59 egg_info_dir = TempDirectory( | |
60 kind="pip-egg-info", globally_managed=True | |
61 ).path | |
62 | |
63 args = make_setuptools_egg_info_args( | |
64 setup_py_path, | |
65 egg_info_dir=egg_info_dir, | |
66 no_user_config=isolated, | |
67 ) | |
68 | |
69 with build_env: | |
70 call_subprocess( | |
71 args, | |
72 cwd=source_dir, | |
73 command_desc='python setup.py egg_info', | |
74 ) | |
75 | |
76 # Return the .egg-info directory. | |
77 return _find_egg_info(egg_info_dir) |