Skip to content
This repository was archived by the owner on Feb 26, 2019. It is now read-only.

Commit e251116

Browse files
authored
Merge pull request pypa#2 from DataDog/jaime/fixlog
[pip] fix paths + logging defaults
2 parents 2ad511d + 987c52e commit e251116

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/pip/_internal/download.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,27 @@ def __init__(self, path_to_tuf_config_file):
9191
with open(path_to_tuf_config_file) as tuf_config_file:
9292
tuf_config = json.load(tuf_config_file)
9393

94+
# Reconfigure TUF logging, we can use the pip log output
95+
tuf.settings.ENABLE_FILE_LOGGING = tuf_config.get('enable_logging', False)
96+
9497
# NOTE: The directory where TUF metadata for *all* repositories are
9598
# kept.
96-
tuf.settings.repositories_directory = tuf_config['repositories_dir']
99+
if os.path.is_abs(tuf_config['repositories_dir']):
100+
tuf.settings.repositories_directory = tuf_config['repositories_dir']
101+
else:
102+
tuf.settings.repositories_directory = os.path.join(
103+
os.path.dirname(path_to_tuf_config_file),
104+
tuf_config['repositories_dir']
105+
)
97106

98107
# NOTE: Tell TUF where SSL certificates are kept.
99108
tuf.settings.ssl_certificates = certifi.where()
100109

110+
101111
# NOTE: The directory where the targets for *this* repository is
102112
# cached. We hard-code this keep this to a subdirectory dedicated to
103113
# this repository.
104-
self.__targets_dir = os.path.join(tuf_config['repositories_dir'],
114+
self.__targets_dir = os.path.join(tuf.settings.repositories_directory,
105115
tuf_config['repository_dir'],
106116
'targets')
107117

@@ -164,6 +174,7 @@ def download(self, target_relpath, dest_dir, dest_filename):
164174
if 'TUF_CONFIG_FILE' in os.environ:
165175
import certifi
166176
import tuf.settings
177+
tuf.settings.ENABLE_FILE_LOGGING = False
167178

168179
from tuf.client.updater import Updater
169180

0 commit comments

Comments
 (0)