How to customize a requirements.txt for multiple environments?

后端 未结 3 912
你的背包
你的背包 2020-11-29 15:26

I have two branches, Development and Production. Each has dependencies, some of which are different. Development points to dependencies that are themselves in development. L

3条回答
  •  青春惊慌失措
    2020-11-29 16:05

    If your requirement is to be able to switch between environments on the same machine, it may be necessary to create different virtualenv folders for each environment you need to switch to.

    python3 -m venv venv_dev
    source venv_dev/bin/activate
    pip install -r pip/common.txt
    pip install -r pip/dev.txt
    exit
    python3 -m venv venv_prod
    source venv_prod/bin/activate
    pip install -r pip/common.txt
    exit
    source venv_dev/bin/activate
    # now we are in dev environment so your code editor and build systems will work.
    
    # let's install a new dev package:
    # pip install awesome
    # pip freeze -r pip/temp.txt
    # find that package, put it into pip/dev.txt
    # rm pip/temp.txt
    
    # pretty cumbersome, but it works. 
    

提交回复
热议问题