Skip to content

Commit

Permalink
Add pyproject.toml and python workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wkoot committed Sep 14, 2023
1 parent 41f55f5 commit 856e050
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 240 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Python

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
include:
- python-version: "3.9"
- python-version: "3.10"
- python-version: "3.11"

steps:
- uses: actions/[email protected]

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install ruff
run: pip install ruff

- name: Run ruff
run: ruff netbox_slm
12 changes: 0 additions & 12 deletions Pipfile

This file was deleted.

192 changes: 0 additions & 192 deletions Pipfile.lock

This file was deleted.

7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,17 @@ And finally, run Netbox with the SLM plugin: ``docker compose up``

To draft a release;

update the setup.py file to reflect the new version, then from the *src*
update the `netbox_slm/__init__.py` file to reflect the new version, then from the *src*
directory run

```
# make sure to update the version in netbox_slm/__init__.py
$ python setup.py sdist
$ python -m build
$ twine upload dist/*
```

On Github.com create a similar tag and version. These steps could be
automated with a github workflow.

n.b. Currently the plugin is configured to use a personal pypi account,
this should be changed.

## Developer Guide (local installation)

Expand Down
3 changes: 2 additions & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ ENV PATH="/opt/netbox/venv/bin:$PATH"

COPY ../ /build

RUN python setup.py sdist
RUN pip install -U .[build]
RUN python -m build
RUN pip install --no-index /build

FROM netboxcommunity/netbox:v3.6.1
Expand Down
4 changes: 3 additions & 1 deletion netbox_slm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from extras.plugins import PluginConfig

__version__ = "1.4"


class SLMConfig(PluginConfig):
name = 'netbox_slm'
verbose_name = 'Software Lifecycle Management'
description = 'Software Lifecycle Management Netbox Plugin.'
version = '1.4'
version = __version__
author = 'ICTU'
author_email = '[email protected]'
base_url = 'slm'
Expand Down
78 changes: 78 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "netbox-slm"
dynamic = ["version"]
description = "Software Lifecycle Management Netbox Plugin"
readme = "README.md"
requires-python = ">=3.9"
license = { text = "Apache-2.0" }
authors = [
{name = "ICTU", email = "[email protected]"},
]
classifiers = [
"Environment :: Web Environment",
"Framework :: Django",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
]
dependencies = []

[project.optional-dependencies]
build = [
"build == 1.0.3",
"setuptools == 68.2.0",
"twine == 3.7.1",
]
tools = [
"black == 23.3.0",
"mypy == 1.4.1",
"ruff == 0.0.275",
]

[tool.setuptools.dynamic]
version = {attr = "app.__version__"}

[tool.setuptools.packages.find]
include = ["netbox_slm"]

[tool.black]
line-length = 120
target-version = ["py39"]
color = true
check = true
diff = true
fast = true

[tool.mypy]
python_version = "3.9"
error_summary = false
ignore_missing_imports = false
incremental = false
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_ignores = true

[tool.ruff]
line-length = 120
target-version = "py39"
format = "github"
src = ["netbox_slm"]

[tool.ruff.per-file-ignores]
"__init__.py" = [
"D104", # https://beta.ruff.rs/docs/rules/#pydocstyle-d - don't require doc strings in __init__.py files
"F401", # https://beta.ruff.rs/docs/rules/#pyflakes-f - don't complain about unused imports in __init__.py files
]
Loading

0 comments on commit 856e050

Please sign in to comment.