Skeleton code for a new Python project.
- Layout
- for single package "helloworld" project with a main module and helper modules (from Python Application Layouts: A Reference – Real Python)
- tests for main and helper modules
- Dependencies
pipenv
based dependency management- It also handles virtual environment management
- Basic development libraries included such as
flake8
for linting, formatting style and other warningsblack
for auto formatting. Frees developers from thinking about style and bikesheddingpytest
for unittestingmypy
for static type checking (triedpyre-check
first but thanks to Unix only dependencyfcntl
it does not work on windows.)
setup.py
for distributionREADME.md
for project description.gitignore
for common files not needed in version control- Recommended editors
- VS Code with following extensions. As the main IDE.
- Python - Visual Studio Marketplace
- PlantUML - Visual Studio Marketplace (requires GraphViz) for software design with UML diagrams
- Better Comments - Visual Studio Marketplace
- Vim. When not having access to my desktop/laptop. For example, when SSH'ing to my devserver from iPad.
- VS Code with following extensions. As the main IDE.
- Download the project zip file (TODO: think about a flow with
git clone
) - Rename files and folder according to new project name
pipenv
- if
pipenv
does not exist in base Python distribution install it viapip install pipenv
pipenv install --dev --pre
to create virtual environment for the project under~/.virtualenvs/PROJECT_NAME-hash
and install developer dependencies. (Currently--pre
is needed for black because its version is less then1
.)- to activate project environment
pipenv shell
- (note that the project itself is in "packages" of Pipfile, which runs
pip install -e .
with above command. That installs the project as a module to virtual environment too. It is required bypytest
.)
- if
git init
to initialize a git repo- for VS Code
- set
python.pythonPath
setting (TODO: figure out the right way of doing this.) - install following extensions if not already installed
- set
- Runing unittests
- CLI: Run either
pytest
orpython -m pytest
from project root- (The latter puts project root to
sys.path
) python -m pytest tests/ --collect-only
command to only discover tests
- (The latter puts project root to
- VS Code: Tests can be discovered and run from the "Tests" tab. Individual tests can be run from the opened file directly.
- CLI: Run either