Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
seanh committed Jul 9, 2022
0 parents commit 2df7d77
Show file tree
Hide file tree
Showing 25 changed files with 780 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .cookiecutter/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"template": "https://github.com/hypothesis/cookiecutters",
"directory": "pypackage",
"ignore": [],
"extra_context": {
"name": "cookiecutter-pypackage-test",
"package_name": "cookiecutter_pypackage_test",
"slug": "cookiecutter-pypackage-test",
"short_description": "A test package for our pypackage cookiecutter.",
"python_versions": "3.10.4, 3.9.12, 3.8.13",
"github_owner": "hypothesis",
"copyright_holder": "Hypothesis",
"public": "no",
"console_script": "yes",
"__dependabot_interval": "weekly",
"__entry_point": "cookiecutter-pypackage-test",
"__github_url": "https://github.com/hypothesis/cookiecutter-pypackage-test",
"__pypi_url": "https://pypi.org/project/cookiecutter-pypackage-test"
}
}
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "00:00"
timezone: "Europe/London"
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI
on:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'
jobs:
Format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install tox
- run: tox -e checkformatting
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install tox
- run: tox -e lint
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.9', '3.8']
name: Unit tests with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install tox
- run: tox -e tests
- name: Upload coverage file
uses: actions/upload-artifact@v3
with:
name: coverage
path: .coverage.*
Coverage:
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Download coverage files
uses: actions/download-artifact@v3
with:
name: coverage
- run: python -m pip install tox
- run: tox -e coverage
Functests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.9', '3.8']
name: Functional tests with Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install tox
- run: tox -e functests
8 changes: 8 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: PyPI
on:
release:
types: [published]
jobs:
PyPI:
uses: hypothesis/workflows/.github/workflows/pypi.yml@main
secrets: inherit
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build
coverage
node_modules
yarn-error.log
.coverage*
.tox
*.egg-info
*.pyc
supervisord.log
supervisord.pid
.DS_Store
.devdata.env
3 changes: 3 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3.10.4
3.9.12
3.8.13
102 changes: 102 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Setting up Your cookiecutter-pypackage-test Development Environment

First you'll need to install:

