Use venv module rather than virtualenv

- simpler to use
- lighter dependency (or no dependency at all, depending on python distribution)
- retrocompatible

virtualenv package from pip to acheive virtual environment feature is no longer
needed, except for projects which need to support py2, which is no longer our
case.

Also, reword "virtualenv" to "virtual environment" in doc, to avoid confusion
with pip package name.

Ref #483
This commit is contained in:
Jocelyn Delalande 2020-07-26 19:55:44 +02:00 committed by zorun
parent 48fabc346f
commit 55bce593f0
4 changed files with 15 additions and 15 deletions

View file

@ -1,4 +1,4 @@
VIRTUALENV = virtualenv --python=python3 VIRTUALENV = python3 -m venv
SPHINX_BUILDDIR = docs/_build SPHINX_BUILDDIR = docs/_build
VENV := $(shell realpath $${VIRTUAL_ENV-.venv}) VENV := $(shell realpath $${VIRTUAL_ENV-.venv})
PYTHON = $(VENV)/bin/python3 PYTHON = $(VENV)/bin/python3

View file

@ -67,7 +67,7 @@ If System :ref:`installation-requirements` are fulfilled, you can just issue::
make serve make serve
It will setup a `virtualenv <https://pypi.python.org/pypi/virtualenv>`_, It will setup a `Virtual environment <https://docs.python.org/3/tutorial/venv.html>`_,
install dependencies, and run the test server. install dependencies, and run the test server.
The hard way The hard way
@ -193,7 +193,7 @@ The documentation is using `sphinx <http://www.sphinx-doc.org/en/stable/>`_ and
its source is located inside the `docs folder its source is located inside the `docs folder
<https://github.com/spiral-project/ihatemoney/tree/master/docs>`_. <https://github.com/spiral-project/ihatemoney/tree/master/docs>`_.
Install doc dependencies (within the virtualenv, if any):: Install doc dependencies (within the virtual environment, if any)::
pip install -r docs/requirements.txt pip install -r docs/requirements.txt

View file

@ -21,9 +21,9 @@ Requirements
* **Python**: either 3.6, 3.7 or 3.8 will work. * **Python**: either 3.6, 3.7 or 3.8 will work.
* **A Backend**: to choose among MySQL, PostgreSQL, SQLite or Memory. * **A Backend**: to choose among MySQL, PostgreSQL, SQLite or Memory.
* **Virtualenv** (recommended): `virtualenv` package under Debian/Ubuntu. * **Virtual environment** (recommended): `python3-venv` package under Debian/Ubuntu.
We recommend to use `virtualenv <https://pypi.python.org/pypi/virtualenv>`_ but We recommend to use `virtual environment <https://docs.python.org/3/tutorial/venv.html>`_ but
it will work without if you prefer. it will work without if you prefer.
If wondering about the backend, SQLite is the simplest and will work fine for If wondering about the backend, SQLite is the simplest and will work fine for
@ -33,16 +33,16 @@ most small to medium setups.
.. _virtualenv-preparation: .. _virtualenv-preparation:
Prepare virtualenv (recommended) Prepare virtual environment (recommended)
================================ =========================================
Choose an installation path, here `/home/john/ihatemoney`. Choose an installation path, here `/home/john/ihatemoney`.
Create a virtualenv:: Create a virtual environment::
virtualenv -p /usr/bin/python3 /home/john/ihatemoney python3 -m venv /home/john/ihatemoney
Activate the virtualenv:: Activate the virtual environment::
source /home/john/ihatemoney/bin/activate source /home/john/ihatemoney/bin/activate
@ -74,7 +74,7 @@ Configure database with MySQL/MariaDB (optional)
apt install python3-dev libssl-dev apt install python3-dev libssl-dev
2. Install PyMySQL (within your virtualenv):: 2. Install PyMySQL (within your virtual environment)::
pip install 'PyMySQL>=0.9,<0.10' pip install 'PyMySQL>=0.9,<0.10'
@ -87,7 +87,7 @@ Configure database with PostgreSQL (optional)
.. note:: Only required if you use Postgresql. .. note:: Only required if you use Postgresql.
1. Install python driver for PostgreSQL (from within your virtualenv):: 1. Install python driver for PostgreSQL (from within your virtual environment)::
pip install psycopg2 pip install psycopg2

View file

@ -15,7 +15,7 @@ General procedure
*(sufficient for minor/patch upgrades)* *(sufficient for minor/patch upgrades)*
1. From the virtualenv (if any):: 1. From the virtual environment (if any)::
pip install -U ihatemoney pip install -U ihatemoney
@ -47,7 +47,7 @@ Switch to a supported version of Python
If you were running IHateMoney using Python < 3.6, you must, **before** upgrading: If you were running IHateMoney using Python < 3.6, you must, **before** upgrading:
1. Ensure to have a Python ≥ 3.6 available on your system 1. Ensure to have a Python ≥ 3.6 available on your system
2. Rebuild your virtualenv (if any). It will *not* alter your database nor configuration. For example, if your virtualenv is in `/home/john/ihatemoney/`:: 2. Rebuild your virtual environment (if any). It will *not* alter your database nor configuration. For example, if your virtual environment is in `/home/john/ihatemoney/`::
rm -rf /home/john/ihatemoney rm -rf /home/john/ihatemoney
pyhton3 -m venv /home/john/ihatemoney pyhton3 -m venv /home/john/ihatemoney
@ -89,7 +89,7 @@ development only.
1. Delete the cloned folder 1. Delete the cloned folder
.. note:: If you are using a virtualenv, then the following commands should be run inside it (see .. note:: If you are using a virtual environment, then the following commands should be run inside it (see
:ref:`virtualenv-preparation`). :ref:`virtualenv-preparation`).