mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-10 10:53:48 +03:00
Convert to PEP-517 project
This commit is contained in:
parent
abf2a2577c
commit
4f1f428eec
1
.github/workflows/tests-and-linters.yml
vendored
1
.github/workflows/tests-and-linters.yml
vendored
|
@ -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
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -1,14 +1,5 @@
|
||||||
VERSION := $(shell python setup.py --version)
|
VERSION := $(shell python setup.py --version)
|
||||||
|
|
||||||
CYTHON_SRC := $(shell find src/dependency_injector -name '*.pyx')
|
|
||||||
|
|
||||||
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 +16,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:
|
||||||
|
@ -61,9 +48,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)*
|
||||||
|
|
||||||
|
|
79
pyproject.toml
Normal file
79
pyproject.toml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
[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__"}
|
152
setup.py
152
setup.py
|
@ -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",
|
|
||||||
])
|
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -24,6 +24,9 @@ extras=
|
||||||
commands = pytest -c tests/.configs/pytest.ini
|
commands = pytest -c tests/.configs/pytest.ini
|
||||||
python_files = test_*_py3*.py
|
python_files = test_*_py3*.py
|
||||||
|
|
||||||
|
[testenv:.pkg]
|
||||||
|
passenv = DEPENDENCY_INJECTOR_*
|
||||||
|
|
||||||
[testenv:coveralls]
|
[testenv:coveralls]
|
||||||
passenv = GITHUB_*, COVERALLS_*, DEPENDENCY_INJECTOR_*
|
passenv = GITHUB_*, COVERALLS_*, DEPENDENCY_INJECTOR_*
|
||||||
basepython=python3.12 # TODO: Upgrade to version 3.13 is blocked by coveralls 4.0.1 not supporting Python 3.13
|
basepython=python3.12 # TODO: Upgrade to version 3.13 is blocked by coveralls 4.0.1 not supporting Python 3.13
|
||||||
|
|
Loading…
Reference in New Issue
Block a user