PyQUDA 0.9.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. pyquda-0.9.1/LICENSE +21 -0
  2. pyquda-0.9.1/MANIFEST.in +13 -0
  3. pyquda-0.9.1/PKG-INFO +116 -0
  4. pyquda-0.9.1/PyQUDA.egg-info/PKG-INFO +116 -0
  5. pyquda-0.9.1/PyQUDA.egg-info/SOURCES.txt +186 -0
  6. pyquda-0.9.1/PyQUDA.egg-info/dependency_links.txt +1 -0
  7. pyquda-0.9.1/PyQUDA.egg-info/entry_points.txt +2 -0
  8. pyquda-0.9.1/PyQUDA.egg-info/requires.txt +2 -0
  9. pyquda-0.9.1/PyQUDA.egg-info/top_level.txt +1 -0
  10. pyquda-0.9.1/README.md +69 -0
  11. pyquda-0.9.1/pycparser/LICENSE +27 -0
  12. pyquda-0.9.1/pycparser/pycparser/__init__.py +93 -0
  13. pyquda-0.9.1/pycparser/pycparser/_ast_gen.py +336 -0
  14. pyquda-0.9.1/pycparser/pycparser/_build_tables.py +40 -0
  15. pyquda-0.9.1/pycparser/pycparser/_c_ast.cfg +195 -0
  16. pyquda-0.9.1/pycparser/pycparser/ast_transforms.py +164 -0
  17. pyquda-0.9.1/pycparser/pycparser/c_ast.py +1125 -0
  18. pyquda-0.9.1/pycparser/pycparser/c_generator.py +502 -0
  19. pyquda-0.9.1/pycparser/pycparser/c_lexer.py +555 -0
  20. pyquda-0.9.1/pycparser/pycparser/c_parser.py +1950 -0
  21. pyquda-0.9.1/pycparser/pycparser/ply/LICENSE +34 -0
  22. pyquda-0.9.1/pycparser/pycparser/ply/__init__.py +5 -0
  23. pyquda-0.9.1/pycparser/pycparser/ply/cpp.py +905 -0
  24. pyquda-0.9.1/pycparser/pycparser/ply/ctokens.py +133 -0
  25. pyquda-0.9.1/pycparser/pycparser/ply/lex.py +1099 -0
  26. pyquda-0.9.1/pycparser/pycparser/ply/yacc.py +3494 -0
  27. pyquda-0.9.1/pycparser/pycparser/ply/ygen.py +74 -0
  28. pyquda-0.9.1/pycparser/pycparser/plyparser.py +133 -0
  29. pyquda-0.9.1/pycparser/utils/fake_libc_include/X11/Intrinsic.h +4 -0
  30. pyquda-0.9.1/pycparser/utils/fake_libc_include/X11/Xlib.h +4 -0
  31. pyquda-0.9.1/pycparser/utils/fake_libc_include/X11/_X11_fake_defines.h +16 -0
  32. pyquda-0.9.1/pycparser/utils/fake_libc_include/X11/_X11_fake_typedefs.h +38 -0
  33. pyquda-0.9.1/pycparser/utils/fake_libc_include/_ansi.h +2 -0
  34. pyquda-0.9.1/pycparser/utils/fake_libc_include/_fake_defines.h +262 -0
  35. pyquda-0.9.1/pycparser/utils/fake_libc_include/_fake_typedefs.h +222 -0
  36. pyquda-0.9.1/pycparser/utils/fake_libc_include/_syslist.h +2 -0
  37. pyquda-0.9.1/pycparser/utils/fake_libc_include/aio.h +2 -0
  38. pyquda-0.9.1/pycparser/utils/fake_libc_include/alloca.h +2 -0
  39. pyquda-0.9.1/pycparser/utils/fake_libc_include/ar.h +2 -0
  40. pyquda-0.9.1/pycparser/utils/fake_libc_include/argz.h +2 -0
  41. pyquda-0.9.1/pycparser/utils/fake_libc_include/arpa/inet.h +2 -0
  42. pyquda-0.9.1/pycparser/utils/fake_libc_include/asm-generic/int-ll64.h +2 -0
  43. pyquda-0.9.1/pycparser/utils/fake_libc_include/assert.h +2 -0
  44. pyquda-0.9.1/pycparser/utils/fake_libc_include/complex.h +2 -0
  45. pyquda-0.9.1/pycparser/utils/fake_libc_include/cpio.h +2 -0
  46. pyquda-0.9.1/pycparser/utils/fake_libc_include/ctype.h +2 -0
  47. pyquda-0.9.1/pycparser/utils/fake_libc_include/dirent.h +2 -0
  48. pyquda-0.9.1/pycparser/utils/fake_libc_include/dlfcn.h +2 -0
  49. pyquda-0.9.1/pycparser/utils/fake_libc_include/emmintrin.h +2 -0
  50. pyquda-0.9.1/pycparser/utils/fake_libc_include/endian.h +2 -0
  51. pyquda-0.9.1/pycparser/utils/fake_libc_include/envz.h +2 -0
  52. pyquda-0.9.1/pycparser/utils/fake_libc_include/errno.h +2 -0
  53. pyquda-0.9.1/pycparser/utils/fake_libc_include/fastmath.h +2 -0
  54. pyquda-0.9.1/pycparser/utils/fake_libc_include/fcntl.h +2 -0
  55. pyquda-0.9.1/pycparser/utils/fake_libc_include/features.h +2 -0
  56. pyquda-0.9.1/pycparser/utils/fake_libc_include/fenv.h +2 -0
  57. pyquda-0.9.1/pycparser/utils/fake_libc_include/float.h +2 -0
  58. pyquda-0.9.1/pycparser/utils/fake_libc_include/fmtmsg.h +2 -0
  59. pyquda-0.9.1/pycparser/utils/fake_libc_include/fnmatch.h +2 -0
  60. pyquda-0.9.1/pycparser/utils/fake_libc_include/ftw.h +2 -0
  61. pyquda-0.9.1/pycparser/utils/fake_libc_include/getopt.h +2 -0
  62. pyquda-0.9.1/pycparser/utils/fake_libc_include/glob.h +2 -0
  63. pyquda-0.9.1/pycparser/utils/fake_libc_include/grp.h +2 -0
  64. pyquda-0.9.1/pycparser/utils/fake_libc_include/iconv.h +2 -0
  65. pyquda-0.9.1/pycparser/utils/fake_libc_include/ieeefp.h +2 -0
  66. pyquda-0.9.1/pycparser/utils/fake_libc_include/immintrin.h +2 -0
  67. pyquda-0.9.1/pycparser/utils/fake_libc_include/inttypes.h +2 -0
  68. pyquda-0.9.1/pycparser/utils/fake_libc_include/iso646.h +2 -0
  69. pyquda-0.9.1/pycparser/utils/fake_libc_include/langinfo.h +2 -0
  70. pyquda-0.9.1/pycparser/utils/fake_libc_include/libgen.h +2 -0
  71. pyquda-0.9.1/pycparser/utils/fake_libc_include/libintl.h +2 -0
  72. pyquda-0.9.1/pycparser/utils/fake_libc_include/limits.h +2 -0
  73. pyquda-0.9.1/pycparser/utils/fake_libc_include/linux/socket.h +2 -0
  74. pyquda-0.9.1/pycparser/utils/fake_libc_include/linux/version.h +2 -0
  75. pyquda-0.9.1/pycparser/utils/fake_libc_include/locale.h +2 -0
  76. pyquda-0.9.1/pycparser/utils/fake_libc_include/malloc.h +2 -0
  77. pyquda-0.9.1/pycparser/utils/fake_libc_include/math.h +2 -0
  78. pyquda-0.9.1/pycparser/utils/fake_libc_include/mir_toolkit/client_types.h +2 -0
  79. pyquda-0.9.1/pycparser/utils/fake_libc_include/monetary.h +2 -0
  80. pyquda-0.9.1/pycparser/utils/fake_libc_include/mqueue.h +2 -0
  81. pyquda-0.9.1/pycparser/utils/fake_libc_include/ndbm.h +2 -0
  82. pyquda-0.9.1/pycparser/utils/fake_libc_include/net/if.h +2 -0
  83. pyquda-0.9.1/pycparser/utils/fake_libc_include/netdb.h +2 -0
  84. pyquda-0.9.1/pycparser/utils/fake_libc_include/netinet/in.h +2 -0
  85. pyquda-0.9.1/pycparser/utils/fake_libc_include/netinet/tcp.h +2 -0
  86. pyquda-0.9.1/pycparser/utils/fake_libc_include/newlib.h +2 -0
  87. pyquda-0.9.1/pycparser/utils/fake_libc_include/nl_types.h +2 -0
  88. pyquda-0.9.1/pycparser/utils/fake_libc_include/openssl/err.h +2 -0
  89. pyquda-0.9.1/pycparser/utils/fake_libc_include/openssl/evp.h +2 -0
  90. pyquda-0.9.1/pycparser/utils/fake_libc_include/openssl/hmac.h +2 -0
  91. pyquda-0.9.1/pycparser/utils/fake_libc_include/openssl/ssl.h +2 -0
  92. pyquda-0.9.1/pycparser/utils/fake_libc_include/openssl/x509v3.h +2 -0
  93. pyquda-0.9.1/pycparser/utils/fake_libc_include/paths.h +2 -0
  94. pyquda-0.9.1/pycparser/utils/fake_libc_include/poll.h +2 -0
  95. pyquda-0.9.1/pycparser/utils/fake_libc_include/process.h +2 -0
  96. pyquda-0.9.1/pycparser/utils/fake_libc_include/pthread.h +2 -0
  97. pyquda-0.9.1/pycparser/utils/fake_libc_include/pwd.h +2 -0
  98. pyquda-0.9.1/pycparser/utils/fake_libc_include/reent.h +2 -0
  99. pyquda-0.9.1/pycparser/utils/fake_libc_include/regdef.h +2 -0
  100. pyquda-0.9.1/pycparser/utils/fake_libc_include/regex.h +2 -0
  101. pyquda-0.9.1/pycparser/utils/fake_libc_include/sched.h +2 -0
  102. pyquda-0.9.1/pycparser/utils/fake_libc_include/search.h +2 -0
  103. pyquda-0.9.1/pycparser/utils/fake_libc_include/semaphore.h +2 -0
  104. pyquda-0.9.1/pycparser/utils/fake_libc_include/setjmp.h +2 -0
  105. pyquda-0.9.1/pycparser/utils/fake_libc_include/signal.h +2 -0
  106. pyquda-0.9.1/pycparser/utils/fake_libc_include/smmintrin.h +2 -0
  107. pyquda-0.9.1/pycparser/utils/fake_libc_include/spawn.h +2 -0
  108. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdalign.h +2 -0
  109. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdarg.h +2 -0
  110. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdatomic.h +2 -0
  111. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdbool.h +2 -0
  112. pyquda-0.9.1/pycparser/utils/fake_libc_include/stddef.h +2 -0
  113. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdint.h +2 -0
  114. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdio.h +2 -0
  115. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdlib.h +2 -0
  116. pyquda-0.9.1/pycparser/utils/fake_libc_include/stdnoreturn.h +2 -0
  117. pyquda-0.9.1/pycparser/utils/fake_libc_include/string.h +2 -0
  118. pyquda-0.9.1/pycparser/utils/fake_libc_include/strings.h +2 -0
  119. pyquda-0.9.1/pycparser/utils/fake_libc_include/stropts.h +2 -0
  120. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/ioctl.h +2 -0
  121. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/ipc.h +2 -0
  122. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/mman.h +2 -0
  123. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/msg.h +2 -0
  124. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/poll.h +2 -0
  125. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/resource.h +2 -0
  126. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/select.h +2 -0
  127. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/sem.h +2 -0
  128. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/shm.h +2 -0
  129. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/socket.h +2 -0
  130. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/stat.h +2 -0
  131. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/statvfs.h +2 -0
  132. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/sysctl.h +2 -0
  133. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/time.h +2 -0
  134. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/times.h +2 -0
  135. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/types.h +2 -0
  136. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/uio.h +2 -0
  137. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/un.h +2 -0
  138. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/utsname.h +2 -0
  139. pyquda-0.9.1/pycparser/utils/fake_libc_include/sys/wait.h +2 -0
  140. pyquda-0.9.1/pycparser/utils/fake_libc_include/syslog.h +2 -0
  141. pyquda-0.9.1/pycparser/utils/fake_libc_include/tar.h +2 -0
  142. pyquda-0.9.1/pycparser/utils/fake_libc_include/termios.h +2 -0
  143. pyquda-0.9.1/pycparser/utils/fake_libc_include/tgmath.h +2 -0
  144. pyquda-0.9.1/pycparser/utils/fake_libc_include/threads.h +2 -0
  145. pyquda-0.9.1/pycparser/utils/fake_libc_include/time.h +2 -0
  146. pyquda-0.9.1/pycparser/utils/fake_libc_include/trace.h +2 -0
  147. pyquda-0.9.1/pycparser/utils/fake_libc_include/ulimit.h +2 -0
  148. pyquda-0.9.1/pycparser/utils/fake_libc_include/unctrl.h +2 -0
  149. pyquda-0.9.1/pycparser/utils/fake_libc_include/unistd.h +2 -0
  150. pyquda-0.9.1/pycparser/utils/fake_libc_include/utime.h +2 -0
  151. pyquda-0.9.1/pycparser/utils/fake_libc_include/utmp.h +2 -0
  152. pyquda-0.9.1/pycparser/utils/fake_libc_include/utmpx.h +2 -0
  153. pyquda-0.9.1/pycparser/utils/fake_libc_include/wchar.h +2 -0
  154. pyquda-0.9.1/pycparser/utils/fake_libc_include/wctype.h +2 -0
  155. pyquda-0.9.1/pycparser/utils/fake_libc_include/wordexp.h +2 -0
  156. pyquda-0.9.1/pycparser/utils/fake_libc_include/xcb/xcb.h +2 -0
  157. pyquda-0.9.1/pycparser/utils/fake_libc_include/zlib.h +33 -0
  158. pyquda-0.9.1/pyproject.toml +51 -0
  159. pyquda-0.9.1/pyquda/__init__.py +465 -0
  160. pyquda-0.9.1/pyquda/__main__.py +67 -0
  161. pyquda-0.9.1/pyquda/_version.py +1 -0
  162. pyquda-0.9.1/pyquda/action/__init__.py +10 -0
  163. pyquda-0.9.1/pyquda/action/abstract.py +228 -0
  164. pyquda-0.9.1/pyquda/action/clover_wilson.py +107 -0
  165. pyquda-0.9.1/pyquda/action/gauge.py +124 -0
  166. pyquda-0.9.1/pyquda/action/hisq.py +233 -0
  167. pyquda-0.9.1/pyquda/dirac/__init__.py +15 -0
  168. pyquda-0.9.1/pyquda/dirac/abstract.py +261 -0
  169. pyquda-0.9.1/pyquda/dirac/clover_wilson.py +100 -0
  170. pyquda-0.9.1/pyquda/dirac/gauge.py +425 -0
  171. pyquda-0.9.1/pyquda/dirac/general.py +771 -0
  172. pyquda-0.9.1/pyquda/dirac/hisq.py +115 -0
  173. pyquda-0.9.1/pyquda/dirac/staggered.py +89 -0
  174. pyquda-0.9.1/pyquda/dirac/wilson.py +80 -0
  175. pyquda-0.9.1/pyquda/enum_quda.in.py +387 -0
  176. pyquda-0.9.1/pyquda/field.py +1078 -0
  177. pyquda-0.9.1/pyquda/hmc.py +421 -0
  178. pyquda-0.9.1/pyquda/pointer.pxd +17 -0
  179. pyquda-0.9.1/pyquda/pointer.pyi +16 -0
  180. pyquda-0.9.1/pyquda/pyquda.pyi +2132 -0
  181. pyquda-0.9.1/pyquda/src/malloc_pyquda.pyx +8 -0
  182. pyquda-0.9.1/pyquda/src/malloc_quda.pxd +3 -0
  183. pyquda-0.9.1/pyquda/src/pointer.pyx +145 -0
  184. pyquda-0.9.1/pyquda/src/pyquda.in.pyx +430 -0
  185. pyquda-0.9.1/pyquda/src/quda.in.pxd +978 -0
  186. pyquda-0.9.1/pyquda_pyx.py +344 -0
  187. pyquda-0.9.1/setup.cfg +4 -0
  188. pyquda-0.9.1/setup.py +57 -0