* [Git](https://git-scm.com/).
On Ubuntu: `sudo apt install git`, on macOS: `brew install git`.
* [GNU Make](https://www.gnu.org/software/make/).
This is probably already installed, run `make --version` to check.
* [pyenv](https://github.com/pyenv/pyenv).
Follow the instructions in pyenv's README to install it.
The **Homebrew** method works best on macOS.
The **Basic GitHub Checkout** method works best on Ubuntu.
You _don't_ need to set up pyenv's shell integration ("shims"), you can
[use pyenv without shims](https://github.com/pyenv/pyenv#using-pyenv-without-shims).

Then to set up your development environment:

```terminal
git clone https://github.com/hypothesis/cookiecutter-pypackage-test.git
cd cookiecutter_pypackage_test
make help
```

Releasing a New Version of the Project
--------------------------------------

1. First, to get PyPI publishing working you need to go to:
<https://github.com/organizations/hypothesis/settings/secrets/actions/PYPI_TOKEN>
and add cookiecutter-pypackage-test to the `PYPI_TOKEN` secret's selected
repositories.

2. Now that the cookiecutter-pypackage-test project has access to the `PYPI_TOKEN` secret
you can release a new version by just [creating a new GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
Publishing a new GitHub release will automatically trigger
[a GitHub Actions workflow](.github/workflows/pypi.yml)
that will build the new version of your Python package and upload it to
<https://pypi.org/project/cookiecutter-pypackage-test>.

Changing the Project's Python Versions
--------------------------------------

To change what versions of Python the project uses:

1. Change the Python versions in the
[cookiecutter.json](.cookiecutter/cookiecutter.json) file. For example:

```json
"python_versions": "3.10.4, 3.9.12",
```

2. Re-run the cookiecutter template:

```terminal
make template
```

3. Commit everything to git and send a pull request

Changing the Project's Python Dependencies
------------------------------------------

To change the production dependencies in the `setup.cfg` file:

1. Change the dependencies in the [`.cookiecutter/includes/setuptools/install_requires`](.cookiecutter/includes/setuptools/install_requires) file.
If this file doesn't exist yet create it and add some dependencies to it.
For example:

```
pyramid
sqlalchemy
celery
```

2. Re-run the cookiecutter template:

```terminal
make template
```

3. Commit everything to git and send a pull request

To change the project's formatting, linting and test dependencies:

1. Change the dependencies in the [`.cookiecutter/includes/tox/deps`](.cookiecutter/includes/tox/deps) file.
If this file doesn't exist yet create it and add some dependencies to it.
Use tox's [factor-conditional settings](https://tox.wiki/en/latest/config.html#factors-and-factor-conditional-settings)
to limit which environment(s) each dependency is used in.
For example:

```
lint: flake8,
format: autopep8,
lint,tests: pytest-faker,
```

2. Re-run the cookiecutter template:

```terminal
make template
```

3. Commit everything to git and send a pull request
39 changes: 39 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Installing cookiecutter-pypackage-test

We recommend using [pipx](https://pypa.github.io/pipx/) to install
cookiecutter-pypackage-test.
First [install pipx](https://pypa.github.io/pipx/#install-pipx) then run:

```terminal
pipx install cookiecutter-pypackage-test
```

You now have cookiecutter-pypackage-test installed! For some help run:

```
cookiecutter-pypackage-test --help
```

Upgrading
---------

To upgrade to the latest version run:

```terminal
pipx upgrade cookiecutter-pypackage-test
```

To see what version you have run:

```terminal
cookiecutter-pypackage-test --version
```

Uninstalling
------------

To uninstall run:

```
pipx uninstall cookiecutter-pypackage-test
```
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2022, Hypothesis
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86 changes: 86 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
comma := ,

.PHONY: help
help = help::; @echo $$$$(tput bold)$(strip $(1)):$$$$(tput sgr0) $(strip $(2))
$(call help,make help,print this help message)

.PHONY: shell
$(call help,make shell,"launch a Python shell in this project's virtualenv")
shell: python
@pyenv exec tox -qe dev

.PHONY: lint
$(call help,make lint,"lint the code and print any warnings")
lint: python
@pyenv exec tox -qe lint

.PHONY: format
$(call help,make format,"format the code")
format: python
@pyenv exec tox -qe format

.PHONY: checkformatting
$(call help,make checkformatting,"crash if the code isn't correctly formatted")
checkformatting: python
@pyenv exec tox -qe checkformatting

.PHONY: test
$(call help,make test,"run the unit tests in Python 3.10")
coverage: test
test: python
@pyenv exec tox -qe tests

.PHONY: test-py39
$(call help,make test-py39,"run the unit tests in Python 3.9")
coverage: test-py39
test-py39: python
@pyenv exec tox -qe py39-tests

.PHONY: test-py38
$(call help,make test-py38,"run the unit tests in Python 3.8")
coverage: test-py38
test-py38: python
@pyenv exec tox -qe py38-tests

.PHONY: coverage
$(call help,make coverage,"run the tests and print the coverage report")
coverage: python
@pyenv exec tox -qe coverage

.PHONY: functests
$(call help,make functests,"run the functional tests in Python 3.10")
functests: python
@pyenv exec tox -qe functests

.PHONY: functests-py39
$(call help,make functests-py39,"run the functional tests in Python 3.9")
functests-py39: python
@pyenv exec tox -qe py39-functests

.PHONY: functests-py38
$(call help,make functests-py38,"run the functional tests in Python 3.8")
functests-py38: python
@pyenv exec tox -qe py38-functests

.PHONY: sure
$(call help,make sure,"make sure that the formatting$(comma) linting and tests all pass")
sure:
@pyenv exec tox --parallel -qe 'checkformatting,lint,tests,py{39,38}-tests,coverage,functests,py{39,38}-functests'

.PHONY: template
$(call help,make template,"update from the latest cookiecutter template")
template: python
@pyenv exec tox -e template -- $(cookiecutter)

.PHONY: clean
$(call help,make clean,"delete temporary files etc")
clean:
@rm -rf build dist .tox
@find . -path '*/__pycache__*' -delete
@find . -path '*.egg-info*' -delete

.PHONY: python
python:
@bin/make_python

-include cookiecutter_pypackage_test.mk
Loading

0 comments on commit 2df7d77

Please sign in to comment.