%global _empty_manifest_terminate_build 0 Name: python-requires Version: 0.10.5 Release: 1 Summary: Runtime imports and dependency utils License: MIT URL: https://github.com/dynamic-graphics-inc/dgpy-libs/tree/main/libs/requires Source0: https://mirrors.nju.edu.cn/pypi/web/packages/25/a0/38f21ca428e081a6564605f581cb51b7dd3e657047cc6273b6874635757c/requires-0.10.5.tar.gz BuildArch: noarch Requires: python3-funkify Requires: python3-xtyping %description ## Usage: ```python # This will fail def uno(): return json.dumps({"a": 1, "b": 2}) try: uno() except NameError as ne: print("Error:", ne) ``` Error: name 'json' is not defined ```python # This will not fail import requires # Module is callable! (checkout funkify for more info -- `pip install funkify`) @requires("json") def uno(): return json.dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python import requires @requires("from json import dumps") def uno(): return dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_from="json", _import="dumps") def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_import="rapidjson", pip="python-rapidjson", conda_forge="python-rapidjson") def tres(): return rapidjson.dumps({"a": 1, "b": 2}) tres() # Will err if not install with where to install instructions ``` '{"a":1,"b":2}' ```python # should error def quatro(): return path.join("a", "b") try: quatro() except NameError as ne: print("ERROR:", ne) ``` ERROR: name 'path' is not defined ```python from requires import Requirement os_path_req = Requirement(_import="path", _from="os") @os_path_req def quatro(): return path.join("a", "b") assert isinstance(quatro(), str) ``` ## Enforcing requirements ```python import requires try: import alibrary except ModuleNotFoundError: requirement = requires.Requirement( _import="alibrary", pip=True, conda_forge="alibrary-conda-listing", details="Install details", ) try: requirement.raise_error() except requires.RequirementError as err: print("ERROR:") print(err) ``` ERROR: Module/Package(s) not found/installed; could not import: `import alibrary` pip install alibrary conda install -c conda-forge alibrary-conda-listing Install details ## Less verbose version: ```python import requires try: import alibrary except ModuleNotFoundError: requires.Requirement( _import='alibrary', pip=True, conda_forge='alibrary-conda-listing', details="Install details" ).raise_error() %package -n python3-requires Summary: Runtime imports and dependency utils Provides: python-requires BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-requires ## Usage: ```python # This will fail def uno(): return json.dumps({"a": 1, "b": 2}) try: uno() except NameError as ne: print("Error:", ne) ``` Error: name 'json' is not defined ```python # This will not fail import requires # Module is callable! (checkout funkify for more info -- `pip install funkify`) @requires("json") def uno(): return json.dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python import requires @requires("from json import dumps") def uno(): return dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_from="json", _import="dumps") def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_import="rapidjson", pip="python-rapidjson", conda_forge="python-rapidjson") def tres(): return rapidjson.dumps({"a": 1, "b": 2}) tres() # Will err if not install with where to install instructions ``` '{"a":1,"b":2}' ```python # should error def quatro(): return path.join("a", "b") try: quatro() except NameError as ne: print("ERROR:", ne) ``` ERROR: name 'path' is not defined ```python from requires import Requirement os_path_req = Requirement(_import="path", _from="os") @os_path_req def quatro(): return path.join("a", "b") assert isinstance(quatro(), str) ``` ## Enforcing requirements ```python import requires try: import alibrary except ModuleNotFoundError: requirement = requires.Requirement( _import="alibrary", pip=True, conda_forge="alibrary-conda-listing", details="Install details", ) try: requirement.raise_error() except requires.RequirementError as err: print("ERROR:") print(err) ``` ERROR: Module/Package(s) not found/installed; could not import: `import alibrary` pip install alibrary conda install -c conda-forge alibrary-conda-listing Install details ## Less verbose version: ```python import requires try: import alibrary except ModuleNotFoundError: requires.Requirement( _import='alibrary', pip=True, conda_forge='alibrary-conda-listing', details="Install details" ).raise_error() %package help Summary: Development documents and examples for requires Provides: python3-requires-doc %description help ## Usage: ```python # This will fail def uno(): return json.dumps({"a": 1, "b": 2}) try: uno() except NameError as ne: print("Error:", ne) ``` Error: name 'json' is not defined ```python # This will not fail import requires # Module is callable! (checkout funkify for more info -- `pip install funkify`) @requires("json") def uno(): return json.dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python import requires @requires("from json import dumps") def uno(): return dumps({"a": 1, "b": 2}) uno() ``` '{"a": 1, "b": 2}' ```python def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_from="json", _import="dumps") def dos(): return dumps({"a": 1, "b": 2}) dos() ``` '{"a": 1, "b": 2}' ```python import requires @requires(_import="rapidjson", pip="python-rapidjson", conda_forge="python-rapidjson") def tres(): return rapidjson.dumps({"a": 1, "b": 2}) tres() # Will err if not install with where to install instructions ``` '{"a":1,"b":2}' ```python # should error def quatro(): return path.join("a", "b") try: quatro() except NameError as ne: print("ERROR:", ne) ``` ERROR: name 'path' is not defined ```python from requires import Requirement os_path_req = Requirement(_import="path", _from="os") @os_path_req def quatro(): return path.join("a", "b") assert isinstance(quatro(), str) ``` ## Enforcing requirements ```python import requires try: import alibrary except ModuleNotFoundError: requirement = requires.Requirement( _import="alibrary", pip=True, conda_forge="alibrary-conda-listing", details="Install details", ) try: requirement.raise_error() except requires.RequirementError as err: print("ERROR:") print(err) ``` ERROR: Module/Package(s) not found/installed; could not import: `import alibrary` pip install alibrary conda install -c conda-forge alibrary-conda-listing Install details ## Less verbose version: ```python import requires try: import alibrary except ModuleNotFoundError: requires.Requirement( _import='alibrary', pip=True, conda_forge='alibrary-conda-listing', details="Install details" ).raise_error() %prep %autosetup -n requires-0.10.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-requires -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue May 30 2023 Python_Bot - 0.10.5-1 - Package Spec generated