Reinstall virtualenv with tox when requirements.txt or setup.py changes

后端 未结 3 1537
北荒
北荒 2021-01-02 00:21

Previously I was manually using a Makefile that looked something like this:

.PHONY: all
all: tests

.PHONY: tests
tests: py_env
    bash -c \'source py_env/b         


        
3条回答
  •  不思量自难忘°
    2021-01-02 00:46

    Here's the Makefile workaround I ended up going with:

    REBUILD_FLAG =
    
    .PHONY: all
    all: tests
    
    .PHONY: tests
    tests: .venv.touch
        tox $(REBUILD_FLAG)
    
    .venv.touch: setup.py requirements.txt requirements_dev.txt
        $(eval REBUILD_FLAG := --recreate)
        touch .venv.touch
    

    Example:

    $ make tests
    touch .venv.touch
    tox --recreate
    [[ SNIP ]]
    $ make tests
    tox 
    [[ SNIP ]]
    $ touch requirements.txt
    $ make tests
    touch .venv.touch
    tox --recreate
    [[ SNIP ]]
    

提交回复
热议问题