|
1 | 1 | """`Dependency injector` setup script."""
|
2 | 2 |
|
3 | 3 | import os
|
4 |
| -import re |
5 |
| -import sys |
6 | 4 |
|
7 |
| -from setuptools import setup, Extension |
| 5 | +from Cython.Build import cythonize |
| 6 | +from Cython.Compiler import Options |
| 7 | +from setuptools import Extension, setup |
8 | 8 |
|
9 |
| - |
10 |
| -def _open(filename): |
11 |
| - if sys.version_info[0] == 2: |
12 |
| - return open(filename) |
13 |
| - return open(filename, encoding="utf-8") |
14 |
| - |
15 |
| - |
16 |
| -# Defining setup variables: |
17 |
| -defined_macros = dict() |
18 |
| -defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 0 |
19 |
| - |
20 |
| -# Getting description: |
21 |
| -with _open("README.rst") as readme_file: |
22 |
| - description = readme_file.read() |
23 |
| - |
24 |
| -# Getting requirements: |
25 |
| -with _open("requirements.txt") as requirements_file: |
26 |
| - requirements = requirements_file.readlines() |
27 |
| - |
28 |
| -# Getting version: |
29 |
| -with _open("src/dependency_injector/__init__.py") as init_file: |
30 |
| - version = re.search("__version__ = \"(.*?)\"", init_file.read()).group(1) |
| 9 | +debug = os.environ.get("DEPENDENCY_INJECTOR_DEBUG_MODE") == "1" |
| 10 | +defined_macros = [] |
| 11 | +compiler_directives = { |
| 12 | + "language_level": 3, |
| 13 | + "profile": debug, |
| 14 | + "linetrace": debug, |
| 15 | +} |
| 16 | +Options.annotate = debug |
31 | 17 |
|
32 | 18 | # Adding debug options:
|
33 |
| -if os.environ.get("DEPENDENCY_INJECTOR_DEBUG_MODE") == "1": |
34 |
| - defined_macros["CYTHON_TRACE"] = 1 |
35 |
| - defined_macros["CYTHON_TRACE_NOGIL"] = 1 |
36 |
| - defined_macros["CYTHON_CLINE_IN_TRACEBACK"] = 1 |
37 |
| - |
38 |
| - |
39 |
| -setup(name="dependency-injector", |
40 |
| - version=version, |
41 |
| - description="Dependency injection framework for Python", |
42 |
| - long_description=description, |
43 |
| - author="Roman Mogylatov", |
44 |
| - author_email="rmogilatov@gmail.com", |
45 |
| - maintainer="Roman Mogylatov", |
46 |
| - maintainer_email="rmogilatov@gmail.com", |
47 |
| - url="https://github.com/ets-labs/python-dependency-injector", |
48 |
| - download_url="https://pypi.python.org/pypi/dependency_injector", |
49 |
| - packages=[ |
50 |
| - "dependency_injector", |
51 |
| - "dependency_injector.ext", |
52 |
| - ], |
53 |
| - package_dir={ |
54 |
| - "": "src", |
55 |
| - }, |
56 |
| - package_data={ |
57 |
| - "dependency_injector": ["*.pxd", "*.pyi", "py.typed"], |
58 |
| - }, |
59 |
| - ext_modules=[ |
60 |
| - Extension("dependency_injector.containers", |
61 |
| - ["src/dependency_injector/containers.c"], |
62 |
| - define_macros=list(defined_macros.items()), |
63 |
| - extra_compile_args=["-O2"]), |
64 |
| - Extension("dependency_injector.providers", |
65 |
| - ["src/dependency_injector/providers.c"], |
66 |
| - define_macros=list(defined_macros.items()), |
67 |
| - extra_compile_args=["-O2"]), |
68 |
| - Extension("dependency_injector._cwiring", |
69 |
| - ["src/dependency_injector/_cwiring.c"], |
70 |
| - define_macros=list(defined_macros.items()), |
71 |
| - extra_compile_args=["-O2"]), |
72 |
| - ], |
73 |
| - install_requires=requirements, |
74 |
| - extras_require={ |
75 |
| - "yaml": [ |
76 |
| - "pyyaml", |
77 |
| - ], |
78 |
| - "pydantic": [ |
79 |
| - "pydantic", |
80 |
| - ], |
81 |
| - "flask": [ |
82 |
| - "flask", |
83 |
| - ], |
84 |
| - "aiohttp": [ |
85 |
| - "aiohttp", |
86 |
| - ], |
87 |
| - }, |
88 |
| - zip_safe=True, |
89 |
| - license="BSD New", |
90 |
| - platforms=["any"], |
91 |
| - keywords=[ |
92 |
| - "Dependency injection", |
93 |
| - "DI", |
94 |
| - "Inversion of Control", |
95 |
| - "IoC", |
96 |
| - "Factory", |
97 |
| - "Singleton", |
98 |
| - "Design patterns", |
99 |
| - "Flask", |
100 |
| - ], |
101 |
| - classifiers=[ |
102 |
| - "Development Status :: 5 - Production/Stable", |
103 |
| - "Intended Audience :: Developers", |
104 |
| - "License :: OSI Approved :: BSD License", |
105 |
| - "Operating System :: OS Independent", |
106 |
| - "Programming Language :: Python", |
107 |
| - "Programming Language :: Python :: 3", |
108 |
| - "Programming Language :: Python :: 3.7", |
109 |
| - "Programming Language :: Python :: 3.8", |
110 |
| - "Programming Language :: Python :: 3.9", |
111 |
| - "Programming Language :: Python :: 3.10", |
112 |
| - "Programming Language :: Python :: 3.11", |
113 |
| - "Programming Language :: Python :: 3.12", |
114 |
| - "Programming Language :: Python :: 3.13", |
115 |
| - "Programming Language :: Python :: Implementation :: CPython", |
116 |
| - "Programming Language :: Python :: Implementation :: PyPy", |
117 |
| - "Framework :: AsyncIO", |
118 |
| - "Framework :: Bottle", |
119 |
| - "Framework :: Django", |
120 |
| - "Framework :: Flask", |
121 |
| - "Framework :: Pylons", |
122 |
| - "Framework :: Pyramid", |
123 |
| - "Framework :: Pytest", |
124 |
| - "Framework :: TurboGears", |
125 |
| - "Topic :: Software Development", |
126 |
| - "Topic :: Software Development :: Libraries", |
127 |
| - "Topic :: Software Development :: Libraries :: Python Modules", |
128 |
| - ]) |
| 19 | +if debug: |
| 20 | + defined_macros.extend( |
| 21 | + [ |
| 22 | + ("CYTHON_TRACE", "1"), |
| 23 | + ("CYTHON_TRACE_NOGIL", "1"), |
| 24 | + ("CYTHON_CLINE_IN_TRACEBACK", "1"), |
| 25 | + ] |
| 26 | + ) |
| 27 | + |
| 28 | + |
| 29 | +setup( |
| 30 | + ext_modules=cythonize( |
| 31 | + [ |
| 32 | + Extension( |
| 33 | + "*", |
| 34 | + ["src/**/*.pyx"], |
| 35 | + define_macros=defined_macros, |
| 36 | + ), |
| 37 | + ], |
| 38 | + annotate=debug, |
| 39 | + show_all_warnings=True, |
| 40 | + compiler_directives=compiler_directives, |
| 41 | + ), |
| 42 | +) |
0 commit comments