From bf6441bdf363e661a3f3fd12468f7a4004b819c9 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 28 Dec 2023 16:39:45 -0700 Subject: [PATCH] Py 312 pytoml (#1) * Updated project configuration and dependencies Removed requirements files and setup.py and replaced it with configuration in pyproject.toml. This includes specifying dependencies and optional dependencies for testing. Also, updated Python version to 3.12 in project settings to reflect changelog. Changed Python version from 3.10 to 3.12 in Github workflows. Also replaced older dependency installation method, based on setup.py and requirements.txt, with a simpler approach, by installing projects directly using pip install . and pip install .[test]. These changes aim to make dependency management simpler and more efficient. --------- Signed-off-by: Steven K --- .coveragerc | 10 --- .github/workflows/main.yml | 87 +++++++------------ .idea/django-bootstrap-templatetags.iml | 2 +- .idea/misc.xml | 2 +- __init__.py | 0 pyproject.toml | 107 ++++++++++++++++++++++-- requirements.txt | 1 - requirements_dev.txt | 7 -- setup.py | 33 -------- 9 files changed, 135 insertions(+), 114 deletions(-) delete mode 100644 .coveragerc delete mode 100644 __init__.py delete mode 100644 requirements.txt delete mode 100644 requirements_dev.txt delete mode 100644 setup.py diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 6109399..0000000 --- a/.coveragerc +++ /dev/null @@ -1,10 +0,0 @@ -[run] -branch = True -omit = - */migrations/* - -[report] -fail_under = 65 -omit = - */migrations/* - */test* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b21ae0d..ab661b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,20 +21,17 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" cache: 'pip' - cache-dependency-path: | - setup.py - requirements*.txt + - name: Install dependencies run: | - python setup.py install python -m pip install --upgrade pip - pip install -r requirements.txt --user - pip install -r requirements_dev.txt --user + pip install . + pip install .[test] - name: outdated - run: pip list --outdated --not-required --exclude=django --user | grep . && echo "There are outdated packages" && exit 1 || echo "All packages up to date" + run: pip list --outdated --not-required --user | grep . && echo "There are outdated packages" && exit 1 || echo "All packages up to date" black: name: Black @@ -43,17 +40,14 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" cache: 'pip' - cache-dependency-path: | - setup.py - requirements*.txt + - name: Install dependencies run: | - python setup.py install python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_dev.txt + pip install . + pip install .[test] - name: Black run: black --check . @@ -65,17 +59,14 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" cache: 'pip' - cache-dependency-path: | - setup.py - requirements*.txt + - name: Install dependencies run: | - python setup.py install python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_dev.txt + pip install . + pip install .[test] pre-commit install - name: Pre-Commit @@ -88,19 +79,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" cache: 'pip' - cache-dependency-path: | - setup.py - requirements*.txt - name: Install dependencies run: | - python setup.py install - pip install bandit + pip install . + pip install .[test] - name: Bandit - run: bandit -r bootstrap_templatetags -x bootstrap_templatetags/tests.py -s B308,B703 -f json -o report.json + run: bandit -c pyproject.toml -r -f json -o report.json . - name: Show report if: ${{ success() || failure() }} @@ -116,13 +104,13 @@ jobs: tests: name: Python ${{ matrix.python-version }} / ${{ matrix.db }} / Django ${{ matrix.django-version}} runs-on: ubuntu-latest -# continue-on-error: ${{ matrix.django-version == '~=4.2.0' }} +# continue-on-error: ${{ matrix.django-version == '~=5.0' }} strategy: max-parallel: 4 matrix: db: [ sqlite, mariadb ] - django-version: [ "~=4.2.0" ] - python-version: [ "3.10" ] + django-version: ["~=4.2.0", "~=5.0"] + python-version: [ "3.12" ] services: mariadb: @@ -150,27 +138,19 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' - cache-dependency-path: | - setup.py - requirements*.txt + - name: Install dependencies run: | - python setup.py install - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements_dev.txt + pip install . + pip install .[test] pip uninstall -y Django pip install Django${{ matrix.django-version }} - name: Run ${{ matrix.db }} Django ${{ matrix.django-version }} Tests env: PYTHONWARNINGS: once::DeprecationWarning - TASK_ALWAYS_EAGER: 1 DB_TYPE: ${{ matrix.db }} - run: | - export PYTHONPATH=`pwd` - coverage run demo/manage.py test --noinput --settings=demo.settings_test bootstrap_templatetags - + run: export PYTHONPATH=`pwd` && coverage run - name: "Upload Coverage Results for PY:${{ matrix.python-version }} DB:${{ matrix.db}} DJ:${{ matrix.django-version }}" uses: actions/upload-artifact@v3 with: @@ -179,9 +159,7 @@ jobs: retention-days: 1 - name: Django Check - run: | - export PYTHONPATH=`pwd` - python demo/manage.py check + run: python demo/manage.py check coverage: name: Upload Coverage to Codecov @@ -191,10 +169,12 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies - run: pip install -q coverage + run: | + pip install . + pip install .[test] - uses: actions/download-artifact@v3 with: @@ -203,7 +183,7 @@ jobs: - name: Combine Report Coverage run: | coverage combine coverage-*/.coverage - coverage report --precision=1 --sort=cover --skip-covered --skip-empty + coverage report coverage xml - name: Upload coverage to Codecov @@ -228,7 +208,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.12" - name: Install dependencies run: | pip install git+https://${{ secrets.ORGANIZATIONAL_REPO_TOKEN }}@github.com/pivotal-energy-solutions/tensor-infrastructure@master#egg=infrastructure @@ -236,12 +216,9 @@ jobs: id: release env: PYTHONWARNINGS: once::DeprecationWarning - TASK_ALWAYS_EAGER: 1 GITHUB_TOKEN: ${{ secrets.ORGANIZATIONAL_REPO_TOKEN }} run: | - bumper.py --directory . --exclude=.github \ - --version_files bootstrap_templatetags/__init__.py \ - --repo=pivotal-energy-solutions/django-bootstrap-templatetags > out.json + bumper -P echo "bumped=$(jq '.bumped' out.json)" >> $GITHUB_OUTPUT echo "bump_version=$(jq '.bump_version' out.json)" >> $GITHUB_OUTPUT echo "bump_sha=$(jq '.bump_sha' out.json)" >> $GITHUB_OUTPUT diff --git a/.idea/django-bootstrap-templatetags.iml b/.idea/django-bootstrap-templatetags.iml index 99a3ba8..d3b0b71 100644 --- a/.idea/django-bootstrap-templatetags.iml +++ b/.idea/django-bootstrap-templatetags.iml @@ -16,7 +16,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index d214e42..73e2b1e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml index d11a4b6..681a419 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,78 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "django-bootstrap-templatetags" +dynamic = ["version"] +description = "Vanilla Bootstrap structures in simple rendering blocks" +readme = "README.md" +requires-python = ">=3.9" +authors = [ + { name = "Pivotal Energy Solutions", email = "steve@pivotal.energy" }, +] +keywords = [ + "django", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Framework :: Django", + "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Utilities", +] +dependencies = [ + "django>=4.2", +] + +[project.optional-dependencies] +test = [ + "django-environ", + "mysqlclient", + "flake8", + "coverage", + "pre-commit", + "black", + "bandit" +] + +[project.urls] +Homepage = "https://github.com/pivotal-energy-solutions/django-bootstrap-templatetags" +Issues = "https://github.com/pivotal-energy-solutions/django-bootstrap-templatetags/issues" +Download = "https://github.com/pivotal-energy-solutions/django-bootstrap-templatetags" +Thanks = "https://saythanks.io/to/rh0dium" +Source = "https://github.com/pivotal-energy-solutions/django-bootstrap-templatetags/" + +[tool.hatch.version] +path = "bootstrap_templatetags/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/bootstrap_templatetags", + "/bootstrap_templatetags/templates/**/*", + "/bootstrap_templatetags/static/**/*", +] + +[tool.hatch.build.targets.wheel] +packages = ['bootstrap_templatetags'] +include = [ + "/bootstrap_templatetags/templates/**/*", + "/bootstrap_templatetags/static/**/*", +] + [tool.black] line-length = 100 -target-version = ['py310'] +target-version = ['py311'] include = '\.pyi?$' exclude = ''' /( @@ -13,8 +85,31 @@ exclude = ''' | dist )/ ''' -extend-exclude = ''' -# A regex preceded with ^/ will apply only to files and directories -# in the root of the project. -/static/.py # exclude a file named foo.py in the root of the project (in addition to the defaults) -''' + +[tool.bandit] +targets = ['bootstrap_templatetags'] +exclude_dirs = ["bootstrap_templatetags/tests.py", "demo"] +skips = ["B308", "B703", ] + +[tool.coverage.run] +branch = true +command_line = "demo/manage.py test --noinput --settings=demo.settings_test bootstrap_templatetags" +omit = [ + "*/demo/**", + "*/migrations/*", + "*/tests/**", +] + +[tool.coverage.report] +fail_under = 65 +precision = 1 +skip_covered = true +skip_empty = true +ignore_errors = true +sort = "cover" + +[tool.bumper] +exclude = [".idea", ".github", "demo"] +version_files = ["bootstrap_templatetags/__init__.py"] +repo = "pivotal-energy-solutions/django-bootstrap-templatetags" +report = "out.json" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5f83046..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -# Nothing needed diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index c18eed6..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -django-environ -mysqlclient -flake8 -tox -coverage -pre-commit -black diff --git a/setup.py b/setup.py deleted file mode 100644 index fb2d988..0000000 --- a/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- - -from setuptools import setup, find_packages - -setup( - name="django-bootstrap-templatetags", - version="2.1.28", - description="Vanilla Bootstrap structures in simple rendering blocks", - author="Autumn Valenta", - author_email="steven@pivotal.energy", - packages=find_packages(exclude=["demo", "bootstrap_templatetags/test*"]), - include_package_data=True, - url="https://github.com/pivotal-energy-solutions/django-bootstrap-templatetags", - license="Apache License 2.0", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.0", - "Intended Audience :: Developers", - "License :: Other/Proprietary License (Proprietary)", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Utilities", - ], - python_requires=">=3.9", - install_requires=[ - "django>=4.0", - ], -)