Re-imagined as a Python project using pygame, from the boot.dev site.
To work with this application please follow the flow for Python Vitrual Environments for venv.
The MAC is set-up to autoswitch to the listed virtual environment if on is present. This should be indicated by the presence of a Virtual Environment indicator at the leading characters of the prompt:
(venv:venv) SLMaxwell68%:asteroids[main] >
Should the terminal Prompt NOT show that a virtual environment is present:
SLMaxwell68%:asteroids[main] >
Follow the needed actions below to activate or create a Virtual Environment.
To create a new Virtual Environment, navigate to the root of the new application directory. Then run:
py -m venv venvorpy -m venv .venv
There is a .zshrc alias set-up to stub in a new Virtual Environment. It performs the creation, activtion, resetting of the prompt, generation of the requirements.txt file and generation of the .gitignore file and entries to ignore the environment. For this run:
venv-create- Which will default the created directory to "venv".
Or you can specify your venv directory with:
venv-create venvorvenv-create .venvor
Do this each time you enter the directory.
To activate the environment so that it is controlling the python version and installed packages, run:
source venv/bin/activateorsource .venv/bin/activateor
Or if the .zshrc is properly set-up simply run:
venv-activate- Which will also re-set the prompt to display correctly.
Do this each time you want to leave the directory.
To Deactivate the environment so that it is controlling the python version and installed packages, run:
deactivate
Or if the .zshrc is properly set-up simply run:
venv-deactivate- Which will also re-set the prompt to display correctly.
Do this each time you want to update the prompt to the current venv activation setting.
set-prompt
The purpose of maintaining a virtual environment is to allow the needed dependencies to be easily installed, added or recreated for the project and python version being used.
This is accomplished using the standard of setting the desired requirements within a text file and installing them from that file:
- Ex: To make sure that the dependency
pygame version 2.6.1is installed and active.- Make sure there is a text file created for
pipinstallation:requirements.txt
- Place the follong text into the text file:
pygame==2.6.1
- Run the followng installation command:
pip install -r requirements.txt
- Make sure there is a text file created for
Or use the aliased command:
venv-install
