How to use virtualenv in makefile

后端 未结 8 1077
-上瘾入骨i
-上瘾入骨i 2020-12-24 04:55

I want to perform several operations while working on a specified virtualenv.

For example command

make install

would be equivalent

8条回答
  •  借酒劲吻你
    2020-12-24 05:38

    I like using something that runs only when requirements.txt changes:

    This assumes that source files are under project in your project's root directory and that tests are under project/test. (You should change project to match your actually project name.)

    venv: venv/touchfile
    
    venv/touchfile: requirements.txt
        test -d venv || virtualenv venv
        . venv/bin/activate; pip install -Ur requirements.txt
        touch venv/touchfile
    
    test: venv
        . venv/bin/activate; nosetests project/test
    
    clean:
        rm -rf venv
        find -iname "*.pyc" -delete
    
    • Run make to install packages in requirements.txt.
    • Run make test to run your tests (you can update this command if your tests are somewhere else).
    • run make clean to delete all artifacts.

提交回复
热议问题