%global _empty_manifest_terminate_build 0 Name: python-preprocessor Version: 1.1.3 Release: 1 Summary: Preprocessor for files. License: MIT URL: https://github.com/nivwusquorum/preprocessor Source0: https://mirrors.nju.edu.cn/pypi/web/packages/96/ad/d9f4ffb9bb97d1cb5bcb876b7932571d4dbaa3eff1701ad45d367f0ea27b/preprocessor-1.1.3.tar.gz BuildArch: noarch %description ### Preprocessor Suited for simple preprocessing of Python files. The original use case of the package was annoying Cython work to do with data types. Notice that Preprocessor can run on any type of file (e.g. TSV, C++ sources etc.). To avoid clashes with other programming language preprocessor prefix and suffix is fully tunable. #### Example Here's a small file where we replicate the same Cython code 3 times - once for every of int, float and double datatypes. You can find the code for `typed_expression` function in `sample_utils.py` in this repo. ```Python pyp from sample_utils import typed_expression ypy cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function pypinline typed_expression(pyp, "self.matinternal", "CMat", print('siema') return WrapMat(TYPED_EXPRESSION.sum()) ypy ``` The output of the preprocessed file looks like this: ```Python cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function if self.dtype == np.int32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float64: print('siema') return WrapMat(((self.matinternal)).sum()) else: raise ValueError("Invalid dtype:" + self.dtype + " (should be one of int32, float32, float64)") ``` #### Command Line Interface Preprocessor comes with a command line script, to easily run the preprocessor form environments outside of Python ```bash preprocessor --input sample.py.pre --output sample.py ``` %package -n python3-preprocessor Summary: Preprocessor for files. Provides: python-preprocessor BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-preprocessor ### Preprocessor Suited for simple preprocessing of Python files. The original use case of the package was annoying Cython work to do with data types. Notice that Preprocessor can run on any type of file (e.g. TSV, C++ sources etc.). To avoid clashes with other programming language preprocessor prefix and suffix is fully tunable. #### Example Here's a small file where we replicate the same Cython code 3 times - once for every of int, float and double datatypes. You can find the code for `typed_expression` function in `sample_utils.py` in this repo. ```Python pyp from sample_utils import typed_expression ypy cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function pypinline typed_expression(pyp, "self.matinternal", "CMat", print('siema') return WrapMat(TYPED_EXPRESSION.sum()) ypy ``` The output of the preprocessed file looks like this: ```Python cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function if self.dtype == np.int32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float64: print('siema') return WrapMat(((self.matinternal)).sum()) else: raise ValueError("Invalid dtype:" + self.dtype + " (should be one of int32, float32, float64)") ``` #### Command Line Interface Preprocessor comes with a command line script, to easily run the preprocessor form environments outside of Python ```bash preprocessor --input sample.py.pre --output sample.py ``` %package help Summary: Development documents and examples for preprocessor Provides: python3-preprocessor-doc %description help ### Preprocessor Suited for simple preprocessing of Python files. The original use case of the package was annoying Cython work to do with data types. Notice that Preprocessor can run on any type of file (e.g. TSV, C++ sources etc.). To avoid clashes with other programming language preprocessor prefix and suffix is fully tunable. #### Example Here's a small file where we replicate the same Cython code 3 times - once for every of int, float and double datatypes. You can find the code for `typed_expression` function in `sample_utils.py` in this repo. ```Python pyp from sample_utils import typed_expression ypy cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function pypinline typed_expression(pyp, "self.matinternal", "CMat", print('siema') return WrapMat(TYPED_EXPRESSION.sum()) ypy ``` The output of the preprocessed file looks like this: ```Python cdef class Mat: cdef CMat[dtype] matinternal int dtype def sum(Mat self): # Inline preprcoessor expression. Executes a function. # Generally inline expressions should be one line, # But can be extended to multiple where all the data # on second line and following will be captured into # a string argument passed as last positional argument # to a function if self.dtype == np.int32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float32: print('siema') return WrapMat(((self.matinternal)).sum()) elif self.dtype == np.float64: print('siema') return WrapMat(((self.matinternal)).sum()) else: raise ValueError("Invalid dtype:" + self.dtype + " (should be one of int32, float32, float64)") ``` #### Command Line Interface Preprocessor comes with a command line script, to easily run the preprocessor form environments outside of Python ```bash preprocessor --input sample.py.pre --output sample.py ``` %prep %autosetup -n preprocessor-1.1.3 %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-preprocessor -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue May 30 2023 Python_Bot - 1.1.3-1 - Package Spec generated