* Convert to PEP-517 project

* Move pylint and coverage configs to pyproject.toml

* Remove autogenerated C files
This commit is contained in:
ZipFile 2024-11-10 07:01:30 +02:00 committed by GitHub
parent abf2a2577c
commit 494c457643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 158 additions and 268887 deletions

View File

@ -1,10 +0,0 @@
[run]
source = dependency_injector
omit = tests/unit
plugins = Cython.Coverage
[report]
show_missing = true
[html]
directory=reports/unittests/

View File

@ -50,7 +50,6 @@ jobs:
with: with:
python-version: 3.12 python-version: 3.12
- run: pip install tox 'cython>=3,<4' - run: pip install tox 'cython>=3,<4'
- run: make cythonize
- run: tox -vv - run: tox -vv
env: env:
TOXENV: coveralls TOXENV: coveralls

12
.gitignore vendored
View File

@ -63,13 +63,11 @@ venv*/
# Vim Rope # Vim Rope
.ropeproject/ .ropeproject/
# C extensions # Cython artifacts
src/dependency_injector/*.h src/**/*.c
src/dependency_injector/*.so src/**/*.h
src/dependency_injector/containers/*.h src/**/*.so
src/dependency_injector/containers/*.so src/**/*.html
src/dependency_injector/providers/*.h
src/dependency_injector/providers/*.so
# Workspace for samples # Workspace for samples
.workspace/ .workspace/

View File

@ -1,49 +0,0 @@
[MASTER]
# Add <file or directory> to the black list. It should be a base name, not a
# path. You may set this option multiple times.
ignore=utils,tests
[MESSAGES CONTROL]
# Disable the message(s) with the given id(s).
# disable-msg=
[SIMILARITIES]
# Minimum lines number of a similarity.
min-similarity-lines=5
[TYPECHECK]
ignore-mixin-members=yes
# ignored-classes=
zope=no
# generated-members=providedBy,implementedBy,rawDataReceived
[DESIGN]
# Maximum number of arguments for function / method
max-args=10
# Maximum number of locals for function / method body
max-locals=20
# Maximum number of return / yield for function / method body
max-returns=10
# Maximum number of branch for function / method body
max-branchs=10
# Maximum number of statements in function / method body
max-statements=60
# Maximum number of parents for a class (see R0901).
max-parents=10
# Maximum number of attributes for a class (see R0902).
max-attributes=30
# Minimum number of public methods for a class (see R0903).
min-public-methods=0
# Maximum number of public methods for a class (see R0904).
max-public-methods=30

View File

@ -1,14 +1,6 @@
VERSION := $(shell python setup.py --version) VERSION := $(shell python setup.py --version)
CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx') export COVERAGE_RCFILE := pyproject.toml
CYTHON_DIRECTIVES = -Xlanguage_level=3
ifdef DEPENDENCY_INJECTOR_DEBUG_MODE
CYTHON_DIRECTIVES += -Xprofile=True
CYTHON_DIRECTIVES += -Xlinetrace=True
endif
clean: clean:
# Clean sources # Clean sources
@ -25,21 +17,17 @@ clean:
find examples -name '*.py[co]' -delete find examples -name '*.py[co]' -delete
find examples -name '__pycache__' -delete find examples -name '__pycache__' -delete
cythonize: build: clean
# Compile Cython to C # Compile C extensions
cython -a $(CYTHON_DIRECTIVES) $(CYTHON_SRC) python setup.py build_ext --inplace
# Move all Cython html reports # Move all Cython html reports
mkdir -p reports/cython/ mkdir -p reports/cython/
find src -name '*.html' -exec mv {} reports/cython/ \; find src -name '*.html' -exec mv {} reports/cython/ \;
build: clean cythonize
# Compile C extensions
python setup.py build_ext --inplace
docs-live: docs-live:
sphinx-autobuild docs docs/_build/html sphinx-autobuild docs docs/_build/html
install: uninstall clean cythonize install: uninstall clean build
pip install -ve . pip install -ve .
uninstall: uninstall:
@ -48,9 +36,9 @@ uninstall:
test: test:
# Unit tests with coverage report # Unit tests with coverage report
coverage erase coverage erase
coverage run --rcfile=./.coveragerc -m pytest -c tests/.configs/pytest.ini coverage run -m pytest -c tests/.configs/pytest.ini
coverage report --rcfile=./.coveragerc coverage report
coverage html --rcfile=./.coveragerc coverage html
check: check:
flake8 src/dependency_injector/ flake8 src/dependency_injector/
@ -61,9 +49,9 @@ check:
mypy tests/typing mypy tests/typing
test-publish: cythonize test-publish: build
# Create distributions # Create distributions
python setup.py sdist python -m build --sdist
# Upload distributions to PyPI # Upload distributions to PyPI
twine upload --repository testpypi dist/dependency-injector-$(VERSION)* twine upload --repository testpypi dist/dependency-injector-$(VERSION)*

101
pyproject.toml Normal file
View File

@ -0,0 +1,101 @@
[build-system]
requires = ["setuptools", "Cython"]
build-backend = "setuptools.build_meta"
[project]
name = "dependency-injector"
authors = [
{name = "Roman Mogylatov", email = "rmogilatov@gmail.com"},
]
maintainers = [
{name = "Roman Mogylatov", email = "rmogilatov@gmail.com"},
]
description = "Dependency injection framework for Python"
readme = {file = "README.rst", content-type = "text/x-rst"}
license = {file = "LICENSE.rst", content-type = "text/x-rst"}
requires-python = ">=3.7"
keywords = [
"Dependency injection",
"DI",
"Inversion of Control",
"IoC",
"Factory",
"Singleton",
"Design patterns",
"Flask",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Framework :: AsyncIO",
"Framework :: Bottle",
"Framework :: Django",
"Framework :: Flask",
"Framework :: Pylons",
"Framework :: Pyramid",
"Framework :: Pytest",
"Framework :: TurboGears",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dynamic = ["version"]
dependencies = ["six"]
[project.optional-dependencies]
yaml = ["pyyaml"]
pydantic = ["pydantic"]
flask = ["flask"]
aiohttp = ["aiohttp"]
[project.urls]
Homepage = "https://github.com/ets-labs/python-dependency-injector"
Documentation = "https://python-dependency-injector.ets-labs.org/"
Download = "https://pypi.python.org/pypi/dependency_injector"
[tool.setuptools]
package-dir = {"" = "src"}
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
dependency_injector = ["*.pxd", "*.pyi", "py.typed"]
[tool.setuptools.dynamic]
version = {attr = "dependency_injector.__version__"}
[tool.coverage.run]
branch = false
relative_files = true
source_pkgs = ["dependency_injector"]
plugins = ["Cython.Coverage"]
[tool.coverage.html]
directory = "reports/unittests/"
[tool.coverage.report]
show_missing = true
[tool.isort]
profile = "black"
[tool.pylint.main]
ignore = ["tests"]
[tool.pylint.design]
min-public-methods = 0
max-public-methods = 30

View File

@ -5,6 +5,7 @@ pytest-asyncio
tox tox
coverage coverage
flake8 flake8
flake8-pyproject
pydocstyle pydocstyle
sphinx_autobuild sphinx_autobuild
pip pip

152
setup.py
View File

@ -1,128 +1,42 @@
"""`Dependency injector` setup script.""" """`Dependency injector` setup script."""
import os import os
import re
import sys
from setuptools import setup, Extension from Cython.Build import cythonize
from Cython.Compiler import Options
from setuptools import Extension, setup
debug = os.environ.get("DEPENDENCY_INJECTOR_DEBUG_MODE") == "1"
def _open(filename): defined_macros = []
if sys.version_info[0] == 2: compiler_directives = {
return open(filename) "language_level": 3,
return open(filename, encoding="utf-8") "profile": debug,
"linetrace": debug,
}
# Defining setup variables: Options.annotate = debug
defined_macros = dict()
defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 0
# Getting description:
with _open("README.rst") as readme_file:
description = readme_file.read()
# Getting requirements:
with _open("requirements.txt") as requirements_file:
requirements = requirements_file.readlines()
# Getting version:
with _open("src/dependency_injector/__init__.py") as init_file:
version = re.search("__version__ = \"(.*?)\"", init_file.read()).group(1)
# Adding debug options: # Adding debug options:
if os.environ.get("DEPENDENCY_INJECTOR_DEBUG_MODE") == "1": if debug:
defined_macros["CYTHON_TRACE"] = 1 defined_macros.extend(
defined_macros["CYTHON_TRACE_NOGIL"] = 1 [
defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 1 ("CYTHON_TRACE", "1"),
("CYTHON_TRACE_NOGIL", "1"),
("CYTHON_CLINE_IN_TRACEBACK", "1"),
]
)
setup(name="dependency-injector", setup(
version=version, ext_modules=cythonize(
description="Dependency injection framework for Python", [
long_description=description, Extension(
author="Roman Mogylatov", "*",
author_email="rmogilatov@gmail.com", ["src/**/*.pyx"],
maintainer="Roman Mogylatov", define_macros=defined_macros,
maintainer_email="rmogilatov@gmail.com", ),
url="https://github.com/ets-labs/python-dependency-injector", ],
download_url="https://pypi.python.org/pypi/dependency_injector", annotate=debug,
packages=[ show_all_warnings=True,
"dependency_injector", compiler_directives=compiler_directives,
"dependency_injector.ext", ),
], )
package_dir={
"": "src",
},
package_data={
"dependency_injector": ["*.pxd", "*.pyi", "py.typed"],
},
ext_modules=[
Extension("dependency_injector.containers",
["src/dependency_injector/containers.c"],
define_macros=list(defined_macros.items()),
extra_compile_args=["-O2"]),
Extension("dependency_injector.providers",
["src/dependency_injector/providers.c"],
define_macros=list(defined_macros.items()),
extra_compile_args=["-O2"]),
Extension("dependency_injector._cwiring",
["src/dependency_injector/_cwiring.c"],
define_macros=list(defined_macros.items()),
extra_compile_args=["-O2"]),
],
install_requires=requirements,
extras_require={
"yaml": [
"pyyaml",
],
"pydantic": [
"pydantic",
],
"flask": [
"flask",
],
"aiohttp": [
"aiohttp",
],
},
zip_safe=True,
license="BSD New",
platforms=["any"],
keywords=[
"Dependency injection",
"DI",
"Inversion of Control",
"IoC",
"Factory",
"Singleton",
"Design patterns",
"Flask",
],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Framework :: AsyncIO",
"Framework :: Bottle",
"Framework :: Django",
"Framework :: Flask",
"Framework :: Pylons",
"Framework :: Pyramid",
"Framework :: Pytest",
"Framework :: TurboGears",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

