Skip to content

Support Django 5.2, packaging updates #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .bumpversion.cfg

This file was deleted.

25 changes: 25 additions & 0 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tool.bumpversion]
current_version = "0.1.1"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)(\\.(?P<patch>\\d+))?"
serialize = [
"{major}.{minor}.{patch}",
"{major}.{minor}",
]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
ignore_missing_files = false
tag = true
sign_tags = false
tag_name = "{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = true
message = "Bump version: {current_version} → {new_version}"
commit_args = ""

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = "version = '{current_version}'"
replace = "version = '{new_version}'"
32 changes: 17 additions & 15 deletions .github/matrix.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# noqa:INP001
import fileinput
import json
import re
Expand All @@ -9,21 +10,22 @@
def main():
actions_matrix = []

for tox_env in fileinput.input():
tox_env = tox_env.rstrip()

if python_match := PY_VERSIONS_RE.match(tox_env):
version_tuple = python_match.groups()
else:
version_tuple = sys.version_info[0:2]

python_version = "{}.{}".format(*version_tuple)
actions_matrix.append(
{
"python": python_version,
"tox_env": tox_env,
}
)
with fileinput.input() as f:
for tox_env_line in f:
tox_env = tox_env_line.rstrip()

if python_match := PY_VERSIONS_RE.match(tox_env):
version_tuple = python_match.groups()
else:
version_tuple = sys.version_info[0:2]

python_version = "{}.{}".format(*version_tuple)
actions_matrix.append(
{
"python": python_version,
"tox_env": tox_env,
}
)

print(json.dumps(actions_matrix)) # noqa:T201

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019-2024, Developer Society Limited
Copyright (c) 2019-2025, Developer Society Limited
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
7 changes: 1 addition & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
include README.rst
include LICENSE
graft postgres_lock
global-exclude *.py[co]
global-exclude __pycache__
global-exclude .DS_Store
prune tests
28 changes: 6 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ test-report: coverage-clean test coverage-report
test-lowest: ## Run tox with lowest (oldest) package dependencies.
test-lowest: tox-test-lowest

dist: ## Builds source and wheel package
dist: clean build-dist

release: ## Package and release this project to PyPI.
release: dist build-release
package: ## Builds source and wheel packages
package: clean build-package


# ---------------
Expand All @@ -67,23 +64,10 @@ build-clean:
rm -rf .eggs
find . -maxdepth 1 -name '*.egg-info' -exec rm -rf {} +

build-release:
@echo
@echo "This will package and release this project to PyPI."
@echo
@echo "A checklist before you continue:"
@echo
@echo " - have you ran 'bumpversion'?"
@echo " - have you pushed the commit and tag created by 'bumpversion'?"
@echo " - are you sure the project is in a state to be released?"
@echo
@read -p "Press <enter> to continue. Or <ctrl>-c to quit and address the above points."
twine upload dist/*

build-dist:
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
build-package:
python -m build
twine check --strict dist/*
check-wheel-contents dist/*.whl


# Virtual Environments
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Django Postgres Lock

A [Django](https://www.djangoproject.com/) management command which will run a command inside a
Postgres lock, ensuring that only a single instance of the inner command will run.

## Installation

Using [pip](https://pip.pypa.io/):

```console
$ pip install django-postgres-lock
```

Edit your Django project's settings module, and add the application to ``INSTALLED_APPS``:

```python
INSTALLED_APPS = [
# ...
"postgres_lock",
# ...
]
```

## Usage

To run clearsessions with the default lock:

```console
$ ./manage.py command_lock -- ./manage.py clearsessions
```

To use a unique lock for this task:

```console
$ ./manage.py command_lock --name clearsessions -- ./manage.py clearsessions
```

To exit immediately if a lock can't be acquired:

```console
$ ./manage.py command_lock --try --name clearsessions -- ./manage.py clearsessions
```

To ignore a lock failure and return a successful exit code:

```console
$ ./manage.py command_lock --try --ignore-fail --name clearsessions -- ./manage.py clearsessions
```
55 changes: 0 additions & 55 deletions README.rst

This file was deleted.

2 changes: 1 addition & 1 deletion postgres_lock/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ def release(self):
def __enter__(self):
return self.lock()

def __exit__(self, type, value, traceback):
def __exit__(self, exc_type, exc_value, traceback):
self.release()
2 changes: 1 addition & 1 deletion postgres_lock/management/commands/command_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def execute(self, *args, **options):
using=options["database"],
) as acquired:
if acquired:
completed = subprocess.run(options["command"]) # noqa:S603
completed = subprocess.run(options["command"], check=False) # noqa:S603
# Raise the return code of the child process if an error occurs
if completed.returncode != 0:
sys.exit(completed.returncode)
Expand Down
Loading