Can pip install only a specified type of pre-release versions?

Viewed 1006

My issue is that, i want to represent 3 environments: dev, int, prod

  • On dev I want to install the most up to date dev-version: 1.0.0.dev0
  • On int I want to install the most up to date rc-version: 1.0.0.rc0
  • On prod I want to install the most up to date production version: 1.0.0

Is there a way like in these examples?

  • pip install --pre==dev MyModule should install me 1.0.0.dev0
  • pip install --pre==rc MyModule should install me 1.0.0.rc0
  • pip install MyModule should install me 1.0.0

My intention is to have a release-flow like

  • 1.0.0.dev0
  • 1.0.0.dev1
  • 1.0.0.dev2
  • 1.0.0.rc0
  • 1.0.0.rc1
  • 1.0.0

My problem is, that i can represent only 2 states: a pre-release version and one without pre; but i need 3 states.

Is there a way to realize this? Maybe even without pip?

1 Answers

Create three .txt files:

touch dev-requirements.txt
touch int-requirements.txt
touch prod-requirements.txt

(or however you want to name them), and put in the package versions you want for each environment.

Create a virtual environment for each one:

python3 -m venv devenv
source devenv/bin/activate
pip3 install -r dev-requirements.txt
deactivate

python3 -m venv intenv
source intenv/bin/activate
pip3 install -r int-requirements.txt
deactivate

python3 -m venv prodenv
source prodenv/bin/activate
pip3 install -r prod-requirements.txt

Then you can simply switch between them depending on which environment you're using.

Alternatively just create one virtual environment and rerun pip3 install -r requirements.txt each time you change states, replacing requirements.txt with whichever file holds the package versions you want.

Related