-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for c++ standards, add using MACOSX_DEPLOYMENT_TARGET, fix …
…names of macos wheels
- Loading branch information
Showing
16 changed files
with
315 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import utils | ||
import sys | ||
|
||
def test_cpp11(): | ||
add_env = {"CIBW_SKIP": "cp27-win* cp34-win*"} | ||
# VC for python 2.7 do not support modern standards | ||
if utils.platform == "macos": | ||
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.9" | ||
project_dir = os.path.join(os.path.dirname(__file__), "cpp11") | ||
# this test checks if c++11 standard is supported. | ||
|
||
utils.cibuildwheel_run(project_dir, add_env=add_env) | ||
|
||
|
||
def test_cpp14(): | ||
add_env = {"CIBW_SKIP": "cp27-win* cp35-win* *manylinux1*"} | ||
# VC for python 2.7 do not support modern standards | ||
# manylinux1 docker image do not support compilers with standards newer than c++11 | ||
if utils.platform == "macos": | ||
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.9" | ||
project_dir = os.path.join(os.path.dirname(__file__), "cpp14") | ||
# this test checks if c++14 standard is supported. | ||
|
||
utils.cibuildwheel_run(project_dir, add_env=add_env) | ||
|
||
def test_cpp17(): | ||
# python 2.7 use `register` keyword which is forbidden in c++17 standard | ||
# manylinux1 docker image do not support compilers with standards newer than c++11 | ||
add_env = {"CIBW_SKIP": "cp27* cp35-win* *manylinux1*"} | ||
if utils.platform == "macos": | ||
add_env["MACOSX_DEPLOYMENT_TARGET"] = "10.13" | ||
|
||
project_dir = os.path.join(os.path.dirname(__file__), "cpp17") | ||
# this test checks if c++17 standard is supported. | ||
|
||
utils.cibuildwheel_run(project_dir, add_env=add_env) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os, sys | ||
|
||
from setuptools import setup, Extension | ||
|
||
setup( | ||
name="spam11", | ||
ext_modules=[Extension('spam11', sources=['spam11.cpp'], language="c++", extra_compile_args=["-std=c++11"])], | ||
version="0.1.0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <Python.h> | ||
#include <array> | ||
|
||
static PyObject * | ||
spam_system(PyObject *self, PyObject *args) | ||
{ | ||
const char *command; | ||
int sts; | ||
|
||
if (!PyArg_ParseTuple(args, "s", &command)) | ||
return NULL; | ||
sts = system(command); | ||
return PyLong_FromLong(sts); | ||
} | ||
|
||
/* Module initialization */ | ||
|
||
#if PY_MAJOR_VERSION >= 3 | ||
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) | ||
#define MOD_DEF(m, name, doc, methods, module_state_size) \ | ||
static struct PyModuleDef moduledef = { \ | ||
PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ | ||
m = PyModule_Create(&moduledef); | ||
#define MOD_RETURN(m) return m; | ||
#else | ||
#define MOD_INIT(name) PyMODINIT_FUNC init##name(void) | ||
#define MOD_DEF(m, name, doc, methods, module_state_size) \ | ||
m = Py_InitModule3(name, methods, doc); | ||
#define MOD_RETURN(m) return; | ||
#endif | ||
|
||
static PyMethodDef module_methods[] = { | ||
{"system", (PyCFunction)spam_system, METH_VARARGS, | ||
"Execute a shell command."}, | ||
{NULL} /* Sentinel */ | ||
}; | ||
|
||
MOD_INIT(spam11) | ||
{ | ||
PyObject* m; | ||
|
||
MOD_DEF(m, | ||
"spam11", | ||
"Example module", | ||
module_methods, | ||
-1) | ||
|
||
MOD_RETURN(m) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import os, sys | ||
|
||
from setuptools import setup, Extension | ||
|
||
setup( | ||
name="spam14", | ||
ext_modules=[Extension('spam14', sources=['spam14.cpp'], language="c++", extra_compile_args=["-std=c++14"])], | ||
version="0.1.0", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <Python.h> | ||
#include <array> | ||
|
||
int a = 100'000; | ||
|
||
static PyObject * | ||
spam_system(PyObject *self, PyObject *args) | ||
{ | ||
const char *command; | ||
int sts; | ||
|
||
if (!PyArg_ParseTuple(args, "s", &command)) | ||
return NULL; | ||
sts = system(command); | ||
return PyLong_FromLong(sts); | ||
} | ||
|
||
/* Module initialization */ | ||
|
||
#if PY_MAJOR_VERSION >= 3 | ||
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) | ||
#define MOD_DEF(m, name, doc, methods, module_state_size) \ | ||
static struct PyModuleDef moduledef = { \ | ||
PyModuleDef_HEAD_INIT, name, doc, module_state_size, methods, }; \ | ||
m = PyModule_Create(&moduledef); | ||
#define MOD_RETURN(m) return m; | ||
#else | ||
#define MOD_INIT(name) PyMODINIT_FUNC init##name(void) | ||
#define MOD_DEF(m, name, doc, methods, module_state_size) \ | ||
m = Py_InitModule3(name, methods, doc); | ||
#define MOD_RETURN(m) return; | ||
#endif | ||
|
||
static PyMethodDef module_methods[] = { | ||
{"system", (PyCFunction)spam_system, METH_VARARGS, | ||
"Execute a shell command."}, | ||
{NULL} /* Sentinel */ | ||
}; | ||
|
||
MOD_INIT(spam14) | ||
{ | ||
PyObject* m; | ||
|
||
MOD_DEF(m, | ||
"spam14", | ||
"Example module", | ||
module_methods, | ||
-1) | ||
|
||
MOD_RETURN(m) | ||
} |
Oops, something went wrong.