Skip to content

Create Python venv manager #45

Closed
campb303 opened this issue Sep 8, 2020 · 3 comments
Closed

Create Python venv manager #45

campb303 opened this issue Sep 8, 2020 · 3 comments
Assignees
Labels
feature-request Request for functionality that has not already been implemented tooling Related to tools and utilities for the management of the project

Comments

@campb303
Copy link
Collaborator

campb303 commented Sep 8, 2020

webqueue2 uses a python virtual environment to manage its python dependencies separate of the system it is running on. This environment is not committed to version control and must be created on new instances of the environment manually. It must also be deleted manually. If it needs to be reset, the removal and creation need to be chained together.

Create venv:

cd api
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
deactivate

Delete venv:

cd api
rm -rf venv

Creating a tool to automate this would simplify the setup and reset of the development environment. Assuming the tool is called venv-manager, potential syntax could be:

Create venv:

venv-manager.py [-c | --create]

Delete venv:

venv-manager.py [-d | --delete]

Reset venv:

venv-manager.py [-r | --reset]

Assuming this tool behaved like the above description and were stored in a /utils directory, it could be integrated with npm like this:

Create venv:

npm run venv:create

Delete venv:

npm run venv:delete

Reset venv:

npm run venv:reset
@campb303 campb303 added api tooling Related to tools and utilities for the management of the project feature-request Request for functionality that has not already been implemented labels Sep 8, 2020
@campb303 campb303 self-assigned this Sep 8, 2020
@campb303
Copy link
Collaborator Author

campb303 commented Sep 8, 2020

This video demonstrated the standard library ArgParse module which can be used to allow command line arguments.

@campb303 campb303 added this to the v1 milestone Sep 14, 2020
@campb303
Copy link
Collaborator Author

This video demonstrates the builtin Python logging library.

@campb303
Copy link
Collaborator Author

With this script finished, it not only allows for automated creation and deletion of virtual environments for webqueue2, it also sets the standard for logging via Python. It's log format follow's Ubuntu syslog format of: Abbreviated_Month Day_of_Month Full_Year HH:MM:SS Process_Name : [LEVEL] Log_Message

Example:

Sep 17 2020 11:59:29 venv-manager : [WARNING] Warning Message

The log setup should be extracted from this script and made available as a general module.

Sign in to join this conversation on GitHub.
Labels
feature-request Request for functionality that has not already been implemented tooling Related to tools and utilities for the management of the project
Projects
None yet
Development

No branches or pull requests

1 participant