Skip to content

Commit

Permalink
Py 312 pytoml (#1)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
rh0dium authored Dec 28, 2023
1 parent 7e7c2fc commit bf6441b
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 114 deletions.
10 changes: 0 additions & 10 deletions .coveragerc

This file was deleted.

87 changes: 32 additions & 55 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .
Expand All @@ -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
Expand All @@ -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() }}
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -228,20 +208,17 @@ 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
- name: Release
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
2 changes: 1 addition & 1 deletion .idea/django-bootstrap-templatetags.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file removed __init__.py
Empty file.
107 changes: 101 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
]
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 = '''
/(
Expand All @@ -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"
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements_dev.txt

This file was deleted.

33 changes: 0 additions & 33 deletions setup.py

This file was deleted.

0 comments on commit bf6441b

Please sign in to comment.