summaryrefslogtreecommitdiff
path: root/python-preprocessor.spec
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-18 07:44:30 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-18 07:44:30 +0000
commit87a3c41d0f4e956690e3bed156e5fdbf8b62f795 (patch)
treeaa49d2d8b7595e2a5bca1dcd636d143a88c1de86 /python-preprocessor.spec
parent56115348d03c7e5f1adc78d7704424fccf3555d8 (diff)
automatic import of python-preprocessor
Diffstat (limited to 'python-preprocessor.spec')
-rw-r--r--python-preprocessor.spec258
1 files changed, 258 insertions, 0 deletions
diff --git a/python-preprocessor.spec b/python-preprocessor.spec
new file mode 100644
index 0000000..4338621
--- /dev/null
+++ b/python-preprocessor.spec
@@ -0,0 +1,258 @@
+%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((<CMat[int]>(self.matinternal)).sum())
+ elif self.dtype == np.float32:
+ print('siema')
+ return WrapMat((<CMat[float]>(self.matinternal)).sum())
+ elif self.dtype == np.float64:
+ print('siema')
+ return WrapMat((<CMat[double]>(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((<CMat[int]>(self.matinternal)).sum())
+ elif self.dtype == np.float32:
+ print('siema')
+ return WrapMat((<CMat[float]>(self.matinternal)).sum())
+ elif self.dtype == np.float64:
+ print('siema')
+ return WrapMat((<CMat[double]>(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((<CMat[int]>(self.matinternal)).sum())
+ elif self.dtype == np.float32:
+ print('siema')
+ return WrapMat((<CMat[float]>(self.matinternal)).sum())
+ elif self.dtype == np.float64:
+ print('siema')
+ return WrapMat((<CMat[double]>(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
+* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.3-1
+- Package Spec generated