mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Retry pypi.org requests on CI, or if an environment variable is set
Use PIPENV_MAX_RETRIES environment variable to determine how many times to retry requests to pypi.org. Default to 0 retries, unless running on CI, in which case default to 1 retry.
This commit is contained in:
@@ -23,6 +23,9 @@ PIPENV_COLORBLIND = bool(os.environ.get('PIPENV_COLORBLIND'))
|
||||
PIPENV_NOSPIN = bool(os.environ.get('PIPENV_NOSPIN'))
|
||||
# Tells Pipenv how many rounds of resolving to do for Pip-Tools.
|
||||
PIPENV_MAX_ROUNDS = int(os.environ.get('PIPENV_MAX_ROUNDS', '16'))
|
||||
# Specify how many retries Pipenv should attempt for network requests.
|
||||
default_retries = '1' if 'CI' in os.environ else '0'
|
||||
PIPENV_MAX_RETRIES = int(os.environ.get('PIPENV_MAX_RETRIES', default_retries))
|
||||
# Specify a custom Pipfile location.
|
||||
PIPENV_PIPFILE = os.environ.get('PIPENV_PIPFILE')
|
||||
# Tells Pipenv which Python to default to, when none is provided.
|
||||
|
||||
+7
-1
@@ -45,7 +45,11 @@ except ImportError:
|
||||
from distutils.spawn import find_executable
|
||||
from contextlib import contextmanager
|
||||
from .pep508checker import lookup
|
||||
from .environments import PIPENV_MAX_ROUNDS, PIPENV_CACHE_DIR
|
||||
from .environments import (
|
||||
PIPENV_MAX_ROUNDS,
|
||||
PIPENV_CACHE_DIR,
|
||||
PIPENV_MAX_RETRIES
|
||||
)
|
||||
|
||||
try:
|
||||
from collections.abc import Mapping
|
||||
@@ -72,6 +76,8 @@ def _get_requests_session():
|
||||
return requests_session
|
||||
import requests
|
||||
requests_session = requests.Session()
|
||||
adapter = requests.adapters.HTTPAdapter(max_retries=PIPENV_MAX_RETRIES)
|
||||
requests_session.mount('https://pypi.org/pypi', adapter)
|
||||
return requests_session
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user