title: Installing into a venv with setup.py setuptools
body: <p>I'm looking for a way to do a single-command installation of the whole python application into a <code>venv</code> by a specific path.</p>
  
  <hr>
  
  <p>I did some research about this topic and particularly in <a href="https://stackoverflow.com/a/18420304/2786156">this thread</a> there was a discussion about <code>Makefile</code> automation of the process. It also suggests to use <a href="https://www.pyinvoke.org/" rel="nofollow noreferrer">pyinvoke</a>, which appeared to me as a command line commands wrapped into python. So I currently wrote the following simple on-the-knee shell script:</p>
  
  <p><code>install_venv.sh</code></p>
  
  <pre><code>#!/bin/bash
  
  PYTHON="$1"
  VENV_PATH="$2"
  SOURCE_ROOT="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  
  echo "$PYTHON"
  echo "$VENV_PATH"
  echo "$SOURCE_ROOT"
  
  cd $SOURCE_ROOT
  $PYTHON -m venv $VENV_PATH
  source "$VENV_PATH/bin/activate"
  python -m pip install -r "$SOURCE_ROOT/requirements.txt"
  python setup.py install
  </code></pre>
  
  <p>This script can be run, say as <code>./install_venv.sh python3.7 /tmp/test_venv</code>. It does not handle the case if <code>venv</code> already exists by the path, but it can be extended in a straightforward way. </p>
  
  <p>It looks like a very common task, so maybe <code>setuptools</code> already has a way to do so or writing such scripts is still necessary? Or what is the preferred way? </p>