Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gma/python-template
https://github.com/gma/python-template
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/gma/python-template
- Owner: gma
- License: mit
- Created: 2023-10-24T11:30:12.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-08T21:10:43.000Z (6 months ago)
- Last Synced: 2024-05-08T22:26:56.097Z (6 months ago)
- Language: Python
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Python Project Template
=======================You can use this repository as a template when creating a new repository on GitHub, to get my preferred setup for a Python project.
After creating the new project, there are a few things you'll need to configure.
## Rename the main package
You'll need to rename the package from "mylib" to something sensible:
```sh
git mv mylib newname
sed -i='' -e 's/mylib/newname/' tests/* .projections.json
```## Choosing the Python version
The version of Python that your project uses is needed by the GitHub Action that runs the tests, and perhaps by your local Python installation tool.
You can create it like this:
```sh
echo 3.11.3 > .python-version # 3.11.3 is just an example
```## Reviewing the license
The open source MIT license is used by default (see the [LICENSE] file). [Is it appropriate](https://choosealicense.com/) for this project?
If you do stick with the MIT license, don't forget to set the year and the name of the copyright holder. If you're on Linux you can do it quickly by copying/pasting this snippet into your shell:
```sh
sed -i='' -e "s,,$(date +%Y)," LICENSE
FULL_NAME="$(getent passwd $USER | cut -d : -f 5 | cut -d , -f 1)"
sed -i='' -e "s,,$FULL_NAME," LICENSE
```Otherwise, just edit [LICENSE].
[LICENSE]: ./LICENSE
## Run the tests locally
You need to get everything installed, and that first test running. Start by creating a virtual environment:
```sh
python3 -m venv .venv
source .venv/bin/activate
```Now we can install our development tools:
```sh
pip install --upgrade pip
pip install pip-tools
pip-sync dev-requirements.txt
```The dev tools included in the template are sufficient to be able to run the linter, type checker, and tests. They're all run by this script:
```sh
./test
```## Adding dependencies
Once you've got non-development dependencies you can specify them in `requirements.in`, running these commands to install them alongside your development dependencies:
```sh
pip-compile requirements.in
pip-sync requirements.txt dev-requirements.txt
```If you want to add more development tools, add them to `dev-requirements.in` and run:
```sh
pip-compile dev-requirements.in
pip-sync requirements.txt dev-requirements.txt
```## Update the README
Now delete all the docs that you've just followed, and write something suitable for your new project!