Skip to content

Commit

Permalink
new: dev: enable full PEP517 packaging, cleanup some import lint
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen L Arnold <[email protected]>
  • Loading branch information
sarnold committed Nov 24, 2023
1 parent b1aea7f commit 545b0da
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 153 deletions.
37 changes: 11 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: check-useless-excludes
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -17,6 +17,7 @@ repos:
- id: debug-statements
#- id: requirements-txt-fixer
- id: fix-encoding-pragma
args: ['--remove']
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: '(.*examples/.*)'
Expand Down Expand Up @@ -53,7 +54,7 @@ repos:
#- id: rst-inline-touching-normal

- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.2.1
hooks:
- id: autoflake
files: ^usb_protocol.*\.py$
Expand All @@ -62,8 +63,8 @@ repos:
- --remove-duplicate-keys
- --remove-unused-variables

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
files: ^usb_protocol.*\.py$
Expand All @@ -76,22 +77,22 @@ repos:
# args: [--config=pyproject.toml]

- repo: https://github.com/pycqa/isort
rev: 5.5.4
rev: 5.12.0
hooks:
- id: isort
args: [--settings-path=pyproject.toml]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
rev: v1.7.1
hooks:
- id: mypy
additional_dependencies:
- construct==2.10.67
- construct-typing==0.5.2
- construct>=2.10.67
- construct-typing>=0.5.2
args:
- --follow-imports=normal
#- --install-types
#- --non-interactive
- --install-types
- --non-interactive
files: ^usb_protocol.*\.py$

# - repo: https://github.com/psf/black
Expand Down Expand Up @@ -120,19 +121,3 @@ repos:
#"-sn",
#"--fail-under=8.10",
#]

ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false

# re-running a pull request: you can trigger a re-run on a pull request by
# commenting pre-commit.ci run (must appear on a line by itself).
# skipping push runs: skip a run by putting [skip ci], [ci skip],
# [skip pre-commit.ci], or [pre-commit.ci skip] in the commit message.
14 changes: 0 additions & 14 deletions MANIFEST.in

This file was deleted.

39 changes: 33 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
[build-system]
[build-system] # these versions are valid on python 3.7 and up
requires = [
"setuptools>=42",
"wheel",
"setuptools_scm[toml]>=6.2",
"setuptools>=61",
"setuptools_scm[toml]>=7",
]

build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = ["tests",]
log_cli = true
doctest_optionflags = ["ELLIPSIS", "NORMALIZE_WHITESPACE",]
addopts = "--strict-markers"
markers = "subscript"

[tool.setuptools_scm]

[tool.coverage.run]
branch = true
source = ["usb_protocol"]
source = [
"usb_protocol",
".tox/py*/lib/python*/site-packages/",
]
omit = [
"docs",
"examples",
"tests",
".tox",
Expand All @@ -27,6 +37,23 @@ show_missing = true

[tool.black]
line-length = 250
skip-string-normalization = true
include = '\.py$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| docs
| dist
| tests
)/
'''

[tool.pycln]
all = true
Expand Down
91 changes: 69 additions & 22 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,23 +1,50 @@
[metadata]
name = usb_protocol
version = attr: setuptools_scm.get_version
description = utilities, data structures, constants, parsers, and tools for working with USB data
url = https://github.com/greatscottgadgets/python-usb-protocol
author = Katherine J. Temkin
author_email = [email protected]
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
license_expression = BSD-3-Clause
license_files = LICENSE.txt
classifiers =
Development Status :: 1 - Planning
Intended Audience :: Science/Research
Intended Audience :: Developers
Programming Language :: Python
Programming Language :: Python :: 3
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Environment :: Console
Environment :: Plugins
Topic :: Scientific/Engineering
Topic :: Software Development
Topic :: Security

# deps are included here mainly for local/venv installs using pip
# otherwise deps are handled via tox, ci config files or pkg managers
[options]
python_requires = >=3.7

install_requires =
construct
importlib-metadata; python_version < '3.8'

# nothing special required for auto-discovery / flat layout
[options.extras_require]
# deps are included below mainly for local/venv installs using pip
# otherwise deps may be handled via tox, ci config files or pkg managers
doc =
sphinx
recommonmark
sphinx_rtd_theme
sphinxcontrib-apidoc

test =
pytest

cov =
pytest-cov
cov =
coverage[toml]
coverage_python_version

all =
%(cov)s
%(doc)s
Expand All @@ -26,6 +53,10 @@ all =
[bdist_wheel]
universal = 1

[check]
metadata = true
strict = false

[check-manifest]
ignore =
.codeclimate.yml
Expand All @@ -48,22 +79,38 @@ max-line-length = 250
max-complexity = 10
addons = file,open,basestring,xrange,unicode,long,cmp
ignore =
W503, # line break before binary operator
F401, # imported but unused
F403, # star import used; unable to detect undefined names
F405, # may be undefined, or defined from star imports
E266, # too many leading '#' for block comment
E203, # whitespace before ':'
E221, # multiple spaces before operator
E222, # multiple spaces after operator
E241, # multiple spaces after ','
E261, # at least two spaces before inline comment
E271, # multiple spaces after keyword
E272, # multiple spaces before keyword
E303, # too many blank lines
E302, # expected 2 blank lines, found 1
E305, # expected 2 blank lines after class or function definition
E731, # do not assign a lambda expression, use a def
# line break before binary operator
W503,
# imported but unused
F401,
# star import used; unable to detect undefined names
F403,
# may be undefined, or defined from star imports
F405,
# too many leading '#' for block comment
E266,
# whitespace before ':'
E203,
# multiple spaces before operator
E221,
# multiple spaces after operator
E222,
# multiple spaces after ','
E241,
# at least two spaces before inline comment
E261,
# multiple spaces after keyword
E271,
# multiple spaces before keyword
E272,
# too many blank lines
E303,
# expected 2 blank lines, found 1
E302,
# expected 2 blank lines after class or function definition
E305,
# do not assign a lambda expression, use a def
E731,

[nosetests]
verbosity = 3
Expand Down
53 changes: 3 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,4 @@
# -*- coding: utf-8 -*-
# minimal compat stub
import setuptools

from setuptools import setup

setup(

# Vitals
name='usb_protocol',
license='BSD',
url='https://github.com/usb-tool/luna',
author='Katherine J. Temkin',
author_email='[email protected]',
description='python library providing utilities, data structures, constants, parsers, and tools for working with USB data',
use_scm_version= {
"root": '..',
"relative_to": __file__,
"version_scheme": "guess-next-dev",
"local_scheme": lambda version : version.format_choice("+{node}", "+{node}.dirty"),
"fallback_version": "0.0"
},

# Imports / exports / requirements.
platforms='any',
packages=[
'usb_protocol',
'usb_protocol.emitters',
'usb_protocol.types',
],
package_dir={'usb_protocol': 'usb_protocol',
'usb_protocol.emitters': 'usb_protocol/emitters',
'usb_protocol.types': 'usb_protocol/types',
},
include_package_data=True,
python_requires="~=3.7",
install_requires=['construct'],

# Metadata
classifiers = [
'Programming Language :: Python',
'Development Status :: 1 - Planning',
'Natural Language :: English',
'Environment :: Console',
'Environment :: Plugins',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering',
'Topic :: Security',
],
)
setuptools.setup()
Loading

0 comments on commit 545b0da

Please sign in to comment.