|
2 | 2 | import sys |
3 | 3 | import attr |
4 | 4 | import re |
5 | | -import py |
6 | 5 | import pycparser |
7 | 6 | import shutil |
| 7 | +from pathlib import Path |
8 | 8 | from pycparser import c_ast |
9 | 9 | from pycparser.c_generator import CGenerator |
10 | 10 | from sysconfig import get_config_var |
11 | 11 | from .conf import SPECIAL_CASES, RETURN_CONSTANT |
12 | 12 |
|
13 | | -PUBLIC_API_H = py.path.local(__file__).dirpath('public_api.h') |
14 | | -CURRENT_DIR = py.path.local(__file__).dirpath() |
15 | | -AUTOGEN_H = py.path.local(__file__).dirpath('autogen.h') |
| 13 | +CURRENT_DIR = Path(__file__).resolve().parent |
| 14 | +PUBLIC_API_H = CURRENT_DIR / 'public_api.h' |
| 15 | +AUTOGEN_H = CURRENT_DIR / 'autogen.h' |
16 | 16 |
|
17 | 17 |
|
18 | 18 | def toC(node): |
@@ -209,13 +209,13 @@ def __init__(self, filename): |
209 | 209 | elif sys.platform == 'win32': |
210 | 210 | cpp_cmd = [shutil.which("cl.exe")] |
211 | 211 | if sys.platform == 'win32': |
212 | | - cpp_cmd += ['/E', '/I%s' % CURRENT_DIR] |
| 212 | + cpp_cmd += ['/E', '/I%s' % str(CURRENT_DIR)] |
213 | 213 | else: |
214 | | - cpp_cmd += ['-E', '-I%s' % CURRENT_DIR] |
| 214 | + cpp_cmd += ['-E', '-I%s' % str(CURRENT_DIR)] |
215 | 215 |
|
216 | 216 | msvc = "cl.exe" in cpp_cmd[0].casefold() |
217 | 217 |
|
218 | | - csource = pycparser.preprocess_file(filename, |
| 218 | + csource = pycparser.preprocess_file(str(filename), |
219 | 219 | cpp_path=str(cpp_cmd[0]), |
220 | 220 | cpp_args=cpp_cmd[1:]) |
221 | 221 |
|
|
0 commit comments