How are pip and setuptools installed after a build from source?


I would like to know how are pip3 and setuptools installed after building python from source and doing an install. There are whl files for both setuptools and pip3 in the source, is there any specific command or script which in run that installs these in system when we do
python3 install

I see setuptools wheel file, is it installed using pip after pip’s installation? or is it installed as part of ensurepip? In which file can I find necessary lines of code regarding the same.

Thank you

When you build Python from source you don’t install it using python3 install. You install it using make install or make altinstall, and part of that process installs the vendored copy of ensurepip (with pip) in the Python installation tree. I do not know if it also installs setuptools, it may not.

As far as I can recall, the wheels for setuptools and pip are used by ensurepip, which in turn is used to populate virtual environments created by venv.

So if you run a command like python3 -m venv path/to/venv then Python will create a virtual environment at the path path/to/venv and install the two wheels in that environment.

You can also run python3 -m venv --without-pip path/to/venv to create an empty virtual environment and then populate it yourself with the command path/to/venv/bin/python -m ensurepip.

1 Like

The OPS is installing python from source, so this is not useful?
Or did you mean to say that venv also uses the ensurepip code just as the python install from source does?

The OP specifically mentions those files in their post, so I’m guessing that’s why @sinoroc is explaining what they are for.

1 Like