Skip to content

Commit b4570ef

Browse files
committed
Build abi3 wheels on macos / linux
1 parent 7611978 commit b4570ef

File tree

2 files changed

+53
-31
lines changed

2 files changed

+53
-31
lines changed

_sass.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static union Sass_Value* _list_to_sass_value(PyObject* value) {
164164
retv = sass_make_list(PyTuple_Size(items), sep, is_bracketed);
165165
for (i = 0; i < PyTuple_Size(items); i += 1) {
166166
sass_list_set_value(
167-
retv, i, _to_sass_value(PyTuple_GET_ITEM(items, i))
167+
retv, i, _to_sass_value(PyTuple_GetItem(items, i))
168168
);
169169
}
170170
Py_DECREF(types_mod);
@@ -200,7 +200,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
200200
PyObject* unit = PyObject_GetAttrString(value, "unit");
201201
PyObject* bytes = PyUnicode_AsEncodedString(unit, "UTF-8", "strict");
202202
retv = sass_make_number(
203-
PyFloat_AsDouble(d_value), PyBytes_AS_STRING(bytes)
203+
PyFloat_AsDouble(d_value), PyBytes_AsString(bytes)
204204
);
205205
Py_DECREF(d_value);
206206
Py_DECREF(unit);
@@ -211,7 +211,7 @@ static union Sass_Value* _number_to_sass_value(PyObject* value) {
211211
static union Sass_Value* _unicode_to_sass_value(PyObject* value) {
212212
union Sass_Value* retv = NULL;
213213
PyObject* bytes = PyUnicode_AsEncodedString(value, "UTF-8", "strict");
214-
retv = sass_make_string(PyBytes_AS_STRING(bytes));
214+
retv = sass_make_string(PyBytes_AsString(bytes));
215215
Py_DECREF(bytes);
216216
return retv;
217217
}
@@ -220,7 +220,7 @@ static union Sass_Value* _warning_to_sass_value(PyObject* value) {
220220
union Sass_Value* retv = NULL;
221221
PyObject* msg = PyObject_GetAttrString(value, "msg");
222222
PyObject* bytes = PyUnicode_AsEncodedString(msg, "UTF-8", "strict");
223-
retv = sass_make_warning(PyBytes_AS_STRING(bytes));
223+
retv = sass_make_warning(PyBytes_AsString(bytes));
224224
Py_DECREF(msg);
225225
Py_DECREF(bytes);
226226
return retv;
@@ -230,7 +230,7 @@ static union Sass_Value* _error_to_sass_value(PyObject* value) {
230230
union Sass_Value* retv = NULL;
231231
PyObject* msg = PyObject_GetAttrString(value, "msg");
232232
PyObject* bytes = PyUnicode_AsEncodedString(msg, "UTF-8", "strict");
233-
retv = sass_make_error(PyBytes_AS_STRING(bytes));
233+
retv = sass_make_error(PyBytes_AsString(bytes));
234234
Py_DECREF(msg);
235235
Py_DECREF(bytes);
236236
return retv;
@@ -259,7 +259,7 @@ static union Sass_Value* _unknown_type_to_sass_error(PyObject* value) {
259259
format_meth, type_name, NULL
260260
);
261261
PyObject* bytes = PyUnicode_AsEncodedString(result, "UTF-8", "strict");
262-
retv = sass_make_error(PyBytes_AS_STRING(bytes));
262+
retv = sass_make_error(PyBytes_AsString(bytes));
263263
Py_DECREF(type);
264264
Py_DECREF(type_name);
265265
Py_DECREF(fmt);
@@ -298,7 +298,7 @@ static PyObject* _exception_to_bytes() {
298298

299299
static union Sass_Value* _exception_to_sass_error() {
300300
PyObject* bytes = _exception_to_bytes();
301-
union Sass_Value* retv = sass_make_error(PyBytes_AS_STRING(bytes));
301+
union Sass_Value* retv = sass_make_error(PyBytes_AsString(bytes));
302302
Py_DECREF(bytes);
303303
return retv;
304304
}
@@ -307,7 +307,7 @@ static Sass_Import_List _exception_to_sass_import_error(const char* path) {
307307
PyObject* bytes = _exception_to_bytes();
308308
Sass_Import_List import_list = sass_make_import_list(1);
309309
import_list[0] = sass_make_import_entry(path, 0, 0);
310-
sass_import_set_error(import_list[0], PyBytes_AS_STRING(bytes), 0, 0);
310+
sass_import_set_error(import_list[0], PyBytes_AsString(bytes), 0, 0);
311311
Py_DECREF(bytes);
312312
return import_list;
313313
}
@@ -330,7 +330,7 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
330330
} else if (PyUnicode_Check(value)) {
331331
retv = _unicode_to_sass_value(value);
332332
} else if (PyBytes_Check(value)) {
333-
retv = sass_make_string(PyBytes_AS_STRING(value));
333+
retv = sass_make_string(PyBytes_AsString(value));
334334
/* XXX: PyMapping_Check returns true for lists and tuples in python3 :( */
335335
/* XXX: pypy derps on dicts: https://bitbucket.org/pypy/pypy/issue/1970 */
336336
} else if (PyDict_Check(value) || PyObject_IsInstance(value, mapping_t)) {
@@ -400,11 +400,11 @@ static void _add_custom_functions(
400400
Sass_Function_List fn_list = sass_make_function_list(
401401
PyList_Size(custom_functions)
402402
);
403-
for (i = 0; i < PyList_GET_SIZE(custom_functions); i += 1) {
404-
PyObject* sass_function = PyList_GET_ITEM(custom_functions, i);
403+
for (i = 0; i < PyList_Size(custom_functions); i += 1) {
404+
PyObject* sass_function = PyList_GetItem(custom_functions, i);
405405
PyObject* signature = PySass_Object_Bytes(sass_function);
406406
Sass_Function_Entry fn = sass_make_function(
407-
PyBytes_AS_STRING(signature),
407+
PyBytes_AsString(signature),
408408
_call_py_f,
409409
sass_function
410410
);
@@ -439,13 +439,13 @@ static Sass_Import_List _call_py_importer_f(
439439

440440
/* Otherwise, we know our importer is well formed (because we wrap it)
441441
* The return value will be a tuple of 1, 2, or 3 tuples */
442-
sass_imports = sass_make_import_list(PyTuple_GET_SIZE(py_result));
443-
for (i = 0; i < PyTuple_GET_SIZE(py_result); i += 1) {
442+
sass_imports = sass_make_import_list(PyTuple_Size(py_result));
443+
for (i = 0; i < PyTuple_Size(py_result); i += 1) {
444444
char* path_str = NULL; /* XXX: Memory leak? */
445445
char* source_str = NULL;
446446
char* sourcemap_str = NULL;
447-
PyObject* tup = PyTuple_GET_ITEM(py_result, i);
448-
Py_ssize_t size = PyTuple_GET_SIZE(tup);
447+
PyObject* tup = PyTuple_GetItem(py_result, i);
448+
Py_ssize_t size = PyTuple_Size(tup);
449449

450450
if (size == 1) {
451451
PyArg_ParseTuple(tup, PySass_IF_PY3("y", "s"), &path_str);
@@ -491,10 +491,10 @@ static void _add_custom_importers(
491491
return;
492492
}
493493

494-
importer_list = sass_make_importer_list(PyTuple_GET_SIZE(custom_importers));
494+
importer_list = sass_make_importer_list(PyTuple_Size(custom_importers));
495495

496-
for (i = 0; i < PyTuple_GET_SIZE(custom_importers); i += 1) {
497-
PyObject* item = PyTuple_GET_ITEM(custom_importers, i);
496+
for (i = 0; i < PyTuple_Size(custom_importers); i += 1) {
497+
PyObject* item = PyTuple_GetItem(custom_importers, i);
498498
int priority = 0;
499499
PyObject* import_function = NULL;
500500

@@ -513,11 +513,11 @@ PySass_compile_string(PyObject *self, PyObject *args) {
513513
struct Sass_Context *ctx;
514514
struct Sass_Data_Context *context;
515515
struct Sass_Options *options;
516-
char *string, *include_paths, *source_map_file;
516+
char *string, *include_paths;
517517
const char *error_message, *output_string;
518518
enum Sass_Output_Style output_style;
519519
int source_comments, error_status, precision, indented,
520-
source_map_embed, source_map_contents, source_map_file_urls,
520+
source_map_embed, source_map_contents,
521521
omit_source_map_url;
522522
PyObject *custom_functions;
523523
PyObject *custom_importers;
@@ -545,9 +545,9 @@ PySass_compile_string(PyObject *self, PyObject *args) {
545545
sass_option_set_source_map_embed(options, source_map_embed);
546546
sass_option_set_omit_source_map_url(options, omit_source_map_url);
547547

548-
if (PyBytes_Check(source_map_root) && PyBytes_GET_SIZE(source_map_root)) {
548+
if (PyBytes_Check(source_map_root) && PyBytes_Size(source_map_root)) {
549549
sass_option_set_source_map_root(
550-
options, PyBytes_AS_STRING(source_map_root)
550+
options, PyBytes_AsString(source_map_root)
551551
);
552552
}
553553

@@ -577,7 +577,7 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
577577
const char *error_message, *output_string, *source_map_string;
578578
enum Sass_Output_Style output_style;
579579
int source_comments, error_status, precision, source_map_embed,
580-
source_map_contents, source_map_file_urls, omit_source_map_url;
580+
source_map_contents, omit_source_map_url;
581581
PyObject *source_map_filename, *custom_functions, *custom_importers,
582582
*result, *output_filename_hint, *source_map_root;
583583

@@ -596,23 +596,23 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
596596
options = sass_file_context_get_options(context);
597597

598598
if (PyBytes_Check(source_map_filename)) {
599-
if (PyBytes_GET_SIZE(source_map_filename)) {
599+
if (PyBytes_Size(source_map_filename)) {
600600
sass_option_set_source_map_file(
601-
options, PyBytes_AS_STRING(source_map_filename)
601+
options, PyBytes_AsString(source_map_filename)
602602
);
603603
}
604604
}
605605
if (PyBytes_Check(output_filename_hint)) {
606-
if (PyBytes_GET_SIZE(output_filename_hint)) {
606+
if (PyBytes_Size(output_filename_hint)) {
607607
sass_option_set_output_path(
608-
options, PyBytes_AS_STRING(output_filename_hint)
608+
options, PyBytes_AsString(output_filename_hint)
609609
);
610610
}
611611
}
612612

613-
if (PyBytes_Check(source_map_root) && PyBytes_GET_SIZE(source_map_root)) {
613+
if (PyBytes_Check(source_map_root) && PyBytes_Size(source_map_root)) {
614614
sass_option_set_source_map_root(
615-
options, PyBytes_AS_STRING(source_map_root)
615+
options, PyBytes_AsString(source_map_root)
616616
);
617617
}
618618

setup.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ def restore_cencode():
156156
extra_compile_args=extra_compile_args,
157157
extra_link_args=extra_link_args,
158158
libraries=libraries,
159+
# abi3
160+
py_limited_api=True, define_macros=[('Py_LIMITED_API', None)],
159161
)
160162

161163

@@ -210,6 +212,26 @@ def run(self):
210212
shutil.rmtree(path)
211213

212214

215+
cmdclass = {'upload_doc': upload_doc}
216+
217+
if (
218+
sys.platform != 'win32' and
219+
sys.version_info >= (3,) and
220+
platform.python_implementation() == 'CPython'
221+
):
222+
try:
223+
import wheel.bdist_wheel
224+
except ImportError:
225+
pass
226+
else:
227+
class bdist_wheel(wheel.bdist_wheel.bdist_wheel):
228+
def finalize_options(self):
229+
self.py_limited_api = 'cp3{}'.format(sys.version_info[1])
230+
super().finalize_options()
231+
232+
cmdclass['bdist_wheel'] = bdist_wheel
233+
234+
213235
setup(
214236
name='libsass',
215237
description='Sass for Python: '
@@ -265,5 +287,5 @@ def run(self):
265287
'Topic :: Software Development :: Code Generators',
266288
'Topic :: Software Development :: Compilers',
267289
],
268-
cmdclass={'upload_doc': upload_doc},
290+
cmdclass=cmdclass,
269291
)

0 commit comments

Comments
 (0)