setup-venv.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. debian_based() { test -f /etc/debian_version; }
  3. if test -z $VENV_DIR; then
  4. VENV_DIR=./.release-venv
  5. fi
  6. if test -z $PYTHONBIN; then
  7. PYTHONBIN=$(which python3)
  8. if test -z $PYTHONBIN; then
  9. PYTHONBIN=$(which python)
  10. fi
  11. fi
  12. VERSION=$($PYTHONBIN -c "import sys; print('{}.{}'.format(*sys.version_info[0:2]))")
  13. if test $(echo $VERSION | cut -d. -f1) -lt 3; then
  14. echo "Python 3.3 or above is required"
  15. fi
  16. if test $(echo $VERSION | cut -d. -f2) -lt 3; then
  17. echo "Python 3.3 or above is required"
  18. fi
  19. # Debian / Ubuntu workaround:
  20. # https://askubuntu.com/questions/879437/ensurepip-is-disabled-in-debian-ubuntu-for-the-system-python
  21. if debian_based; then
  22. VENV_FLAGS="$VENV_FLAGS --without-pip"
  23. fi
  24. $PYTHONBIN -m venv $VENV_DIR $VENV_FLAGS
  25. VENV_PYTHONBIN=$VENV_DIR/bin/python
  26. if debian_based; then
  27. curl https://bootstrap.pypa.io/get-pip.py -o $VENV_DIR/get-pip.py
  28. $VENV_PYTHONBIN $VENV_DIR/get-pip.py
  29. fi
  30. $VENV_PYTHONBIN -m pip install -U Jinja2==2.10 \
  31. PyGithub==1.39 \
  32. GitPython==2.1.9 \
  33. requests==2.18.4 \
  34. setuptools==40.6.2 \
  35. twine==1.11.0
  36. $VENV_PYTHONBIN setup.py develop