11
tox.ini
View File

@ -23,6 +23,11 @@ extras=
yaml yaml
commands = pytest -c tests/.configs/pytest.ini commands = pytest -c tests/.configs/pytest.ini
python_files = test_*_py3*.py python_files = test_*_py3*.py
setenv =
COVERAGE_RCFILE = pyproject.toml
[testenv:.pkg]
passenv = DEPENDENCY_INJECTOR_*
[testenv:coveralls] [testenv:coveralls]
passenv = GITHUB_*, COVERALLS_*, DEPENDENCY_INJECTOR_* passenv = GITHUB_*, COVERALLS_*, DEPENDENCY_INJECTOR_*
@ -34,8 +39,8 @@ deps=
coveralls>=4 coveralls>=4
commands= commands=
coverage erase coverage erase
coverage run --rcfile=./.coveragerc -m pytest -c tests/.configs/pytest.ini coverage run -m pytest -c tests/.configs/pytest.ini
coverage report --rcfile=./.coveragerc coverage report
coveralls coveralls
[testenv:pypy3.9] [testenv:pypy3.9]
@ -60,7 +65,7 @@ deps=
flask<2.2 flask<2.2
werkzeug<=2.2.2 werkzeug<=2.2.2
commands= commands=
- pylint -f colorized --rcfile=./.pylintrc src/dependency_injector - pylint -f colorized src/dependency_injector
[testenv:flake8] [testenv:flake8]
deps= deps=