Skip to content
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

[INTERNAL] Adopt pyproject.toml #479

Merged
merged 5 commits into from
Feb 13, 2024
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
a81731039c118543398c90869e608dde0acaf32c
# ruff
af2c352786f952d819e69b928bf6c99dcde5954b
# Compile requirements to update comments
5821434b42203b1080dcdc480d1ffcf07fe53a90
4 changes: 2 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

services:
mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: password
ports:
Expand All @@ -42,7 +42,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
setup.cfg
pyproject.toml
docker/requirements.txt

- name: Fetch Promtool
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
setup.cfg
pyproject.toml
docker/requirements.txt

- name: Install graphviz
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ RUN set -ex \
&& apk del build-deps

COPY docker/docker-entrypoint.sh /
COPY setup.py /usr/src/app/setup.py
COPY setup.cfg /usr/src/app/setup.cfg
COPY pyproject.toml /usr/src/app/pyproject.toml
COPY promgen /usr/src/app/promgen
COPY promgen/tests/examples/promgen.yml /etc/promgen/promgen.yml

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ list: $(PIP_BIN)
$(PIP_COMPILE): $(PIP_BIN)
$(PIP_BIN) install pip-tools

docker/requirements.txt: $(PIP_COMPILE) setup.py setup.cfg docker/requirements.in
$(PIP_COMPILE) --output-file docker/requirements.txt setup.py docker/requirements.in --no-emit-index-url
docker/requirements.txt: $(PIP_COMPILE) pyproject.toml docker/requirements.in
$(PIP_COMPILE) --output-file docker/requirements.txt pyproject.toml docker/requirements.in --no-emit-index-url

.PHONY: pip
## Reinstall with pip
Expand Down
26 changes: 13 additions & 13 deletions docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --no-emit-index-url --output-file=docker/requirements.txt docker/requirements.in setup.py
# pip-compile --no-emit-index-url --output-file=docker/requirements.txt docker/requirements.in pyproject.toml
#
amqp==2.6.1
# via kombu
Expand All @@ -11,13 +11,13 @@ asgiref==3.7.2
async-timeout==4.0.2
# via redis
atomicwrites==1.4.1
# via promgen (setup.py)
# via promgen (pyproject.toml)
billiard==3.6.4.0
# via celery
celery[redis]==4.3.0
# via
# -r docker/requirements.in
# promgen (setup.py)
# promgen (pyproject.toml)
certifi==2023.7.22
# via
# requests
Expand All @@ -36,36 +36,36 @@ django==3.2.20
# via
# django-filter
# djangorestframework
# promgen (setup.py)
# promgen (pyproject.toml)
# social-auth-app-django
django-environ==0.10.0
# via promgen (setup.py)
# via promgen (pyproject.toml)
django-filter==23.2
# via promgen (setup.py)
# via promgen (pyproject.toml)
djangorestframework==3.14.0
# via promgen (setup.py)
# via promgen (pyproject.toml)
gunicorn==21.2.0
# via -r docker/requirements.in
idna==3.4
# via requests
kombu==4.6.11
# via
# celery
# promgen (setup.py)
# promgen (pyproject.toml)
oauthlib==3.2.2
# via
# requests-oauthlib
# social-auth-core
packaging==23.1
# via gunicorn
prometheus-client==0.17.1
# via promgen (setup.py)
# via promgen (pyproject.toml)
pycparser==2.21
# via cffi
pyjwt==2.8.0
# via social-auth-core
python-dateutil==2.8.2
# via promgen (setup.py)
# via promgen (pyproject.toml)
python3-openid==3.2.0
# via social-auth-core
pytz==2023.3
Expand All @@ -74,12 +74,12 @@ pytz==2023.3
# django
# djangorestframework
pyyaml==6.0.1
# via promgen (setup.py)
# via promgen (pyproject.toml)
redis==4.6.0
# via celery
requests==2.31.0
# via
# promgen (setup.py)
# promgen (pyproject.toml)
# requests-oauthlib
# social-auth-core
requests-oauthlib==1.3.1
Expand All @@ -89,7 +89,7 @@ sentry-sdk==1.19.1
six==1.16.0
# via python-dateutil
social-auth-app-django==5.2.0
# via promgen (setup.py)
# via promgen (pyproject.toml)
social-auth-core==4.4.2
# via social-auth-app-django
sqlparse==0.4.4
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import django
django.setup()

from promgen.version import __version__
from django.conf import settings


