summaryrefslogtreecommitdiff
path: root/python-simple-di.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-simple-di.spec')
-rw-r--r--python-simple-di.spec310
1 files changed, 310 insertions, 0 deletions
diff --git a/python-simple-di.spec b/python-simple-di.spec
new file mode 100644
index 0000000..cf74ffa
--- /dev/null
+++ b/python-simple-di.spec
@@ -0,0 +1,310 @@
+%global _empty_manifest_terminate_build 0
+Name: python-simple-di
+Version: 0.1.5
+Release: 1
+Summary: simple dependency injection library
+License: Apache License 2.0
+URL: https://github.com/bentoml/simple_di
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2a/b8/f2e3d1d6eac545c897a9b8ae339f2f2437a0e0b00bf0df3767109bede14d/simple_di-0.1.5.tar.gz
+BuildArch: noarch
+
+Requires: python3-dataclasses
+Requires: python3-types-dataclasses
+Requires: python3-pytest
+Requires: python3-mypy
+
+%description
+# simple-di
+
+A simple, strictly typed dependency injection library.
+
+- [Install](#install)
+- [Usage](#usage)
+- [API](#api)
+
+[![mypy-strict](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml)
+
+[![Python 3.6](https://github.com/bentoml/simple_di/workflows/Python%203.6/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py36.yml)
+[![Python 3.7](https://github.com/bentoml/simple_di/workflows/Python%203.7/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py37.yml)
+[![Python 3.8](https://github.com/bentoml/simple_di/workflows/Python%203.8/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py38.yml)
+[![Python 3.9](https://github.com/bentoml/simple_di/workflows/Python%203.9/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py39.yml)
+
+## Install
+
+``` bash
+ pip install simple_di
+```
+
+## Usage
+
+Examples:
+
+```python
+ from simple_di import inject, Provide, Provider, container
+ from simple_di.providers import Static, Factory, Configuration
+
+
+ @container
+ class OptionsClass(container):
+ cpu: Provider[int] = Static(2)
+ worker: Provider[int] = Factory(lambda c: 2 * int(c) + 1, c=cpu)
+
+ Options = OptionsClass()
+
+ @inject
+ def func(worker: int = Provide[Options.worker]):
+ return worker
+
+ assert func() == 5
+ assert func(1) == 1
+
+ Options.worker.set(2)
+ assert func() == 2
+
+ Options.worker.reset()
+ assert func() == 5
+
+ Options.cpu.set(1)
+ assert func() == 3
+```
+
+
+## API
+
+- [container](#container)
+- [sync_container](#sync_container)
+- [inject](#inject)
+- [Provide](#Provide)
+- [providers](#providers)
+ - [Static](#Static)
+ - [Configuration](#Configuration)
+ - [Factory](#Factory)
+ - [SingletonFactory](#SingletonFactory)
+
+## Type annotation supported
+
+
+### inject
+
+Inject values into providers in function/method arguments.
+
+Arguments:
+ - squeeze_none: default False. Treat None value passed in as not passed.
+
+
+
+
+%package -n python3-simple-di
+Summary: simple dependency injection library
+Provides: python-simple-di
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-simple-di
+# simple-di
+
+A simple, strictly typed dependency injection library.
+
+- [Install](#install)
+- [Usage](#usage)
+- [API](#api)
+
+[![mypy-strict](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml)
+
+[![Python 3.6](https://github.com/bentoml/simple_di/workflows/Python%203.6/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py36.yml)
+[![Python 3.7](https://github.com/bentoml/simple_di/workflows/Python%203.7/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py37.yml)
+[![Python 3.8](https://github.com/bentoml/simple_di/workflows/Python%203.8/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py38.yml)
+[![Python 3.9](https://github.com/bentoml/simple_di/workflows/Python%203.9/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py39.yml)
+
+## Install
+
+``` bash
+ pip install simple_di
+```
+
+## Usage
+
+Examples:
+
+```python
+ from simple_di import inject, Provide, Provider, container
+ from simple_di.providers import Static, Factory, Configuration
+
+
+ @container
+ class OptionsClass(container):
+ cpu: Provider[int] = Static(2)
+ worker: Provider[int] = Factory(lambda c: 2 * int(c) + 1, c=cpu)
+
+ Options = OptionsClass()
+
+ @inject
+ def func(worker: int = Provide[Options.worker]):
+ return worker
+
+ assert func() == 5
+ assert func(1) == 1
+
+ Options.worker.set(2)
+ assert func() == 2
+
+ Options.worker.reset()
+ assert func() == 5
+
+ Options.cpu.set(1)
+ assert func() == 3
+```
+
+
+## API
+
+- [container](#container)
+- [sync_container](#sync_container)
+- [inject](#inject)
+- [Provide](#Provide)
+- [providers](#providers)
+ - [Static](#Static)
+ - [Configuration](#Configuration)
+ - [Factory](#Factory)
+ - [SingletonFactory](#SingletonFactory)
+
+## Type annotation supported
+
+
+### inject
+
+Inject values into providers in function/method arguments.
+
+Arguments:
+ - squeeze_none: default False. Treat None value passed in as not passed.
+
+
+
+
+%package help
+Summary: Development documents and examples for simple-di
+Provides: python3-simple-di-doc
+%description help
+# simple-di
+
+A simple, strictly typed dependency injection library.
+
+- [Install](#install)
+- [Usage](#usage)
+- [API](#api)
+
+[![mypy-strict](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/mypy.yml)
+
+[![Python 3.6](https://github.com/bentoml/simple_di/workflows/Python%203.6/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py36.yml)
+[![Python 3.7](https://github.com/bentoml/simple_di/workflows/Python%203.7/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py37.yml)
+[![Python 3.8](https://github.com/bentoml/simple_di/workflows/Python%203.8/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py38.yml)
+[![Python 3.9](https://github.com/bentoml/simple_di/workflows/Python%203.9/badge.svg)](https://github.com/bentoml/simple_di/actions/workflows/py39.yml)
+
+## Install
+
+``` bash
+ pip install simple_di
+```
+
+## Usage
+
+Examples:
+
+```python
+ from simple_di import inject, Provide, Provider, container
+ from simple_di.providers import Static, Factory, Configuration
+
+
+ @container
+ class OptionsClass(container):
+ cpu: Provider[int] = Static(2)
+ worker: Provider[int] = Factory(lambda c: 2 * int(c) + 1, c=cpu)
+
+ Options = OptionsClass()
+
+ @inject
+ def func(worker: int = Provide[Options.worker]):
+ return worker
+
+ assert func() == 5
+ assert func(1) == 1
+
+ Options.worker.set(2)
+ assert func() == 2
+
+ Options.worker.reset()
+ assert func() == 5
+
+ Options.cpu.set(1)
+ assert func() == 3
+```
+
+
+## API
+
+- [container](#container)
+- [sync_container](#sync_container)
+- [inject](#inject)
+- [Provide](#Provide)
+- [providers](#providers)
+ - [Static](#Static)
+ - [Configuration](#Configuration)
+ - [Factory](#Factory)
+ - [SingletonFactory](#SingletonFactory)
+
+## Type annotation supported
+
+
+### inject
+
+Inject values into providers in function/method arguments.
+
+Arguments:
+ - squeeze_none: default False. Treat None value passed in as not passed.
+
+
+
+
+%prep
+%autosetup -n simple-di-0.1.5
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-simple-di -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.5-1
+- Package Spec generated