bootstrap repo

This change creates a minimal functional python
package using the src layout
https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/
pbr and pyproject.toml

A minimal tox config is provided
with pre-commit hooks executed via the pep8 traget for ci.

Change-Id: Ibabb01280da142e3c6a3188b3845356906947757
This commit is contained in:
Sean Mooney
2025-05-01 20:04:17 +01:00
parent e53879beee
commit 570031139f
12 changed files with 320 additions and 2 deletions
+67
View File
@@ -0,0 +1,67 @@
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
.eggs
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
cover/
.tox
nosetests.xml
.testrepository
.venv
node_modules
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# Complexity
output/*.html
output/*/index.html
# Sphinx
doc/build
# pbr generates these
AUTHORS
ChangeLog
# Editors
*~
.*.swp
.*sw?
# Horizon related
*.lock
grian_horizon_plugin/test/.secret_key_store
# Files created by releasenotes build
releasenotes/build
# DS_Store on Mac computers
*.DS_Store
+78
View File
@@ -0,0 +1,78 @@
exclude: '^docs/conf.py'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# whitespace
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
exclude: '.*\.(svg)$'
- id: check-byte-order-marker
# file format and permissions
- id: check-ast
- id: check-json
- id: check-xml
- id: check-yaml
files: .*\.(yaml|yml)$
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# git
- id: check-added-large-files
- id: check-case-conflict
- id: detect-private-key
# python
- id: debug-statements
- id: check-docstring-first
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-tabs
exclude: '.*\.(svg)$'
- repo: https://github.com/PyCQA/bandit
rev: 1.8.3
hooks:
- id: bandit
- repo: https://opendev.org/openstack/bashate
rev: 2.1.1
hooks:
- id: bashate
args: ["--max-line-length", "150"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.2
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
- repo: https://github.com/PyCQA/doc8
rev: v1.1.2
hooks:
- id: doc8
- repo: https://opendev.org/openstack/hacking
rev: 7.0.0
hooks:
- id: hacking
additional_dependencies:
- flake8-import-order~=0.18.2
exclude: '^(doc|releasenotes|tools)/.*$'
- repo: "https://github.com/TotallyNotRobots/check-spdx-header"
rev: '0.1.0'
hooks:
- id: fix-spdx-header
+6 -2
View File
@@ -1,7 +1,11 @@
- project:
check:
jobs:
- noop
- openstack-tox-pep8:
required-projects:
- openstack/horizon
gate:
jobs:
- noop
- openstack-tox-pep8:
required-projects:
- openstack/horizon
+9
View File
@@ -0,0 +1,9 @@
============================================
grian-ui - telemetry visualization dashboard
============================================
* Free software: Apache license
* Documentation: https://docs.openstack.org/grian-ui/latest/
* Release notes: https://docs.openstack.org/releasenotes/grian-ui/
* Source: https://opendev.org/openstack/grian-ui
* Bugs: https://bugs.launchpad.net/grian-ui
+35
View File
@@ -0,0 +1,35 @@
[build-system]
requires = ["pbr>=6.0.0", "setuptools>=64.0.0"]
build-backend = "pbr.build"
[project]
name = "grian-ui"
description = "A horizon dashboard plugin for telemetry visualization"
readme = "README.rst"
authors = [
{name = "OpenStack", email = "openstack-discuss@lists.openstack.org"},
]
requires-python = ">=3.10"
license = "Apache-2.0"
classifiers = [
"Environment :: OpenStack",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
keywords = ["openstack", "horizon", "telemetry"]
[project.urls]
Homepage = "https://opendev.org/openstack/grian-ui"
Documentation = "https://docs.openstack.org/grian-ui/latest/"
Repository = "https://opendev.org/openstack/grian-ui"
Issues = "https://bugs.launchpad.net/grian-ui"
Changelog = "https://docs.openstack.org/releasenotes/grian-ui/"
+9
View File
@@ -0,0 +1,9 @@
# Horizon Core Requirements
django-compressor>=2.0 # MIT
horizon>=18.3.1 # Apache-2.0
oslo.utils>=4.7.0 # Apache-2.0
# Requirements lower bounds listed here are our best effort to keep them up to
# date but we do not test them so no guarantee of having them all correct. If
# you find any incorrect lower bounds, let us know or propose a fix.
pbr>=6.0.0 # Apache-2.0
+3
View File
@@ -0,0 +1,3 @@
# TODO: Delete this file once PBR can read project names from pyproject.toml
[metadata]
name = grian-ui
+6
View File
@@ -0,0 +1,6 @@
#
# SPDX-License-Identifier: Apache-2.0
import setuptools
setuptools.setup(setup_requires=["pbr>=2.0.0"], pbr=True)
+2
View File
@@ -0,0 +1,2 @@
#
# SPDX-License-Identifier: Apache-2.0
+6
View File
@@ -0,0 +1,6 @@
#
# SPDX-License-Identifier: Apache-2.0
def main():
print("hi")
+10
View File
@@ -0,0 +1,10 @@
coverage>=4.4.1 # Apache-2.0
ddt>=1.2.1 # MIT
django
fixtures>=3.0.0 # Apache-2.0/BSD
hacking==6.1.0 # Apache-2.0
oslotest>=3.8.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0
testresources>=2.0.0 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=2.5.0 # MIT
+89
View File
@@ -0,0 +1,89 @@
[tox]
minversion = 3.18.0
envlist = pep8,unit
[testenv]
usedevelop = True
allowlist_externals =
bash
find
rm
env
make
install_command = python -I -m pip install -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
LANGUAGE=en_US
LC_ALL=en_US.utf-8
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=160
PYTHONDONTWRITEBYTECODE=1
deps =
-r{toxinidir}/test-requirements.txt
passenv =
# LOCALE_ARCHIVE is needed when not using python from the system package
# manager (e.g. when installed with nix) to ensure the locale-archive is
# available to the tests. specifically this is needed by sphinx to build
# the docs.
LOCALE_ARCHIVE
OS_DEBUG
GENERATE_HASHES
# Note(sean-k-mooney):
# leaking greanthreads between tests is a bug so we should fail if it happens
# however unlike greenthreads, greenlets cannot be killed via a test fixture.
# greenlet leaks will be annotated in the test details but will not cause a
# failure. if you want to make them raise set
# NOVA_RAISE_ON_GREENLET_LEAK=1|true|yes
# All leaks of green threads have been resolved in the unit and functional
# suite
NOVA_RAISE_ON_GREENLET_LEAK
# NOTE(sean-k-mooney) optimization is enabled by default and when enabled
# asserts are complied out. Disable optimization to allow asserts in
# nova to fire in unit and functional tests. This can be useful for
# debugging issue with fixtures and mocks.
PYTHONOPTIMIZE
# there is also secret magic in subunit-trace which lets you run in a fail only
# mode. To do this define the TRACE_FAILONLY environmental variable.
TRACE_FAILONLY
commands =
stestr run {posargs}
stestr slowest
[testenv:pep8]
description =
Run style checks.
deps =
pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure
[testenv:{unit,py3,py310,py311,py312,py313}]
set_env =
{[testenv]setenv}
[testenv:venv]
deps =
{[testenv]deps}
-r{toxinidir}/doc/requirements.txt
commands =
{posargs}
[flake8]
# We only enable the hacking (H) and local checks (N)
select = H,N
filename = *.py,app.wsgi
show-source=True
# W504 line break after binary operator
# H301 Black will put commas after imports that can't fit on one line
# H404 Docstrings don't always start with a newline
# H405 Multiline docstrings are okay
# H105 disable blocking author tags
# H202 assertRaises Exception too broad
# H104: File contains nothing but comments
ignore = H301,H403,H404,H405,H105,H202,H104
builtins= _
enable-extensions = H106,H203,H904
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,*sqlalchemy/alembic/versions/*,demo/,releasenotes