Skip to content

Commit

Permalink
Fix bootstrapping for development
Browse files Browse the repository at this point in the history
- fix bootstrapping for Python 2.7

The bootstrap process uses `get-pip.py`, which in its latest version,
tries to bootstrap a Python 3 only version of pip.

We need to pass in a separate URL for a Python 2.7 compatible version of
get-pip.py.

- Handle different pip messages

e.g. on pip 20.3.4 the message for no updates is
"Requirement already up-to-date"

e.g. on pip 21.0.1 the message for no updates is
"Requirement already satisfied"
  • Loading branch information
jugmac00 committed Feb 20, 2021
1 parent db3d6e2 commit 3645619
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Change History

- Support python37, python38 and python39 in conditional section expressions

- Fix bootstrapping for python27 and python35


3.0.0a2 (2020-05-25)
====================
Expand Down
10 changes: 8 additions & 2 deletions dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ def install_pip():
tmp = tempfile.mkdtemp(prefix='buildout-dev-')
try:
get_pip = os.path.join(tmp, 'get-pip.py')
if sys.version_info < (3, ):
GET_PIP_URL = 'https://bootstrap.pypa.io/2.7/get-pip.py'
elif (sys.version_info.major, sys.version_info.minor) == (3, 5):
GET_PIP_URL = 'https://bootstrap.pypa.io/3.5/get-pip.py'
else:
GET_PIP_URL = 'https://bootstrap.pypa.io/get-pip.py'
with open(get_pip, 'wb') as f:
f.write(urlopen('https://bootstrap.pypa.io/get-pip.py').read())
f.write(urlopen(GET_PIP_URL).read())

sys.stdout.flush()
if subprocess.call([sys.executable, get_pip]):
Expand Down Expand Up @@ -83,7 +89,7 @@ def check_upgrade(package):
output = subprocess.check_output(
[sys.executable] + ['-m', 'pip', 'install', '--upgrade', package],
)
was_up_to_date = b"up-to-date" in output
was_up_to_date = b"up-to-date" in output or b"already satisfied" in output
if not was_up_to_date:
print(output.decode('utf8'))
return not was_up_to_date
Expand Down

0 comments on commit 3645619

Please sign in to comment.