pyquda-0.9.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-2024 PyQUDA Developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # .gitignore
2
+ exclude pyquda/src/quda_constants.pxd
3
+ exclude pyquda/src/enum_quda.pxd
4
+ exclude pyquda/src/quda.pxd
5
+ exclude pyquda/src/pyquda.pyx
6
+ exclude pyquda/enum_quda.py
7
+ exclude pyquda/src/*.c
8
+ exclude pyquda/src/*.cpp
9
+
10
+ include pyquda_pyx.py
11
+ include pycparser/LICENSE
12
+ recursive-include pycparser/pycparser *.py *.cfg LICENSE
13
+ recursive-include pycparser/utils/fake_libc_include *.h
pyquda-0.9.1/PKG-INFO ADDED
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyQUDA
3
+ Version: 0.9.1
4
+ Summary: Python wrapper for QUDA written in Cython
5
+ Author-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
6
+ Maintainer-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2022-2024 PyQUDA Developers
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: Homepage, https://github.com/CLQCD/PyQUDA
30
+ Project-URL: Documentation, https://github.com/CLQCD/PyQUDA/wiki/Documentation
31
+ Project-URL: Repository, https://github.com/CLQCD/PyQUDA.git
32
+ Project-URL: Issues, https://github.com/CLQCD/PyQUDA/issues
33
+ Keywords: lattice-gauge-theory,lattice-field-theory,lattice-qcd,hep-lat
34
+ Classifier: Development Status :: 2 - Pre-Alpha
35
+ Classifier: Programming Language :: Python :: 3 :: Only
36
+ Classifier: Programming Language :: Cython
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: POSIX :: Linux
39
+ Classifier: Environment :: GPU
40
+ Classifier: Environment :: GPU :: NVIDIA CUDA
41
+ Classifier: Topic :: Scientific/Engineering :: Physics
42
+ Requires-Python: >=3.8
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: mpi4py
46
+ Requires-Dist: numpy
47
+
48
+ # PyQUDA
49
+
50
+ Python wrapper for [QUDA](https://github.com/lattice/quda) written in Cython.
51
+
52
+ This project aims to benefit from the optimized linear algebra library [CuPy](https://cupy.dev/) in Python based on CUDA. CuPy and QUDA will allow us to perform most lattice QCD research operations with high performance. [PyTorch](https://pytorch.org/) is an alternative option.
53
+
54
+ This project is based on the latest QUDA `develop` branch. PyQUDA should be compatible with any commit of QUDA after https://github.com/lattice/quda/pull/1489, but leave some features disabled.
55
+
56
+ ## Feature
57
+
58
+ - Multi-GPU supported
59
+ - with [MPI for Python](https://mpi4py.readthedocs.io/en/stable/) package
60
+ - File I/O
61
+ - Read gauge and propagator in Chroma format
62
+ - Read gauge and propagator in MILC format
63
+ - Read/write gauge and propagator in KYU format
64
+ - Read/write gauge and propagator in XQCD format
65
+ - Read/write gauge and propagator in NPY format (numpy)
66
+ - Quark propagator
67
+ - Isotropic/anisotropic Wilson fermion action with multigrid support
68
+ - Isotropic/anisotropic Clover fermion action with multigrid support
69
+ - Isotropic HISQ fermion action
70
+ - HMC
71
+ - Isotropic Wilson gauge action
72
+ - Isotropic Symanzik gauge action
73
+ - 1-flavor isotropic clover fermion action
74
+ - 2-flavor isotropic clover fermion action
75
+ - Gauge fixing
76
+ - Rotation field with over-relaxation method (waiting for QUDA merge)
77
+ - Gauge smearing
78
+ - 3D/4D APE smearing
79
+ - 3D/4D stout smearing
80
+ - 3D/4D HYP smearing
81
+ - Fermion smearing
82
+ - Gaussian smearing
83
+ - Gradient flow
84
+ - Wilson flow
85
+ - Symanzik flow
86
+
87
+ ## Installation
88
+
89
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Installation for detailed instructions to install PyQUDA from the source.
90
+
91
+ ## Benchmark
92
+
93
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Benchmark for detailed instructions to run the PyQUDA benchmark.
94
+
95
+ ## Documentation (draft)
96
+
97
+ https://github.com/CLQCD/PyQUDA/wiki/Documentation
98
+
99
+ ## Development
100
+
101
+ We recommend building PyQUDA using in-place mode instead of installing PyQUDA for development.
102
+
103
+ ```bash
104
+ git clone https://github.com/CLQCD/PyQUDA.git
105
+ cd PyQUDA
106
+ ln -s pyquda_core/pyquda pyquda
107
+ cd pyquda_core
108
+ export QUDA_PATH=/path/to/quda/build/usqcd
109
+ python3 setup.py build_ext --inplace
110
+ ```
111
+
112
+ Now you can modify Python files in the project and immediately get the new result by running scripts. Adding the root directory to `sys.path` is needed if you are running scripts from other directories.
113
+
114
+ ## Maintenance
115
+
116
+ Function definitions (mainly in `quda.in.pxd` and `pyquda.in.pyx`) and most docstrings (mainly in `pyquda.pyi` and `enum_quda.in.py`) should be manually updated as they cannot be autogenerated now. This also means PyQUDA should work well with future versions if the API remains unchanged.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyQUDA
3
+ Version: 0.9.1
4
+ Summary: Python wrapper for QUDA written in Cython
5
+ Author-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
6
+ Maintainer-email: SaltyChiang <SaltyChiang@users.noreply.github.com>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2022-2024 PyQUDA Developers
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+
29
+ Project-URL: Homepage, https://github.com/CLQCD/PyQUDA
30
+ Project-URL: Documentation, https://github.com/CLQCD/PyQUDA/wiki/Documentation
31
+ Project-URL: Repository, https://github.com/CLQCD/PyQUDA.git
32
+ Project-URL: Issues, https://github.com/CLQCD/PyQUDA/issues
33
+ Keywords: lattice-gauge-theory,lattice-field-theory,lattice-qcd,hep-lat
34
+ Classifier: Development Status :: 2 - Pre-Alpha
35
+ Classifier: Programming Language :: Python :: 3 :: Only
36
+ Classifier: Programming Language :: Cython
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: POSIX :: Linux
39
+ Classifier: Environment :: GPU
40
+ Classifier: Environment :: GPU :: NVIDIA CUDA
41
+ Classifier: Topic :: Scientific/Engineering :: Physics
42
+ Requires-Python: >=3.8
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Requires-Dist: mpi4py
46
+ Requires-Dist: numpy
47
+
48
+ # PyQUDA
49
+
50
+ Python wrapper for [QUDA](https://github.com/lattice/quda) written in Cython.
51
+
52
+ This project aims to benefit from the optimized linear algebra library [CuPy](https://cupy.dev/) in Python based on CUDA. CuPy and QUDA will allow us to perform most lattice QCD research operations with high performance. [PyTorch](https://pytorch.org/) is an alternative option.
53
+
54
+ This project is based on the latest QUDA `develop` branch. PyQUDA should be compatible with any commit of QUDA after https://github.com/lattice/quda/pull/1489, but leave some features disabled.
55
+
56
+ ## Feature
57
+
58
+ - Multi-GPU supported
59
+ - with [MPI for Python](https://mpi4py.readthedocs.io/en/stable/) package
60
+ - File I/O
61
+ - Read gauge and propagator in Chroma format
62
+ - Read gauge and propagator in MILC format
63
+ - Read/write gauge and propagator in KYU format
64
+ - Read/write gauge and propagator in XQCD format
65
+ - Read/write gauge and propagator in NPY format (numpy)
66
+ - Quark propagator
67
+ - Isotropic/anisotropic Wilson fermion action with multigrid support
68
+ - Isotropic/anisotropic Clover fermion action with multigrid support
69
+ - Isotropic HISQ fermion action
70
+ - HMC
71
+ - Isotropic Wilson gauge action
72
+ - Isotropic Symanzik gauge action
73
+ - 1-flavor isotropic clover fermion action
74
+ - 2-flavor isotropic clover fermion action
75
+ - Gauge fixing
76
+ - Rotation field with over-relaxation method (waiting for QUDA merge)
77
+ - Gauge smearing
78
+ - 3D/4D APE smearing
79
+ - 3D/4D stout smearing
80
+ - 3D/4D HYP smearing
81
+ - Fermion smearing
82
+ - Gaussian smearing
83
+ - Gradient flow
84
+ - Wilson flow
85
+ - Symanzik flow
86
+
87
+ ## Installation
88
+
89
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Installation for detailed instructions to install PyQUDA from the source.
90
+
91
+ ## Benchmark
92
+
93
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Benchmark for detailed instructions to run the PyQUDA benchmark.
94
+
95
+ ## Documentation (draft)
96
+
97
+ https://github.com/CLQCD/PyQUDA/wiki/Documentation
98
+
99
+ ## Development
100
+
101
+ We recommend building PyQUDA using in-place mode instead of installing PyQUDA for development.
102
+
103
+ ```bash
104
+ git clone https://github.com/CLQCD/PyQUDA.git
105
+ cd PyQUDA
106
+ ln -s pyquda_core/pyquda pyquda
107
+ cd pyquda_core
108
+ export QUDA_PATH=/path/to/quda/build/usqcd
109
+ python3 setup.py build_ext --inplace
110
+ ```
111
+
112
+ Now you can modify Python files in the project and immediately get the new result by running scripts. Adding the root directory to `sys.path` is needed if you are running scripts from other directories.
113
+
114
+ ## Maintenance
115
+
116
+ Function definitions (mainly in `quda.in.pxd` and `pyquda.in.pyx`) and most docstrings (mainly in `pyquda.pyi` and `enum_quda.in.py`) should be manually updated as they cannot be autogenerated now. This also means PyQUDA should work well with future versions if the API remains unchanged.
@@ -0,0 +1,186 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ pyquda_pyx.py
6
+ setup.py
7
+ PyQUDA.egg-info/PKG-INFO
8
+ PyQUDA.egg-info/SOURCES.txt
9
+ PyQUDA.egg-info/dependency_links.txt
10
+ PyQUDA.egg-info/entry_points.txt
11
+ PyQUDA.egg-info/requires.txt
12
+ PyQUDA.egg-info/top_level.txt
13
+ pycparser/LICENSE
14
+ pycparser/pycparser/__init__.py
15
+ pycparser/pycparser/_ast_gen.py
16
+ pycparser/pycparser/_build_tables.py
17
+ pycparser/pycparser/_c_ast.cfg
18
+ pycparser/pycparser/ast_transforms.py
19
+ pycparser/pycparser/c_ast.py
20
+ pycparser/pycparser/c_generator.py
21
+ pycparser/pycparser/c_lexer.py
22
+ pycparser/pycparser/c_parser.py
23
+ pycparser/pycparser/plyparser.py
24
+ pycparser/pycparser/ply/LICENSE
25
+ pycparser/pycparser/ply/__init__.py
26
+ pycparser/pycparser/ply/cpp.py
27
+ pycparser/pycparser/ply/ctokens.py
28
+ pycparser/pycparser/ply/lex.py
29
+ pycparser/pycparser/ply/yacc.py
30
+ pycparser/pycparser/ply/ygen.py
31
+ pycparser/utils/fake_libc_include/_ansi.h
32
+ pycparser/utils/fake_libc_include/_fake_defines.h
33
+ pycparser/utils/fake_libc_include/_fake_typedefs.h
34
+ pycparser/utils/fake_libc_include/_syslist.h
35
+ pycparser/utils/fake_libc_include/aio.h
36
+ pycparser/utils/fake_libc_include/alloca.h
37
+ pycparser/utils/fake_libc_include/ar.h
38
+ pycparser/utils/fake_libc_include/argz.h
39
+ pycparser/utils/fake_libc_include/assert.h
40
+ pycparser/utils/fake_libc_include/complex.h
41
+ pycparser/utils/fake_libc_include/cpio.h
42
+ pycparser/utils/fake_libc_include/ctype.h
43
+ pycparser/utils/fake_libc_include/dirent.h
44
+ pycparser/utils/fake_libc_include/dlfcn.h
45
+ pycparser/utils/fake_libc_include/emmintrin.h
46
+ pycparser/utils/fake_libc_include/endian.h
47
+ pycparser/utils/fake_libc_include/envz.h
48
+ pycparser/utils/fake_libc_include/errno.h
49
+ pycparser/utils/fake_libc_include/fastmath.h
50
+ pycparser/utils/fake_libc_include/fcntl.h
51
+ pycparser/utils/fake_libc_include/features.h
52
+ pycparser/utils/fake_libc_include/fenv.h
53
+ pycparser/utils/fake_libc_include/float.h
54
+ pycparser/utils/fake_libc_include/fmtmsg.h
55
+ pycparser/utils/fake_libc_include/fnmatch.h
56
+ pycparser/utils/fake_libc_include/ftw.h
57
+ pycparser/utils/fake_libc_include/getopt.h
58
+ pycparser/utils/fake_libc_include/glob.h
59
+ pycparser/utils/fake_libc_include/grp.h
60
+ pycparser/utils/fake_libc_include/iconv.h
61
+ pycparser/utils/fake_libc_include/ieeefp.h
62
+ pycparser/utils/fake_libc_include/immintrin.h
63
+ pycparser/utils/fake_libc_include/inttypes.h
64
+ pycparser/utils/fake_libc_include/iso646.h
65
+ pycparser/utils/fake_libc_include/langinfo.h
66
+ pycparser/utils/fake_libc_include/libgen.h
67
+ pycparser/utils/fake_libc_include/libintl.h
68
+ pycparser/utils/fake_libc_include/limits.h
69
+ pycparser/utils/fake_libc_include/locale.h
70
+ pycparser/utils/fake_libc_include/malloc.h
71
+ pycparser/utils/fake_libc_include/math.h
72
+ pycparser/utils/fake_libc_include/monetary.h
73
+ pycparser/utils/fake_libc_include/mqueue.h
74
+ pycparser/utils/fake_libc_include/ndbm.h
75
+ pycparser/utils/fake_libc_include/netdb.h
76
+ pycparser/utils/fake_libc_include/newlib.h
77
+ pycparser/utils/fake_libc_include/nl_types.h
78
+ pycparser/utils/fake_libc_include/paths.h
79
+ pycparser/utils/fake_libc_include/poll.h
80
+ pycparser/utils/fake_libc_include/process.h
81
+ pycparser/utils/fake_libc_include/pthread.h
82
+ pycparser/utils/fake_libc_include/pwd.h
83
+ pycparser/utils/fake_libc_include/reent.h
84
+ pycparser/utils/fake_libc_include/regdef.h
85
+ pycparser/utils/fake_libc_include/regex.h
86
+ pycparser/utils/fake_libc_include/sched.h
87
+ pycparser/utils/fake_libc_include/search.h
88
+ pycparser/utils/fake_libc_include/semaphore.h
89
+ pycparser/utils/fake_libc_include/setjmp.h
90
+ pycparser/utils/fake_libc_include/signal.h
91
+ pycparser/utils/fake_libc_include/smmintrin.h
92
+ pycparser/utils/fake_libc_include/spawn.h
93
+ pycparser/utils/fake_libc_include/stdalign.h
94
+ pycparser/utils/fake_libc_include/stdarg.h
95
+ pycparser/utils/fake_libc_include/stdatomic.h
96
+ pycparser/utils/fake_libc_include/stdbool.h
97
+ pycparser/utils/fake_libc_include/stddef.h
98
+ pycparser/utils/fake_libc_include/stdint.h
99
+ pycparser/utils/fake_libc_include/stdio.h
100
+ pycparser/utils/fake_libc_include/stdlib.h
101
+ pycparser/utils/fake_libc_include/stdnoreturn.h
102
+ pycparser/utils/fake_libc_include/string.h
103
+ pycparser/utils/fake_libc_include/strings.h
104
+ pycparser/utils/fake_libc_include/stropts.h
105
+ pycparser/utils/fake_libc_include/syslog.h
106
+ pycparser/utils/fake_libc_include/tar.h
107
+ pycparser/utils/fake_libc_include/termios.h
108
+ pycparser/utils/fake_libc_include/tgmath.h
109
+ pycparser/utils/fake_libc_include/threads.h
110
+ pycparser/utils/fake_libc_include/time.h
111
+ pycparser/utils/fake_libc_include/trace.h
112
+ pycparser/utils/fake_libc_include/ulimit.h
113
+ pycparser/utils/fake_libc_include/unctrl.h
114
+ pycparser/utils/fake_libc_include/unistd.h
115
+ pycparser/utils/fake_libc_include/utime.h
116
+ pycparser/utils/fake_libc_include/utmp.h
117
+ pycparser/utils/fake_libc_include/utmpx.h
118
+ pycparser/utils/fake_libc_include/wchar.h
119
+ pycparser/utils/fake_libc_include/wctype.h
120
+ pycparser/utils/fake_libc_include/wordexp.h
121
+ pycparser/utils/fake_libc_include/zlib.h
122
+ pycparser/utils/fake_libc_include/X11/Intrinsic.h
123
+ pycparser/utils/fake_libc_include/X11/Xlib.h
124
+ pycparser/utils/fake_libc_include/X11/_X11_fake_defines.h
125
+ pycparser/utils/fake_libc_include/X11/_X11_fake_typedefs.h
126
+ pycparser/utils/fake_libc_include/arpa/inet.h
127
+ pycparser/utils/fake_libc_include/asm-generic/int-ll64.h
128
+ pycparser/utils/fake_libc_include/linux/socket.h
129
+ pycparser/utils/fake_libc_include/linux/version.h
130
+ pycparser/utils/fake_libc_include/mir_toolkit/client_types.h
131
+ pycparser/utils/fake_libc_include/net/if.h
132
+ pycparser/utils/fake_libc_include/netinet/in.h
133
+ pycparser/utils/fake_libc_include/netinet/tcp.h
134
+ pycparser/utils/fake_libc_include/openssl/err.h
135
+ pycparser/utils/fake_libc_include/openssl/evp.h
136
+ pycparser/utils/fake_libc_include/openssl/hmac.h
137
+ pycparser/utils/fake_libc_include/openssl/ssl.h
138
+ pycparser/utils/fake_libc_include/openssl/x509v3.h
139
+ pycparser/utils/fake_libc_include/sys/ioctl.h
140
+ pycparser/utils/fake_libc_include/sys/ipc.h
141
+ pycparser/utils/fake_libc_include/sys/mman.h
142
+ pycparser/utils/fake_libc_include/sys/msg.h
143
+ pycparser/utils/fake_libc_include/sys/poll.h
144
+ pycparser/utils/fake_libc_include/sys/resource.h
145
+ pycparser/utils/fake_libc_include/sys/select.h
146
+ pycparser/utils/fake_libc_include/sys/sem.h
147
+ pycparser/utils/fake_libc_include/sys/shm.h
148
+ pycparser/utils/fake_libc_include/sys/socket.h
149
+ pycparser/utils/fake_libc_include/sys/stat.h
150
+ pycparser/utils/fake_libc_include/sys/statvfs.h
151
+ pycparser/utils/fake_libc_include/sys/sysctl.h
152
+ pycparser/utils/fake_libc_include/sys/time.h
153
+ pycparser/utils/fake_libc_include/sys/times.h
154
+ pycparser/utils/fake_libc_include/sys/types.h
155
+ pycparser/utils/fake_libc_include/sys/uio.h
156
+ pycparser/utils/fake_libc_include/sys/un.h
157
+ pycparser/utils/fake_libc_include/sys/utsname.h
158
+ pycparser/utils/fake_libc_include/sys/wait.h
159
+ pycparser/utils/fake_libc_include/xcb/xcb.h
160
+ pyquda/__init__.py
161
+ pyquda/__main__.py
162
+ pyquda/_version.py
163
+ pyquda/enum_quda.in.py
164
+ pyquda/field.py
165
+ pyquda/hmc.py
166
+ pyquda/pointer.pxd
167
+ pyquda/pointer.pyi
168
+ pyquda/pyquda.pyi
169
+ pyquda/action/__init__.py
170
+ pyquda/action/abstract.py
171
+ pyquda/action/clover_wilson.py
172
+ pyquda/action/gauge.py
173
+ pyquda/action/hisq.py
174
+ pyquda/dirac/__init__.py
175
+ pyquda/dirac/abstract.py
176
+ pyquda/dirac/clover_wilson.py
177
+ pyquda/dirac/gauge.py
178
+ pyquda/dirac/general.py
179
+ pyquda/dirac/hisq.py
180
+ pyquda/dirac/staggered.py
181
+ pyquda/dirac/wilson.py
182
+ pyquda/src/malloc_pyquda.pyx
183
+ pyquda/src/malloc_quda.pxd
184
+ pyquda/src/pointer.pyx
185
+ pyquda/src/pyquda.in.pyx
186
+ pyquda/src/quda.in.pxd
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyquda = pyquda.__main__:main
@@ -0,0 +1,2 @@
1
+ mpi4py
2
+ numpy
@@ -0,0 +1 @@
1
+ pyquda
pyquda-0.9.1/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # PyQUDA
2
+
3
+ Python wrapper for [QUDA](https://github.com/lattice/quda) written in Cython.
4
+
5
+ This project aims to benefit from the optimized linear algebra library [CuPy](https://cupy.dev/) in Python based on CUDA. CuPy and QUDA will allow us to perform most lattice QCD research operations with high performance. [PyTorch](https://pytorch.org/) is an alternative option.
6
+
7
+ This project is based on the latest QUDA `develop` branch. PyQUDA should be compatible with any commit of QUDA after https://github.com/lattice/quda/pull/1489, but leave some features disabled.
8
+
9
+ ## Feature
10
+
11
+ - Multi-GPU supported
12
+ - with [MPI for Python](https://mpi4py.readthedocs.io/en/stable/) package
13
+ - File I/O
14
+ - Read gauge and propagator in Chroma format
15
+ - Read gauge and propagator in MILC format
16
+ - Read/write gauge and propagator in KYU format
17
+ - Read/write gauge and propagator in XQCD format
18
+ - Read/write gauge and propagator in NPY format (numpy)
19
+ - Quark propagator
20
+ - Isotropic/anisotropic Wilson fermion action with multigrid support
21
+ - Isotropic/anisotropic Clover fermion action with multigrid support
22
+ - Isotropic HISQ fermion action
23
+ - HMC
24
+ - Isotropic Wilson gauge action
25
+ - Isotropic Symanzik gauge action
26
+ - 1-flavor isotropic clover fermion action
27
+ - 2-flavor isotropic clover fermion action
28
+ - Gauge fixing
29
+ - Rotation field with over-relaxation method (waiting for QUDA merge)
30
+ - Gauge smearing
31
+ - 3D/4D APE smearing
32
+ - 3D/4D stout smearing
33
+ - 3D/4D HYP smearing
34
+ - Fermion smearing
35
+ - Gaussian smearing
36
+ - Gradient flow
37
+ - Wilson flow
38
+ - Symanzik flow
39
+
40
+ ## Installation
41
+
42
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Installation for detailed instructions to install PyQUDA from the source.
43
+
44
+ ## Benchmark
45
+
46
+ Refer to https://github.com/CLQCD/PyQUDA/wiki/Benchmark for detailed instructions to run the PyQUDA benchmark.
47
+
48
+ ## Documentation (draft)
49
+
50
+ https://github.com/CLQCD/PyQUDA/wiki/Documentation
51
+
52
+ ## Development
53
+
54
+ We recommend building PyQUDA using in-place mode instead of installing PyQUDA for development.
55
+
56
+ ```bash
57
+ git clone https://github.com/CLQCD/PyQUDA.git
58
+ cd PyQUDA
59
+ ln -s pyquda_core/pyquda pyquda
60
+ cd pyquda_core
61
+ export QUDA_PATH=/path/to/quda/build/usqcd
62
+ python3 setup.py build_ext --inplace
63
+ ```
64
+
65
+ Now you can modify Python files in the project and immediately get the new result by running scripts. Adding the root directory to `sys.path` is needed if you are running scripts from other directories.
66
+
67
+ ## Maintenance
68
+
69
+ Function definitions (mainly in `quda.in.pxd` and `pyquda.in.pyx`) and most docstrings (mainly in `pyquda.pyi` and `enum_quda.in.py`) should be manually updated as they cannot be autogenerated now. This also means PyQUDA should work well with future versions if the API remains unchanged.
@@ -0,0 +1,27 @@
1
+ pycparser -- A C parser in Python
2
+
3
+ Copyright (c) 2008-2022, Eli Bendersky
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification,
7
+ are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+ * Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+ * Neither the name of the copyright holder nor the names of its contributors may
15
+ be used to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
27
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,93 @@
1
+ #-----------------------------------------------------------------
2
+ # pycparser: __init__.py
3
+ #
4
+ # This package file exports some convenience functions for
5
+ # interacting with pycparser
6
+ #
7
+ # Eli Bendersky [https://eli.thegreenplace.net/]
8
+ # License: BSD
9
+ #-----------------------------------------------------------------
10
+ __all__ = ['c_lexer', 'c_parser', 'c_ast']
11
+ __version__ = '2.22'
12
+
13
+ import io
14
+ from subprocess import check_output
15
+ from .c_parser import CParser
16
+
17
+
18
+ def preprocess_file(filename, cpp_path='cpp', cpp_args=''):
19
+ """ Preprocess a file using cpp.
20
+
21
+ filename:
22
+ Name of the file you want to preprocess.
23
+
24
+ cpp_path:
25
+ cpp_args:
26
+ Refer to the documentation of parse_file for the meaning of these
27
+ arguments.
28
+
29
+ When successful, returns the preprocessed file's contents.
30
+ Errors from cpp will be printed out.
31
+ """
32
+ path_list = [cpp_path]
33
+ if isinstance(cpp_args, list):
34
+ path_list += cpp_args
35
+ elif cpp_args != '':
36
+ path_list += [cpp_args]
37
+ path_list += [filename]
38
+
39
+ try:
40
+ # Note the use of universal_newlines to treat all newlines
41
+ # as \n for Python's purpose
42
+ text = check_output(path_list, universal_newlines=True)
43
+ except OSError as e:
44
+ raise RuntimeError("Unable to invoke 'cpp'. " +
45
+ 'Make sure its path was passed correctly\n' +
46
+ ('Original error: %s' % e))
47
+
48
+ return text
49
+
50
+
51
+ def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='',
52
+ parser=None, encoding=None):
53
+ """ Parse a C file using pycparser.
54
+
55
+ filename:
56
+ Name of the file you want to parse.
57
+
58
+ use_cpp:
59
+ Set to True if you want to execute the C pre-processor
60
+ on the file prior to parsing it.
61
+
62
+ cpp_path:
63
+ If use_cpp is True, this is the path to 'cpp' on your
64
+ system. If no path is provided, it attempts to just
65
+ execute 'cpp', so it must be in your PATH.
66
+
67
+ cpp_args:
68
+ If use_cpp is True, set this to the command line arguments strings
69
+ to cpp. Be careful with quotes - it's best to pass a raw string
70
+ (r'') here. For example:
71
+ r'-I../utils/fake_libc_include'
72
+ If several arguments are required, pass a list of strings.
73
+
74
+ encoding:
75
+ Encoding to use for the file to parse
76
+
77
+ parser:
78
+ Optional parser object to be used instead of the default CParser
79
+
80
+ When successful, an AST is returned. ParseError can be
81
+ thrown if the file doesn't parse successfully.
82
+
83
+ Errors from cpp will be printed out.
84
+ """
85
+ if use_cpp:
86
+ text = preprocess_file(filename, cpp_path, cpp_args)
87
+ else:
88
+ with io.open(filename, encoding=encoding) as f:
89
+ text = f.read()
90
+
91
+ if parser is None:
92
+ parser = CParser()
93
+ return parser.parse(text, filename)