Skip to content

refactor: PEP-518 and use uv #42

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = docs
max-line-length = 120
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

## Contributors

None yet. Why not be the first?
- Gary Reynolds \<<[email protected]>\>
54 changes: 20 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,58 +42,49 @@ The best way to send feedback is to file an issue at https://github.com/namespac
If you are proposing a feature:

- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to
implement.
- Remember that this is a volunteer-driven project, and that
contributions are welcome :)
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)

## Get Started!

Ready to contribute? Here's how to set up django-datadog-logger for local development.

1. Fork the repo on GitHub.

https://github.com/namespace-ee/django-datadog-logger/fork

2. Clone your fork locally:

``` shell
$ git clone [email protected]:your_name_here/django-datadog-logger.git
git clone [email protected]:your_name_here/django-datadog-logger.git
```

3. Install your local copy into a virtualenv. Assuming you have
virtualenvwrapper installed, this is how you set up your fork for
local development:
3. Install your local copy into a virtualenv. Assuming you have `uv` installed, this is how you set up your fork for development:

``` shell
$ mkvirtualenv django-datadog-logger
$ cd django-datadog-logger/
$ python setup.py develop
uv sync
```

4. Create a branch for local development:

``` shell
$ git checkout -b name-of-your-bugfix-or-feature
git switch -c name-of-your-bugfix-or-feature
```

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8
and the tests, including testing other Python versions with tox:
5. When you're done making changes, check that your changes pass `flake8` and the tests, including testing other Python versions with `tox`. For convenience, that is wrapped up as `make test-all`:

``` shell
$ flake8 django_datadog_logger tests
$ make test
$ tox
make test-all
```

To get flake8 and tox, just pip install them into your virtualenv.

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

``` shell
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
git add .
git commit -m "Your detailed description of your changes."
git push origin name-of-your-bugfix-or-feature
```

7. Submit a pull request through the GitHub website.
Expand All @@ -103,23 +94,18 @@ Ready to contribute? Here's how to set up django-datadog-logger for local develo
Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated.
Put your new functionality into a function with a docstring, and add
the feature to the list in README.md.
3. The pull request should work for Python 3.6, 3.7 and 3.8, and for
PyPy. Check
<https://github.com/namespace-ee/django-datadog-logger/actions> and
make sure that the tests pass for all supported Python versions.
2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`.
3. The pull request should work for CPython 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13, and for PyPy 3.8, 3.9, 3.10, 3.11. Check https://github.com/namespace-ee/django-datadog-logger/actions and make sure that the tests pass for all supported Python versions.

## Deploying

A reminder for the maintainers on how to deploy. Make sure all your
changes are committed (including an entry in HISTORY.md). Then run:
A reminder for the maintainers on how to deploy.

Make sure all your changes are committed (including an entry in `HISTORY.md`). Then run:

``` shell
$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags
git push
git push --tags
```

GitHub Actions will then deploy to PyPI if tests pass.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## Unreleased

- Converted to PEP-518 with `pyproject.toml` and preference for `uv`

## 0.6.2 (2023-04-27)

- Fixed case where accessing request.auth may raise errors
Expand Down
12 changes: 0 additions & 12 deletions MANIFEST.in

This file was deleted.

30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ for line in sys.stdin:
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"
UV := uv run
BROWSER := $(UV) python -c "$$BROWSER_PYSCRIPT"

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
@$(UV) python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
clean: clean-test clean-build clean-pyc ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
rm -fr build/
Expand All @@ -48,38 +49,37 @@ clean-test: ## remove test and coverage artifacts
rm -fr .pytest_cache

lint: ## check style with flake8
flake8 django_datadog_logger tests
$(UV) tox -e flake8

test: ## run tests quickly with the default Python
DJANGO_SETTINGS_MODULE=tests.settings python -m unittest discover
DJANGO_SETTINGS_MODULE=tests.settings $(UV) -m unittest discover -v

test-all: ## run tests on every Python version with tox
tox
$(UV) tox

coverage: ## check code coverage quickly with the default Python
DJANGO_SETTINGS_MODULE=tests.settings coverage run --source django_datadog_logger setup.py test
coverage report -m
coverage html
DJANGO_SETTINGS_MODULE=tests.settings $(UV) coverage run --source django_datadog_logger -m unittest discover -v
$(UV) coverage report -m
$(UV) coverage html
$(BROWSER) htmlcov/index.html

docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/django_datadog_logger.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ django_datadog_logger
$(UV) sphinx-apidoc -o docs/ django_datadog_logger
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
$(UV) watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: dist ## package and upload a release
twine upload dist/*
uv publish

dist: clean ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
uv build
ls -l dist

install: clean ## install the package to the active Python's site-packages
python setup.py install
uv sync --frozen
1 change: 0 additions & 1 deletion django_datadog_logger/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = "0.7.3"
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
django_datadog_logger.*.rst
django_datadog_logger.rst
modules.rst
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXBUILD = uv run -m sphinx
SPHINXPROJ = django_datadog_logger
SOURCEDIR = .
BUILDDIR = _build
Expand Down
10 changes: 7 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

sys.path.insert(0, os.path.abspath(".."))

import django_datadog_logger
try:
import importlib.metadata as importlib_metadata
except ImportError:
# For Python 3.7, we use the backport 'importlib_metadata'
import importlib_metadata

# -- General configuration ---------------------------------------------

Expand Down Expand Up @@ -57,9 +61,9 @@
# the built documents.
#
# The short X.Y version.
version = django_datadog_logger.__version__
version = importlib_metadata.version("django_datadog_logger")
# The full version, including alpha/beta/rc tags.
release = django_datadog_logger.__version__
release = importlib_metadata.version("django_datadog_logger")

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 0 additions & 2 deletions docs/requirements.txt

This file was deleted.

67 changes: 66 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,71 @@
[build-system]
requires = ["setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "django-datadog-logger"
description = "Django DataDog Logger integration package."
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">=3.7"
license = {file = "LICENSE"}
authors = [
{name = "Lenno Nagel", email = "[email protected]"}
]
keywords = ["django_datadog_logger"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]
dependencies = [
"backports.zoneinfo; python_version<'3.9'",
"Django",
"djangorestframework",
"JSON-log-formatter",
]

[project.urls]
Homepage = "https://github.com/namespace-ee/django-datadog-logger"

[dependency-groups]
dev = [
"coverage",
"tox",
"watchdog",
]
docs = [
# Documentation will be built with the Python from .python-version
"sphinx>=7,<8; python_version>'3.8'",
"myst-parser>=2,<3; python_version>'3.8'",
"importlib-metadata; python_version<'3.8'",
]
pep8 = [
"black",
"flake8",
"isort",
]

[tool.setuptools]
packages = ["django_datadog_logger"]
zip-safe = false
include-package-data = true

[tool.setuptools_scm]

[tool.black]
line-length = 120
target-version = ["py37", "py38"]
target-version = ["py37", "py38", "py39", "py310", "py311", "py312", "py313"]
include = '\.pyi?$'
exclude = '''
/(
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements_dev.txt

This file was deleted.

21 changes: 0 additions & 21 deletions setup.cfg

This file was deleted.

Loading