Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ envlist = graalpy

[testenv]
deps =
pytest==6.0.1
pytest==8.4.2
commands =
pytest --assert=plain tests {posargs}

Expand Down
2 changes: 1 addition & 1 deletion graalpython/hpy/docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ sphinx-rtd-theme==2.0.0
sphinx-autobuild==2021.3.14
sphinx-c-autodoc==1.3.0
clang==17.0.6
docutils==0.16 # docutils >= 0.17 fails to render bullet lists :/
docutils==0.18.1 # Latest release supported by Sphinx 5.0.2
5 changes: 3 additions & 2 deletions graalpython/hpy/hpy/tools/autogen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Parse public_api.h and generate various stubs around
"""
import sys
import py
from pathlib import Path

import pycparser
from packaging import version

Expand Down Expand Up @@ -57,7 +58,7 @@ def main():
if len(sys.argv) != 2:
print('Usage: python -m hpy.tools.autogen OUTDIR')
sys.exit(1)
outdir = py.path.local(sys.argv[1])
outdir = Path(sys.argv[1])

generate(DEFAULT_GENERATORS, outdir)

Expand Down
10 changes: 9 additions & 1 deletion graalpython/hpy/hpy/tools/autogen/autogenfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
*/
"""


def resolve_relative_path(root, relative_path):
if hasattr(root, 'join'):
return root.join(relative_path)
return root / relative_path


class AutoGenFile:
LANGUAGE = 'C'
PATH = None
Expand All @@ -27,7 +34,8 @@ def generate(self):
def write(self, root):
cls = self.__class__
clsname = '%s.%s' % (cls.__module__, cls.__name__)
with root.join(self.PATH).open('w', encoding='utf-8') as f:
target = resolve_relative_path(root, self.PATH)
with target.open('w', encoding='utf-8') as f:
if self.DISCLAIMER is not None:
f.write(self.DISCLAIMER.format(clsname=clsname))
f.write('\n')
Expand Down
7 changes: 4 additions & 3 deletions graalpython/hpy/hpy/tools/autogen/doc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import textwrap
import re

from .autogenfile import AutoGenFile
from .autogenfile import AutoGenFile, resolve_relative_path
from .parse import toC
from .ctx import autogen_ctx_h
from .conf import (DOC_C_API_PAGES_SPECIAL_CASES,
Expand Down Expand Up @@ -64,7 +64,8 @@ def write(self, root):
if not self.BEGIN_MARKER or not self.END_MARKER:
raise RuntimeError("missing BEGIN_MARKER or END_MARKER")
n_begin = len(self.BEGIN_MARKER)
with root.join(self.PATH).open('r', encoding='utf-8') as f:
target = resolve_relative_path(root, self.PATH)
with target.open('r', encoding='utf-8') as f:
content = f.read()
start = content.find(self.BEGIN_MARKER)
if start < 0:
Expand All @@ -75,7 +76,7 @@ def write(self, root):
raise RuntimeError(f'end marker "{self.END_MARKER}" not found in'
f'file {self.PATH}')
new_content = self.generate(content[(start+n_begin):end])
with root.join(self.PATH).open('w', encoding='utf-8') as f:
with target.open('w', encoding='utf-8') as f:
f.write(content[:start + n_begin] + new_content + content[end:])


Expand Down
14 changes: 7 additions & 7 deletions graalpython/hpy/hpy/tools/autogen/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
import sys
import attr
import re
import py
import pycparser
import shutil
from pathlib import Path
from pycparser import c_ast
from pycparser.c_generator import CGenerator
from sysconfig import get_config_var
from .conf import SPECIAL_CASES, RETURN_CONSTANT

PUBLIC_API_H = py.path.local(__file__).dirpath('public_api.h')
CURRENT_DIR = py.path.local(__file__).dirpath()
AUTOGEN_H = py.path.local(__file__).dirpath('autogen.h')
CURRENT_DIR = Path(__file__).resolve().parent
PUBLIC_API_H = CURRENT_DIR / 'public_api.h'
AUTOGEN_H = CURRENT_DIR / 'autogen.h'


def toC(node):
Expand Down Expand Up @@ -209,13 +209,13 @@ def __init__(self, filename):
elif sys.platform == 'win32':
cpp_cmd = [shutil.which("cl.exe")]
if sys.platform == 'win32':
cpp_cmd += ['/E', '/I%s' % CURRENT_DIR]
cpp_cmd += ['/E', '/I%s' % str(CURRENT_DIR)]
else:
cpp_cmd += ['-E', '-I%s' % CURRENT_DIR]
cpp_cmd += ['-E', '-I%s' % str(CURRENT_DIR)]

msvc = "cl.exe" in cpp_cmd[0].casefold()

csource = pycparser.preprocess_file(filename,
csource = pycparser.preprocess_file(str(filename),
cpp_path=str(cpp_cmd[0]),
cpp_args=cpp_cmd[1:])

Expand Down
9 changes: 4 additions & 5 deletions graalpython/hpy/hpy/tools/autogen/testing/test_autogen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import textwrap
import difflib
import py
import pytest
from hpy.tools.autogen.parse import HPyAPI
from hpy.tools.autogen.ctx import autogen_ctx_h, autogen_ctx_def_h
Expand All @@ -26,11 +25,11 @@ def src_equal(exp, got):
class BaseTestAutogen:

@pytest.fixture
def initargs(self, tmpdir):
self.tmpdir = tmpdir
def initargs(self, tmp_path):
self.tmpdir = tmp_path

def parse(self, src):
fname = self.tmpdir.join('test_api.h')
fname = self.tmpdir / 'test_api.h'
# automatically add useful typedefs
src = """
#define STRINGIFY(X) #X
Expand All @@ -39,7 +38,7 @@ def parse(self, src):
typedef int HPy;
typedef int HPyContext;
""" + src
fname.write(src)
fname.write_text(src)
return HPyAPI.parse(fname)


Expand Down
5 changes: 2 additions & 3 deletions graalpython/hpy/requirements-autogen.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pycparser==2.21
py==1.11.0
packaging==19.2
attrs==19.3.0
packaging==25.0
attrs==23.2.0
1 change: 0 additions & 1 deletion mx.graalpython/mx_graalpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,6 @@ def tox_example(args=None):
"packaging==25.0",
"platformdirs==4.3.8",
"pluggy==1.5.0",
"py==1.11.0",
"pyparsing==3.2.3",
"six==1.17.0",
"toml==0.10.2",
Expand Down
Loading