Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop installing setuptools and wheel on Python 3.12+ #218

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# get-pip.py

`get-pip.py` is a bootstrapping script that enables users to install pip,
setuptools, and wheel in Python environments that don't already have them. You
`get-pip.py` is a bootstrapping script that enables users to install pip
in Python environments that don't already have it installed. You
should not directly reference the files located in this repository and instead
use the versions located at <https://bootstrap.pypa.io/>.

Expand All @@ -12,26 +12,34 @@ $ curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$ python get-pip.py
```

Upon execution, `get-pip.py` will install `pip`, `setuptools` and `wheel` in
the current Python environment.
Upon execution, `get-pip.py` will install the latest version of `pip` into the
current Python environment. When using Python 3.11 or older, by default the
packages `setuptools` and `wheel` will also be installed if an existing version
of them was not found.

It is possible to provide additional arguments to the underlying script. These
are passed through to the underlying `pip install` command, and can thus be
used to constraint the versions of the packages, or to pass other pip options
such as `--no-index`.
used to constrain the versions of the packages, install additional packages,
or to pass other pip options such as `--no-index`.

```console
$ python get-pip.py "pip < 21.0" "setuptools < 50.0" "wheel < 1.0"
# Constrain the pip version
$ python get-pip.py "pip < 21.0"

# Force the installation of `setuptools` and `wheel` on newer Python versions.
$ python get-pip.py setuptools wheel

# Install packages from a local directory instead of PyPI.
$ python get-pip.py --no-index --find-links=/local/copies
```

### get-pip.py options

This script also has it's own options, which control which packages it will
This script also has its own options, which control which packages it will
install.

- `--no-setuptools`: do not attempt to install `setuptools`.
- `--no-wheel`: do not attempt to install `wheel`.
- `--no-setuptools`: Do not attempt to install `setuptools`. This is a no-op on Python 3.12+.
edmorley marked this conversation as resolved.
Show resolved Hide resolved
- `--no-wheel`: Do not attempt to install `wheel`. This is a no-op on Python 3.12+.

## Development

Expand Down
12 changes: 7 additions & 5 deletions public/3.6/get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@

def include_setuptools(args):
"""
Install setuptools only if absent and not excluded.
Install setuptools only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_setuptools
env = not os.environ.get("PIP_NO_SETUPTOOLS")
absent = not importlib.util.find_spec("setuptools")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def include_wheel(args):
"""
Install wheel only if absent and not excluded.
Install wheel only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_wheel
env = not os.environ.get("PIP_NO_WHEEL")
absent = not importlib.util.find_spec("wheel")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def determine_pip_install_arguments():
Expand Down Expand Up @@ -111,7 +113,7 @@ def bootstrap(tmpdir):
monkeypatch_for_cert(tmpdir)

# Execute the included pip and use it to install the latest pip and
# setuptools from PyPI
# any user-requested packages from PyPI.
from pip._internal.cli.main import main as pip_entry_point
args = determine_pip_install_arguments()
sys.exit(pip_entry_point(args))
Expand Down
12 changes: 7 additions & 5 deletions public/3.7/get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@

def include_setuptools(args):
"""
Install setuptools only if absent and not excluded.
Install setuptools only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_setuptools
env = not os.environ.get("PIP_NO_SETUPTOOLS")
absent = not importlib.util.find_spec("setuptools")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def include_wheel(args):
"""
Install wheel only if absent and not excluded.
Install wheel only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_wheel
env = not os.environ.get("PIP_NO_WHEEL")
absent = not importlib.util.find_spec("wheel")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def determine_pip_install_arguments():
Expand Down Expand Up @@ -111,7 +113,7 @@ def bootstrap(tmpdir):
monkeypatch_for_cert(tmpdir)

# Execute the included pip and use it to install the latest pip and
# setuptools from PyPI
# any user-requested packages from PyPI.
from pip._internal.cli.main import main as pip_entry_point
args = determine_pip_install_arguments()
sys.exit(pip_entry_point(args))
Expand Down
12 changes: 7 additions & 5 deletions public/get-pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@

def include_setuptools(args):
"""
Install setuptools only if absent and not excluded.
Install setuptools only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_setuptools
env = not os.environ.get("PIP_NO_SETUPTOOLS")
absent = not importlib.util.find_spec("setuptools")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def include_wheel(args):
"""
Install wheel only if absent and not excluded.
Install wheel only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_wheel
env = not os.environ.get("PIP_NO_WHEEL")
absent = not importlib.util.find_spec("wheel")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def determine_pip_install_arguments():
Expand Down Expand Up @@ -111,7 +113,7 @@ def bootstrap(tmpdir):
monkeypatch_for_cert(tmpdir)

# Execute the included pip and use it to install the latest pip and
# setuptools from PyPI
# any user-requested packages from PyPI.
from pip._internal.cli.main import main as pip_entry_point
args = determine_pip_install_arguments()
sys.exit(pip_entry_point(args))
Expand Down
12 changes: 7 additions & 5 deletions templates/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@

def include_setuptools(args):
"""
Install setuptools only if absent and not excluded.
Install setuptools only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_setuptools
env = not os.environ.get("PIP_NO_SETUPTOOLS")
absent = not importlib.util.find_spec("setuptools")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def include_wheel(args):
"""
Install wheel only if absent and not excluded.
Install wheel only if absent, not excluded and when using Python <3.12.
"""
cli = not args.no_wheel
env = not os.environ.get("PIP_NO_WHEEL")
absent = not importlib.util.find_spec("wheel")
return cli and env and absent
python_lt_3_12 = this_python < (3, 12)
return cli and env and absent and python_lt_3_12


def determine_pip_install_arguments():
Expand Down Expand Up @@ -111,7 +113,7 @@ def bootstrap(tmpdir):
monkeypatch_for_cert(tmpdir)

# Execute the included pip and use it to install the latest pip and
# setuptools from PyPI
# any user-requested packages from PyPI.
from pip._internal.cli.main import main as pip_entry_point
args = determine_pip_install_arguments()
sys.exit(pip_entry_point(args))
Expand Down
Loading