From c1fdb3b59140807e50f074a76c0d0d77926a0c8b Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Wed, 15 May 2024 13:31:40 +0200 Subject: [PATCH] Proof of Concept for pyproject.toml --- .gitignore | 48 +++++++++++++++++++---------------- README.md | 1 + bugsink/scripts/manage.py | 33 ++++++++++++++++++++++++ bugsink/version.py | 8 ++++++ pyproject.toml | 53 +++++++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 6 files changed, 122 insertions(+), 22 deletions(-) create mode 100644 README.md create mode 100755 bugsink/scripts/manage.py create mode 100644 bugsink/version.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 26bc4b0..d61490f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,32 +2,36 @@ *.pyc __pycache__ -# Virtual Environments -.env -.venv -bin/ -include/ -lib/ -lib64 -pyvenv.cfg -share/ +# Virtual Environments / build +/.env +/.venv +/bin/ +/include/ +/lib/ +/lib64 +/pyvenv.cfg +/share/ +/Bugsink.egg-info/ +/bugsink/_version.py +/dist/ + # sqlite -db.sqlite3 -db.*.sqlite3 -test.sqlite3 +/db.sqlite3 +/db.*.sqlite3 +/test.sqlite3 -db.sqlite3-wal -db.*.sqlite3-wal -test.sqlite3-wal +/db.sqlite3-wal +/db.*.sqlite3-wal +/test.sqlite3-wal -db.sqlite3-shm -db.*.sqlite3-shm -test.sqlite3-shm +/db.sqlite3-shm +/db.*.sqlite3-shm +/test.sqlite3-shm -snappea.sqlite3 -snappea.sqlite3-shm -snappea.sqlite3-wal +/snappea.sqlite3 +/snappea.sqlite3-shm +/snappea.sqlite3-wal # vim *.swo @@ -38,4 +42,4 @@ node_modules /package* # conf -bugsink_conf.py +/bugsink_conf.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..1333ed7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +TODO diff --git a/bugsink/scripts/manage.py b/bugsink/scripts/manage.py new file mode 100755 index 0000000..cb96ca1 --- /dev/null +++ b/bugsink/scripts/manage.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +"""A copy of the Django-generated manage.py, but: + +* in the bugsink.scripts package, such that it can be wrapped by a setuptools-installable script +* with the DJANGO_SETTINGS_MODULE set to `bugsink_conf` by default. + +""" +import os +import sys + + +def main(): + # To maintain equivalent behavior to `python manage.py` / `python -m bugsink.scripts.manage` when running this + # script as `bugsink-manage` we need to add the current directory to sys.path. Otherwise the Django settings module + # will not be found if it is in the current directory. + cwd = os.getcwd() + if cwd not in sys.path: + sys.path.insert(0, cwd) + + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bugsink_conf') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/bugsink/version.py b/bugsink/version.py new file mode 100644 index 0000000..c42ba00 --- /dev/null +++ b/bugsink/version.py @@ -0,0 +1,8 @@ +try: + # The _version.py file is generated by setuptools_scm during release and should contain the right version number + from ._version import version, __version__, version_tuple, __version_tuple__ +except ImportError: + # The case where this file does not exist is: during development. In this case, we set the version to unknown, such + # that at least we don't crash when trying to get the version number. + version = __version__ = "0.0.0+unknown" + __version_tuple__ = version_tuple = (0, 0, 0, 'unknown') diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..86b4416 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,53 @@ +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_file = "bugsink/_version.py" + +[project] +name = "Bugsink" +authors = [ + {name = "Bugsink B.V.", email = "klaas@vanschelven.com"}, +] +description = "Dead simple crash monitoring." +readme = "README.md" +requires-python = ">=3.8" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python :: 3", +] +dynamic = ["version", "dependencies"] + +[project.scripts] +bugsink-manage = "bugsink.scripts.manage:main" +bugsink-create-example-conf = "bugsink.scripts.create_example_conf:main" + +[tool.setuptools] +include-package-data = true # this is the default, but explicit is better than implicit + +[tool.setuptools.packages.find] +where = ["."] +include = [ + "alerts*", + "api*", + "bugsink*", + "compat*", + "events*", + "ingest*", + "issues*", + "performance*", + "projects*", + "releases*", + "sentry*", + "sentry_sdk_extensions*", + "snappea*", + "static*", + "templates*", + "theme*", +] + +# exclude = ["my_package.tests*"] # exclude packages matching these glob patterns (empty by default) + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} diff --git a/requirements.txt b/requirements.txt index 9dec10b..90bb765 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ django-admin-autocomplete-filter==0.7.* pygments==2.16.* inotify_simple brotli +python-dateutil # testing/development only: requests