Skip to content

Commit

Permalink
start to support windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Nov 29, 2020
1 parent 652f946 commit 9fdbe19
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ __pycache__/

# C extensions
*.so
vc140.pdb

# Distribution / packaging
.Python
Expand Down Expand Up @@ -47,6 +48,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
test-output.xml
*.cover
*.py,cover
.hypothesis/
Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
py38-macos:
python.version: '3.8'
imageName: 'macos-latest'
py38-macos:
python.version: '3.8'
imageName: 'windows-latest'
steps:
- template: azure-templates/ccache.yml
parameters:
Expand Down
9 changes: 6 additions & 3 deletions hpy/universal/src/ctx_meth.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,36 @@ ctx_CallRealFunctionFromTrampoline(HPyContext ctx, HPyFunc_Signature sig,
HPyFunc_varargs f = (HPyFunc_varargs)func;
_HPyFunc_args_VARARGS *a = (_HPyFunc_args_VARARGS*)args;
Py_ssize_t nargs = PyTuple_GET_SIZE(a->args);
HPy h_args[nargs * sizeof(HPy)];
HPy *h_args = (HPy *)malloc(nargs * sizeof(HPy));
for (Py_ssize_t i = 0; i < nargs; i++) {
h_args[i] = _py2h(PyTuple_GET_ITEM(a->args, i));
}
a->result = _h2py(f(ctx, _py2h(a->self), h_args, nargs));
free(h_args);
return;
}
case HPyFunc_KEYWORDS: {
HPyFunc_keywords f = (HPyFunc_keywords)func;
_HPyFunc_args_KEYWORDS *a = (_HPyFunc_args_KEYWORDS*)args;
Py_ssize_t nargs = PyTuple_GET_SIZE(a->args);
HPy h_args[nargs * sizeof(HPy)];
HPy *h_args = (HPy *)malloc(nargs * sizeof(HPy));
for (Py_ssize_t i = 0; i < nargs; i++) {
h_args[i] = _py2h(PyTuple_GET_ITEM(a->args, i));
}
a->result = _h2py(f(ctx, _py2h(a->self), h_args, nargs, _py2h(a->kw)));
free(h_args);
return;
}
case HPyFunc_INITPROC: {
HPyFunc_initproc f = (HPyFunc_initproc)func;
_HPyFunc_args_INITPROC *a = (_HPyFunc_args_INITPROC*)args;
Py_ssize_t nargs = PyTuple_GET_SIZE(a->args);
HPy h_args[nargs * sizeof(HPy)];
HPy *h_args = (HPy *)malloc(nargs * sizeof(HPy));
for (Py_ssize_t i = 0; i < nargs; i++) {
h_args[i] = _py2h(PyTuple_GET_ITEM(a->args, i));
}
a->result = f(ctx, _py2h(a->self), h_args, nargs, _py2h(a->kw));
free(h_args);
return;
}
#include "autogen_ctx_call.i"
Expand Down
30 changes: 22 additions & 8 deletions test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,28 @@ def compile_module(self, ExtensionTemplate, main_src, name, extra_sources):
extra_filename = self._expand(ExtensionTemplate, 'extmod_%d' % i, src)
sources.append(extra_filename)
#
compile_args = [
'-g', '-O0',
'-Wfatal-errors', # stop after one error (unrelated to warnings)
'-Werror', # turn warnings into errors (all, for now)
]
link_args = [
'-g',
]
if sys.platform == 'win32':
# not strictly true, could be mingw
compile_args = [
'/Od',
'/WX', # turn warnings into errors (all, for now)
# '/Wall', # this is too aggresive, makes windows itself fail
'/Zi',
'-D_CRT_SECURE_NO_WARNINGS', # something about _snprintf and _snprintf_s
]
link_args = [
'/DEBUG',
'/LTCG',
]
else:
compile_args = [
'-g', '-O0',
'-Wfatal-errors', # stop after one error (unrelated to warnings)
'-Werror', # turn warnings into errors (all, for now)
]
link_args = [
'-g',
]
#
ext = Extension(
name,
Expand Down
5 changes: 4 additions & 1 deletion test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
class TestParseItem(HPyTest):
def make_parse_item(self, fmt, type, hpy_converter):
mod = self.make_module("""
__attribute__((unused)) static inline
#ifndef _MSC_VER
__attribute__((unused))
#endif
static inline
HPy char_to_hpybytes(HPyContext ctx, char a) {{
return HPyBytes_FromStringAndSize(ctx, &a, 1);
}}
Expand Down

0 comments on commit 9fdbe19

Please sign in to comment.