From ec01e937c49e2808e2e7153feb73bbeabb49ad42 Mon Sep 17 00:00:00 2001 From: SaltyChiang Date: Fri, 8 Mar 2024 21:10:15 +0800 Subject: [PATCH] Fix bugs for installing pyquda with pycparser already installed. --- pyquda/__init__.py | 2 +- pyquda/version.py | 1 + pyquda_pyx.py | 8 +++++--- setup.cfg | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 pyquda/version.py diff --git a/pyquda/__init__.py b/pyquda/__init__.py index 524b592..2149891 100644 --- a/pyquda/__init__.py +++ b/pyquda/__init__.py @@ -15,7 +15,7 @@ class SupportsWriteAndFlush(SupportsWrite[_T_contra], SupportsFlush, Protocol[_T from mpi4py import MPI -__version__ = "0.6.2" +from .version import __version__ # noqa: F401 from . import pyquda as quda from .field import LatticeInfo diff --git a/pyquda/version.py b/pyquda/version.py new file mode 100644 index 0000000..63af887 --- /dev/null +++ b/pyquda/version.py @@ -0,0 +1 @@ +__version__ = "0.6.3" diff --git a/pyquda_pyx.py b/pyquda_pyx.py index 9dcb6bb..aea8521 100644 --- a/pyquda_pyx.py +++ b/pyquda_pyx.py @@ -145,7 +145,7 @@ def build_pyquda_pyx(pyquda_root, quda_path): print(f"Building pyquda wrapper from {os.path.join(quda_include, 'quda.h')}") try: from pycparser import parse_file, c_ast - except ModuleNotFoundError: + except ImportError or ModuleNotFoundError: from pycparser.pycparser import parse_file, c_ast def evaluate(node): @@ -316,5 +316,7 @@ def evaluate(node): # with open(os.path.join(pyquda_root, "pyquda", "pyquda.pyi"), "w") as f: # f.write(pyquda_pyi) - os.remove(os.path.join(pyquda_root, "yacctab.py")) - os.remove(os.path.join(pyquda_root, "lextab.py")) + if os.path.exists(os.path.join(pyquda_root, "yacctab.py")): + os.remove(os.path.join(pyquda_root, "yacctab.py")) + if os.path.exists(os.path.join(pyquda_root, "lextab.py")): + os.remove(os.path.join(pyquda_root, "lextab.py")) diff --git a/setup.cfg b/setup.cfg index 3630bc1..fe77a8f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = PyQuda -version = attr: pyquda.__version__ +version = attr: pyquda.version.__version__ url = https://github.com/CLQCD/PyQuda author = SaltyChiang author_email = SaltyChiang@users.noreply.github.com