Skip to content

Commit

Permalink
chore: Modernize Python packaging (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
tibordp committed May 8, 2023
1 parent 869c18a commit 4128cda
Show file tree
Hide file tree
Showing 64 changed files with 579 additions and 1,040 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ htmlcov/
.tox/
build/
dist/
.vscode/
.vscode/
22 changes: 12 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
strategy:
matrix:
environment:
- python-version: "3.9"
- python-version: "3.10"
toxenv: check
- python-version: "3.9"
- python-version: "3.10"
toxenv: docs
- python-version: "3.7"
toxenv: py37
- python-version: "3.8"
toxenv: py38
- python-version: "3.9"
toxenv: py39
toxenv: py39
- python-version: "3.10"
toxenv: py310
toxenv: py310
- python-version: "3.11"
toxenv: py311
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.environment['python-version'] }}
Expand All @@ -39,23 +39,25 @@ jobs:
python -m tox
integration:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
environment:
- python-version: "3.9"
- python-version: "3.10"
toxenv: integration
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pyncette
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- 5432:5432
redis:
image: redis
options: >-
Expand Down Expand Up @@ -89,7 +91,7 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
- 3306:3306

steps:
- uses: actions/checkout@v2
Expand All @@ -113,4 +115,4 @@ jobs:
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ docs/_build
.mypy_cache/

## VSCode
.vscode/tags
.vscode/tags

## Pyncette
pyncette.db
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# To install the git pre-commit hooks run:
# pre-commit install --install-hooks
# To update the versions:
# pre-commit autoupdate
exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg)(/|$)'
# Note the order is intentional to avoid multiple passes of the hooks
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.263
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude_types:
- c
- id: end-of-file-fixer
exclude_types:
- c
- id: debug-statements
8 changes: 6 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ sphinx:
# Optionally build your docs in additional formats such as PDF and ePub
formats: all

build:
os: ubuntu-22.04
tools:
python: "3.9"

python:
version: "3.8"
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- all
- all
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"python.formatting.provider": "black",
"restructuredtext.confPath": "${workspaceFolder}/docs",
"python.pythonPath": "/usr/bin/python3"
}
}
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
Changelog
=========

Unreleased
------------------

* Drop support for Python 3.7
* Add support for Python 3.11
* Modernize Python package structure and linters
* Fix a few bugs and type annotations


0.8.1 (2021-04-08)
------------------

Expand Down Expand Up @@ -69,7 +78,7 @@ Changelog
------------------

* Timezone support
* More efficient poling when Redis backend is used
* More efficient poling when Redis backend is used


0.1.1 (2020-01-08)
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ To set up `pyncette` for local development:
3. Create a branch for local development::

git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

4. Running integration tests assumes that there will be Redis, PostgreSQL, MySQL and Localstack (for DynamoDB) running on localhost. Alternatively, there is a Docker Compose environment that will set up all the backends so that integration tests can run seamlessly::

docker-compose up -d
docker-compose run --rm shell

5. When you're done making changes run all the checks and docs builder with `tox <https://tox.readthedocs.io/en/latest/install.html>`_ one command::
5. When you're done making changes run all the checks and docs builder with `tox <https://tox.wiki/en/latest/installation.html>`_ one command::

tox

6. Pyncette uses `black` and `isort` to enforce formatting and import ordering. If you want to auto-format the code, you can do it like this::

tox -e fmt
tox -e check

7. Commit your changes and push your branch to GitHub::

Expand Down Expand Up @@ -91,7 +91,7 @@ To run a subset of tests::

tox -e envname -- pytest -k test_myfeature

To run all the test environments in *parallel* (see
[tox documentation](https://tox.readthedocs.io/en/latest/example/basic.html#parallel-mode))::
To run all the test environments in *parallel* (see
[tox documentation](https://tox.wiki/en/latest/user_guide.html#parallel-mode))::

tox --parallel auto
9 changes: 6 additions & 3 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ RUN apt-get update -y \
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y \
&& apt-get install -y \
python3.7 \
python3.8 \
python3.8-distutils \
python3.9 \
python3.9-distutils \
python3.10 \
python3-pip \
python3.10-distutils \
python3.11 \
python3.11-distutils \
python3-pip \
python3-apt \
redis-tools \
postgresql-client \
mysql-client \
git \
curl \
curl \
unzip \
groff \
&& rm -rf /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 0 additions & 27 deletions MANIFEST.in

This file was deleted.

7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Pyncette comes with an implementation for the following backends (used for persi
- SQLite (included)
- Redis (``pip install pyncette[redis]``)
- PostgreSQL (``pip install pyncette[postgres]``)
- MySQL 8.0+ (``pip install pyncette[mysql]`` - `does not work on Python 3.10 <https://github.com/aio-libs/aiomysql/issues/624>`_)
- MySQL 8.0+ (``pip install pyncette[mysql]``)
- Amazon DynamoDB (``pip install pyncette[dynamodb]``)

Pyncette imposes few requirements on the underlying datastores, so it can be extended to support other databases or
Expand All @@ -167,16 +167,13 @@ To run the all tests run::

Alternatively, there is a Docker Compose environment that will set up all the backends so that integration tests can run seamlessly::

# If you want the Docker environment to run as current user
# to avoid writing files as root.
export UID_GID="$(id -u):$(id -g)"
docker-compose up -d
docker-compose run --rm shell
tox

To run just the unit tests (excluding integration tests)::

tox -e py38 # or py37, py39
tox -e py310 # or your Python version of choice

Note, to combine the coverage data from all the tox environments run:

Expand Down

0 comments on commit 4128cda

Please sign in to comment.