An attempt to consolidate my python Know-how.
snip...
[remote "origin"]
url = https://GITHUB_USER:TOKEN@github.com/lozsui/python.git
fetch = +refs/heads/:refs/remotes/origin/
I try to use .venv in root folder of this project for most things. See Setting Up a Virtual Environment
Create a virtual environment in the root folder of this project.
python3 -m venv tests/.venv
source tests/.venv/bin/activate
(.venv) lozsui@host:~/python$ pip install -r requirements.txt
source tests/.venv/bin/activate (.venv) lozsui@host:
/python$ export $(cat tests/.env | grep -v '^#') (.venv) lozsui@host:/python/tests$ pytest test_* (.venv) lozsui@host:~/python/tests$ pytest -s test_*
- Get the source code
- Install dependencies
- Compile and install according to readme.rst
According to install-dependencies build dependencies can be installed as follows:
git clone https://github.com/python/cpython.git
git checkout v3.10.4
mkdir -p ~/python/python3.10.4_debug
./configure --prefix="~/python/python3.10.4_debug" --with-pydebug
make
make test
make install
Set up virtual environment:
mkdir ~/python/python-env
cd ~/python/python3.10.4_debug/
bin/virtualenv -p ~/python/python3.10.4_debug/bin/python3 ~/python/python-env
source ~/python/python-env/bin/activate
python -m pip install -r ~/003-GitHub/python/requirements.txt
source ~/python/python-env/bin/activate
cd ~/003-GitHub/python/tests
python -m pytest
Assume the Python interpreter was installed to 'C:\GNOT\Python' and this project is cloned to 'C:\GIT\GITHUB\python'.
PS C:\GIT\GITHUB\python> & C:/GNOT/Python/python.exe -m venv .venv
or
PS C:\GIT\GITHUB\python> & python.exe -m venv .venv
or
& C:/GNOT/python/python.3.11.2/python.exe -m venv .venv
if PS knows the path to your python binary. Put pip.ini like shown below into .venv folder.
[global]
proxy = http://proxy.highly.secure:8080
PS C:\Temp\python> .venv/Scripts/Activate.ps1 (.venv) PS C:\Temp\python> python.exe -m pip install --upgrade pip (.venv) PS C:\Temp\python> python -m pip install -r requirements.txt
Activate your .venv and type command as in listing below.
PS C:\GIT\GITHUB\python> & C:/GIT/GITHUB/python/.venv/Scripts/Activate.ps1
pytest
!!! Hint on 'No module named 'cards': This is because of 'test_count.py'. Either comment out these tests or install cards like so:
(venv) $ cd .\learnpytest\
(venv) $ pip install ./cards_proj/
Jose Salvatierra Fuentes created quite a nice course on Python. Code Snippets of this course on here: Code on 'The Complete Python Course' on github.