95 lines
2.4 KiB
Markdown
95 lines
2.4 KiB
Markdown
# Python Skeleton
|
|
|
|
This a skeleton for a python project
|
|
|
|
Includes file layout, pyproject.toml, README.md, license and a hello world script.
|
|
|
|
Intended as a starting point for future personal projects
|
|
|
|
To use:
|
|
|
|
Clone this and then delete the git repo (unless you're working on the skeleton)
|
|
|
|
## Create a new git repo
|
|
|
|
`git init`
|
|
|
|
```
|
|
git config --local init.defaultbranch main
|
|
git config --local user.name "Neill Cox"
|
|
git config --local user.email "neill.cox@ingenious.com.au"
|
|
```
|
|
|
|
Configure as necessary.
|
|
|
|
## Create a virtualenv
|
|
|
|
`python -m venv venv`
|
|
|
|
## Activate
|
|
|
|
`source venv/bin/activate`
|
|
|
|
## Upgrade pip
|
|
|
|
`pip install --upgrade pip`
|
|
|
|
## Install requirements-dev.txt
|
|
|
|
`pip install -r requirements-dev.txt`
|
|
|
|
If this was an actual project this would be the time to install the actual requirements
|
|
|
|
`pip install -r requirements.txt`
|
|
|
|
That's an empty file at the moment so there's no point
|
|
|
|
## Check that tests work
|
|
|
|
`pytest`
|
|
|
|
Should produce something like:
|
|
|
|
```
|
|
======================================================== test session starts ==========================================================
|
|
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.3.0 -- /home/ncox/Projects/python-skeleton/venv/bin/python
|
|
cachedir: .pytest_cache
|
|
rootdir: /home/ncox/Projects/python-skeleton
|
|
configfile: pyproject.toml
|
|
testpaths: tests
|
|
plugins: cov-4.1.0
|
|
collected 1 item
|
|
|
|
tests/test_skeleton.py::test_hello_word PASSED [100%]
|
|
|
|
---------- coverage: platform linux, python 3.11.5-final-0 -----------
|
|
Name Stmts Miss Cover Missing
|
|
---------------------------------------------------------------
|
|
src/python_skeleton/__init__.py 6 1 83% 18
|
|
---------------------------------------------------------------
|
|
TOTAL 6 1 83%
|
|
|
|
|
|
========================================================== 1 passed in 0.02s ===========================================================
|
|
```
|
|
|
|
## Install pre-commit hooks:
|
|
|
|
`pre-commit install`
|
|
|
|
Should produce:
|
|
|
|
`pre-commit installed at .git/hooks/pre-commit`
|
|
|
|
## Commit files (feel free to make some changes first)
|
|
|
|
```
|
|
git add .
|
|
git commit -m ":tada: Initial commit"
|
|
```
|
|
|
|
I like using [gitmoji](https://gitmoji.dev), but that's entirely up to you.
|
|
|
|
## Note there is a docs directory, but it's really a skeleton and probably doesn't work.
|
|
|
|
I'll fix this in a later version.
|