1. Make sure [[#Getting pip|pip is available]] and up-to-date
2. Make sure there's a [[#Virtual environment]] (if appropriate)
3. Run the command
## Getting pip
- Use the `.pyz` file
- [Proposal](https://github.com/pypa/pip/issues/11243)
- [Location of `.pyz` file online](https://bootstrap.pypa.io/pip/)
- Follow the [XDG base directory spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) for where to store
- `$XDG_CACHE_HOME`|`$HOME/.cache`
- Handle updates automatically
- Check for updates in a separate thread
- Use [`Etag` and `Last-Modified`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests) to have the server make the decision
- Update the mtime of the cached header data file or recorde the last check so the attempt to download is only done once a day
- Replace the old file **after** everything else has executed (can't guarantee everything was loaded into memory upfront)
- `pip.pyz` is 2,034,201 bytes, so it isn't strenuous to keep in memory
- Run pip with `--disable-pip-version-check`
## Virtual environment
Should operate like `PIP_REQUIRE_VIRTUALENV`/`--require-virtualenv` is set.
### Determine if a virtual environment is needed
Skip the virtual environment if:
- `--target`/`-t`
- `--user`
is used.
### Creating the virtual environment
- Find a `pyproject.toml` file as the directory to create the virtual environment
- If not found, ask the user where to create or just error out?
- Use `microvenv`
- Implies `.venv` for the directory name
- Implies `--without-pip`
## Run `pip`
- `--disable-pip-version-check`