mirror of https://github.com/pypa/pip
gzip compress link metadata for a slight reduction in disk space
This commit is contained in:
parent
7591507dfe
commit
5a42ae469c
|
@ -5,6 +5,7 @@
|
||||||
# mypy: strict-optional=False
|
# mypy: strict-optional=False
|
||||||
|
|
||||||
import email.errors
|
import email.errors
|
||||||
|
import gzip
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
@ -437,7 +438,7 @@ class RequirementPreparer:
|
||||||
try:
|
try:
|
||||||
cached_path = self._metadata_cache.cache_path(req.link)
|
cached_path = self._metadata_cache.cache_path(req.link)
|
||||||
os.makedirs(str(cached_path.parent), exist_ok=True)
|
os.makedirs(str(cached_path.parent), exist_ok=True)
|
||||||
with cached_path.open("rb") as f:
|
with gzip.open(cached_path, mode="rt", encoding="utf-8") as f:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"found cached metadata for link %s at %s", req.link, f.name
|
"found cached metadata for link %s at %s", req.link, f.name
|
||||||
)
|
)
|
||||||
|
@ -466,7 +467,7 @@ class RequirementPreparer:
|
||||||
try:
|
try:
|
||||||
cached_path = self._metadata_cache.cache_path(req.link)
|
cached_path = self._metadata_cache.cache_path(req.link)
|
||||||
os.makedirs(str(cached_path.parent), exist_ok=True)
|
os.makedirs(str(cached_path.parent), exist_ok=True)
|
||||||
with cached_path.open("w") as f:
|
with gzip.open(cached_path, mode="wt", encoding="utf-8") as f:
|
||||||
cacheable_dist = CacheableDist.from_dist(req.link, metadata_dist)
|
cacheable_dist = CacheableDist.from_dist(req.link, metadata_dist)
|
||||||
args = cacheable_dist.to_json()
|
args = cacheable_dist.to_json()
|
||||||
logger.debug("caching metadata for link %s at %s", req.link, f.name)
|
logger.debug("caching metadata for link %s at %s", req.link, f.name)
|
||||||
|
|
Loading…
Reference in New Issue