# -- General configuration ------------------------------------------------
Expand Down Expand Up @@ -67,9 +67,9 @@
# built documents.
#
# The short X.Y version.
version = __version__
version = settings.PROMGEN_VERSION
# The full version, including alpha/beta/rc tags.
release = __version__
release = settings.PROMGEN_VERSION

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 3 additions & 2 deletions promgen/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# These sources are released under the terms of the MIT license: see LICENSE

from promgen import models, util
from promgen.version import __version__

from django.conf import settings


def settings_in_view(request):
return {
"TIMEZONE": util.setting("timezone", "UTC"),
"VERSION": __version__,
"VERSION": settings.PROMGEN_VERSION,
"DEFAULT_EXPORTERS": models.DefaultExporter.objects.order_by("job", "-port"),
}
5 changes: 3 additions & 2 deletions promgen/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import importlib.metadata
import os
import pathlib

Expand All @@ -23,11 +24,11 @@

from promgen import PROMGEN_CONFIG_FILE
from promgen.plugins import apps_from_setuptools
from promgen.version import __version__

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = pathlib.Path(__file__).parent.parent
DOT_ENV = BASE_DIR / ".env"
PROMGEN_VERSION = importlib.metadata.version("promgen")

# Load our environment
env = environ.Env()
Expand Down Expand Up @@ -177,7 +178,7 @@
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.celery import CeleryIntegration

os.environ.setdefault("SENTRY_RELEASE", __version__)
os.environ.setdefault("SENTRY_RELEASE", PROMGEN_VERSION)
# By default we want to keep sentry's default of NOT sending user
# information, but in some environments, it's useful for debugging
# purposes so lets add a flag here that we can use.
Expand Down
3 changes: 1 addition & 2 deletions promgen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
from django.conf import settings
from django.db.models import F

from promgen.version import __version__

# Wrappers around request api to ensure we always attach our user agent
# https://github.com/requests/requests/blob/master/requests/api.py


USER_AGENT = f"promgen/{__version__}"
USER_AGENT = f"promgen/{settings.PROMGEN_VERSION}"
ACCEPT_HEADER = (
"application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1"
)
Expand Down
1 change: 0 additions & 1 deletion promgen/version.py

This file was deleted.

4 changes: 2 additions & 2 deletions promgen/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
signals,
tasks,
util,
version,
)
from promgen.shortcuts import resolve_domain

from django.conf import settings
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.contenttypes.models import ContentType
Expand Down Expand Up @@ -1064,7 +1064,7 @@ def collect(self):
v = GaugeMetricFamily(
"promgen_build_info", "Promgen Information", labels=["version", "python"]
)
v.add_metric([version.__version__, platform.python_version()], 1)
v.add_metric([settings.PROMGEN_VERSION, platform.python_version()], 1)
yield v

try:
Expand Down
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "promgen"
version = "0.61.0.dev"
authors = [{ name = "LINE Corporation", email = "[email protected]" }]
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP",
]
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.9"
dependencies = [
"Django~=3.2",
"atomicwrites",
"celery==4.3.0",
"django-environ",
"django-filter",
"djangorestframework",
"kombu",
"prometheus-client",
"python-dateutil",
"pyyaml",
"requests",
"social-auth-app-django>=2.0.0",
]

[tool.setuptools.packages]
find = {}

[project.urls]
Source = "https://github.com/line/promgen"
Tracker = "https://github.com/line/promgen/issues"
Documentation = "https://line.github.io/promgen/"

[project.optional-dependencies]
dev = ["black", "codecov", "flake8", "unittest-xml-reporting"]
docs = ["Sphinx", "sphinxcontrib-httpdomain"]
mysql = ["mysqlclient"]

[project.scripts]
promgen = "promgen.manage:main"

[project.entry-points]
[project.entry-points."promgen.discovery"]
promgen = "promgen.discovery.default:DiscoveryPromgen"

[project.entry-points."promgen.notification"]
email = "promgen.notification.email:NotificationEmail"
linenotify = "promgen.notification.linenotify:NotificationLineNotify"
slack = "promgen.notification.slack:NotificationSlack"
user = "promgen.notification.user:NotificationUser"
webhook = "promgen.notification.webhook:NotificationWebhook"

[tool.black]
line-length = 100
target-version = ['py39']
Expand Down
67 changes: 0 additions & 67 deletions setup.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions setup.py

This file was deleted.

Loading