Skip to content

Commit 0da37e8

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

File tree

2 files changed

+62
-31
lines changed

2 files changed

+62
-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: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ def restore_cencode():
148148
include_dirs = [os.path.join('.', 'libsass', 'include')]
149149
extra_compile_args.append(define)
150150

151+
# Py_LIMITED_API does not work for pypy
152+
# https://foss.heptapod.net/pypy/pypy/issues/3173
153+
if not hasattr(sys, 'pypy_version_info'):
154+
py_limited_api = True
155+
define_macros = [('Py_LIMITED_API', None)]
156+
else:
157+
py_limited_api = False
158+
define_macros = []
159+
151160
sass_extension = Extension(
152161
'_sass',
153162
sorted(sources),
@@ -156,6 +165,8 @@ def restore_cencode():
156165
extra_compile_args=extra_compile_args,
157166
extra_link_args=extra_link_args,
158167
libraries=libraries,
168+
py_limited_api=py_limited_api,
169+
define_macros=define_macros,
159170
)
160171

161172

@@ -210,6 +221,26 @@ def run(self):
210221
shutil.rmtree(path)
211222

212223

224+
cmdclass = {'upload_doc': upload_doc}
225+
226+
if (
227+
sys.platform != 'win32' and
228+
sys.version_info >= (3,) and
229+
platform.python_implementation() == 'CPython'
230+
):
231+
try:
232+
import wheel.bdist_wheel
233+
except ImportError:
234+
pass
235+
else:
236+
class bdist_wheel(wheel.bdist_wheel.bdist_wheel):
237+
def finalize_options(self):
238+
self.py_limited_api = 'cp3{}'.format(sys.version_info[1])
239+
super().finalize_options()
240+
241+
cmdclass['bdist_wheel'] = bdist_wheel
242+
243+
213244
setup(
214245
name='libsass',
215246
description='Sass for Python: '
@@ -265,5 +296,5 @@ def run(self):
265296
'Topic :: Software Development :: Code Generators',
266297
'Topic :: Software Development :: Compilers',
267298
],
268-
cmdclass={'upload_doc': upload_doc},
299+
cmdclass=cmdclass,
269300
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy