https://github.com/romanturas/python-env
Python virtual environment examples
https://github.com/romanturas/python-env
poetry python
Last synced: 12 months ago
JSON representation
Python virtual environment examples
- Host: GitHub
- URL: https://github.com/romanturas/python-env
- Owner: RomanTuras
- Created: 2025-03-23T10:27:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-23T12:17:57.000Z (over 1 year ago)
- Last Synced: 2025-06-12T16:44:50.582Z (about 1 year ago)
- Topics: poetry, python
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Add virtual env, CLASSIC method
`python -m venv env`
`source env/bin/activate`
`pip install Flask`
`python -m pip freeze > requirements.txt`
#### Install from requirements.txt:
`pip install -r requirements.txt`
## Add virtual env, with POETRY
`pip install poetry`
> Create or init existings project:
`poetry new `
or
`poetry init`
> Create lock:
`poetry lock`
> To Activate ENV:
`source $(poetry env info --path)/bin/activate`
> To Deactivate ENV: `deactivate`
> Examples poetry commands:
`poetry add aiosqlite`
`poetry remove aiosqlite`
`poetry install`
`poetry update`
`poetry show`
`poetry run pytest`
`poetry export --without-hashes --format=requirements.txt > requirements.txt`
## -= Example Makefile for poetry =-
Since you we are using poetry, there is no need to manually activate the virtual environment, poetry run automatically runs commands in it
```Makefile:
.PHONY: setup \
lint \
mypy \
help
setup: ## Project setup
poetry install
lint: ## Run linter
poetry run ruff format --config ./pyproject.toml .
poetry run ruff check --fix --config ./pyproject.toml .
mypy: ## Run mypy
poetry run mypy ./
test: ## Run tests check
poetry run pytest $(filter-out $@,$(MAKECMDGOALS)) -s
# Just help
help: ## Display help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'```