Skip to content

Commit 4354c5f

Browse files
committed
Merge pull request #60 from Eksmo/feature/freebsd_support
Fix problem compiling package under FreeBSD
2 parents a66606e + 4a6566e commit 4354c5f

File tree

6 files changed

+125
-155
lines changed

6 files changed

+125
-155
lines changed

libsass

Submodule libsass updated 113 files

pysass.cpp

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ static union Sass_Value* _error_to_sass_value(PyObject* value);
3535
static union Sass_Value* _unknown_type_to_sass_error(PyObject* value);
3636
static union Sass_Value* _exception_to_sass_error();
3737

38-
struct PySass_Pair {
39-
char *label;
40-
int value;
41-
};
42-
43-
static struct PySass_Pair PySass_output_style_enum[] = {
44-
{(char *) "nested", SASS_STYLE_NESTED},
45-
{(char *) "expanded", SASS_STYLE_EXPANDED},
46-
{(char *) "compact", SASS_STYLE_COMPACT},
47-
{(char *) "compressed", SASS_STYLE_COMPRESSED},
48-
{NULL}
49-
};
5038

5139
static PyObject* _to_py_value(const union Sass_Value* value) {
5240
PyObject* retv = NULL;
@@ -362,10 +350,12 @@ static union Sass_Value* _to_sass_value(PyObject* value) {
362350
}
363351

364352
static union Sass_Value* _call_py_f(
365-
const union Sass_Value* sass_args, void* cookie
353+
const union Sass_Value* sass_args,
354+
Sass_Function_Entry cb,
355+
struct Sass_Options* opts
366356
) {
367357
size_t i;
368-
PyObject* pyfunc = (PyObject*)cookie;
358+
PyObject* pyfunc = (PyObject*)sass_function_get_cookie(cb);
369359
PyObject* py_args = PyTuple_New(sass_list_get_length(sass_args));
370360
PyObject* py_result = NULL;
371361
union Sass_Value* sass_result = NULL;
@@ -394,13 +384,13 @@ static void _add_custom_functions(
394384
struct Sass_Options* options, PyObject* custom_functions
395385
) {
396386
Py_ssize_t i;
397-
Sass_C_Function_List fn_list = sass_make_function_list(
387+
Sass_Function_List fn_list = sass_make_function_list(
398388
PyList_Size(custom_functions)
399389
);
400390
for (i = 0; i < PyList_GET_SIZE(custom_functions); i += 1) {
401391
PyObject* sass_function = PyList_GET_ITEM(custom_functions, i);
402392
PyObject* signature = PySass_Object_Bytes(sass_function);
403-
Sass_C_Function_Callback fn = sass_make_function(
393+
Sass_Function_Entry fn = sass_make_function(
404394
PySass_Bytes_AS_STRING(signature),
405395
_call_py_f,
406396
sass_function
@@ -415,27 +405,26 @@ PySass_compile_string(PyObject *self, PyObject *args) {
415405
struct Sass_Context *ctx;
416406
struct Sass_Data_Context *context;
417407
struct Sass_Options *options;
418-
char *string, *include_paths, *image_path;
408+
char *string, *include_paths;
419409
const char *error_message, *output_string;
420410
Sass_Output_Style output_style;
421411
int source_comments, error_status, precision;
422412
PyObject *custom_functions;
423413
PyObject *result;
424414

425415
if (!PyArg_ParseTuple(args,
426-
PySass_IF_PY3("yiiyyiO", "siissiO"),
416+
PySass_IF_PY3("yiiyiO", "siisiO"),
427417
&string, &output_style, &source_comments,
428-
&include_paths, &image_path, &precision,
418+
&include_paths, &precision,
429419
&custom_functions)) {
430420
return NULL;
431421
}
432422

433-
context = sass_make_data_context(string);
423+
context = sass_make_data_context(strdup(string));
434424
options = sass_data_context_get_options(context);
435425
sass_option_set_output_style(options, output_style);
436426
sass_option_set_source_comments(options, source_comments);
437427
sass_option_set_include_path(options, include_paths);
438-
sass_option_set_image_path(options, image_path);
439428
sass_option_set_precision(options, precision);
440429
_add_custom_functions(options, custom_functions);
441430

@@ -459,16 +448,16 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
459448
struct Sass_Context *ctx;
460449
struct Sass_File_Context *context;
461450
struct Sass_Options *options;
462-
char *filename, *include_paths, *image_path;
451+
char *filename, *include_paths;
463452
const char *error_message, *output_string, *source_map_string;
464453
Sass_Output_Style output_style;
465454
int source_comments, error_status, precision;
466455
PyObject *source_map_filename, *custom_functions, *result;
467456

468457
if (!PyArg_ParseTuple(args,
469-
PySass_IF_PY3("yiiyyiOO", "siissiOO"),
458+
PySass_IF_PY3("yiiyiOO", "siisiOO"),
470459
&filename, &output_style, &source_comments,
471-
&include_paths, &image_path, &precision,
460+
&include_paths, &precision,
472461
&source_map_filename, &custom_functions)) {
473462
return NULL;
474463
}
@@ -491,7 +480,6 @@ PySass_compile_filename(PyObject *self, PyObject *args) {
491480
sass_option_set_output_style(options, output_style);
492481
sass_option_set_source_comments(options, source_comments);
493482
sass_option_set_include_path(options, include_paths);
494-
sass_option_set_image_path(options, image_path);
495483
sass_option_set_precision(options, precision);
496484
_add_custom_functions(options, custom_functions);
497485

@@ -522,22 +510,17 @@ static PyMethodDef PySass_methods[] = {
522510

523511
static char PySass_doc[] = "The thin binding of libsass for Python.";
524512

525-
void PySass_make_enum_dict(PyObject *enum_dict, struct PySass_Pair *pairs) {
526-
size_t i;
527-
for (i = 0; pairs[i].label; ++i) {
528-
PyDict_SetItemString(
529-
enum_dict,
530-
pairs[i].label,
531-
PySass_Int_FromLong((long) pairs[i].value)
532-
);
533-
}
513+
PyObject* PySass_make_enum_dict() {
514+
PyObject* dct = PyDict_New();
515+
PyDict_SetItemString(dct, "nested", PySass_Int_FromLong(SASS_STYLE_NESTED));
516+
PyDict_SetItemString(dct, "expected", PySass_Int_FromLong(SASS_STYLE_EXPANDED));
517+
PyDict_SetItemString(dct, "compact", PySass_Int_FromLong(SASS_STYLE_COMPACT));
518+
PyDict_SetItemString(dct, "compressed", PySass_Int_FromLong(SASS_STYLE_COMPRESSED));
519+
return dct;
534520
}
535521

536522
void PySass_init_module(PyObject *module) {
537-
PyObject *output_styles;
538-
output_styles = PyDict_New();
539-
PySass_make_enum_dict(output_styles, PySass_output_style_enum);
540-
PyModule_AddObject(module, "OUTPUT_STYLES", output_styles);
523+
PyModule_AddObject(module, "OUTPUT_STYLES", PySass_make_enum_dict());
541524
}
542525

543526
#if PY_MAJOR_VERSION >= 3

sass.py

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ def __str__(self):
144144

145145
def compile_dirname(
146146
search_path, output_path, output_style, source_comments, include_paths,
147-
image_path, precision, custom_functions,
147+
precision, custom_functions,
148148
):
149149
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
150150
for dirpath, _, filenames in os.walk(search_path):
151151
filenames = [
152-
filename for filename in filenames if filename.endswith('.scss')
152+
filename for filename in filenames
153+
if filename.endswith('.scss') and not filename.startswith('_')
153154
]
154155
for filename in filenames:
155156
input_filename = os.path.join(dirpath, filename)
@@ -159,7 +160,7 @@ def compile_dirname(
159160
input_filename = input_filename.encode(fs_encoding)
160161
s, v, _ = compile_filename(
161162
input_filename, output_style, source_comments, include_paths,
162-
image_path, precision, None, custom_functions,
163+
precision, None, custom_functions,
163164
)
164165
if s:
165166
v = v.decode('UTF-8')
@@ -192,8 +193,6 @@ def compile(**kwargs):
192193
:param include_paths: an optional list of paths to find ``@import``\ ed
193194
SASS/CSS source files
194195
:type include_paths: :class:`collections.Sequence`, :class:`str`
195-
:param image_path: an optional path to find images
196-
:type image_path: :class:`str`
197196
:param precision: optional precision for numbers. :const:`5` by default.
198197
:type precision: :class:`int`
199198
:param custom_functions: optional mapping of custom functions.
@@ -229,8 +228,6 @@ def compile(**kwargs):
229228
:param include_paths: an optional list of paths to find ``@import``\ ed
230229
SASS/CSS source files
231230
:type include_paths: :class:`collections.Sequence`, :class:`str`
232-
:param image_path: an optional path to find images
233-
:type image_path: :class:`str`
234231
:param precision: optional precision for numbers. :const:`5` by default.
235232
:type precision: :class:`int`
236233
:param custom_functions: optional mapping of custom functions.
@@ -269,8 +266,6 @@ def compile(**kwargs):
269266
:param include_paths: an optional list of paths to find ``@import``\ ed
270267
SASS/CSS source files
271268
:type include_paths: :class:`collections.Sequence`, :class:`str`
272-
:param image_path: an optional path to find images
273-
:type image_path: :class:`str`
274269
:param precision: optional precision for numbers. :const:`5` by default.
275270
:type precision: :class:`int`
276271
:param custom_functions: optional mapping of custom functions.
@@ -424,16 +419,6 @@ def func_name(a, b):
424419
'Windows) string, not ' + repr(include_paths))
425420
if isinstance(include_paths, text_type):
426421
include_paths = include_paths.encode(fs_encoding)
427-
try:
428-
image_path = kwargs.pop('image_path')
429-
except KeyError:
430-
image_path = b'.'
431-
else:
432-
if not isinstance(image_path, string_types):
433-
raise TypeError('image_path must be a string, not ' +
434-
repr(image_path))
435-
elif isinstance(image_path, text_type):
436-
image_path = image_path.encode(fs_encoding)
437422

438423
custom_functions = kwargs.pop('custom_functions', ())
439424
if isinstance(custom_functions, collections.Mapping):
@@ -460,10 +445,10 @@ def func_name(a, b):
460445
string = kwargs.pop('string')
461446
if isinstance(string, text_type):
462447
string = string.encode('utf-8')
463-
s, v = compile_string(string,
464-
output_style, source_comments,
465-
include_paths, image_path, precision,
466-
custom_functions)
448+
s, v = compile_string(
449+
string, output_style, source_comments, include_paths, precision,
450+
custom_functions,
451+
)
467452
if s:
468453
return v.decode('utf-8')
469454
elif 'filename' in modes:
@@ -475,10 +460,8 @@ def func_name(a, b):
475460
elif isinstance(filename, text_type):
476461
filename = filename.encode(fs_encoding)
477462
s, v, source_map = compile_filename(
478-
filename,
479-
output_style, source_comments,
480-
include_paths, image_path, precision, source_map_filename,
481-
custom_functions,
463+
filename, output_style, source_comments, include_paths, precision,
464+
source_map_filename, custom_functions,
482465
)
483466
if s:
484467
v = v.decode('utf-8')
@@ -522,10 +505,8 @@ def func_name(a, b):
522505
raise ValueError('dirname must be a pair of (source_dir, '
523506
'output_dir)')
524507
s, v = compile_dirname(
525-
search_path, output_path,
526-
output_style, source_comments,
527-
include_paths, image_path, precision,
528-
custom_functions,
508+
search_path, output_path, output_style, source_comments,
509+
include_paths, precision, custom_functions,
529510
)
530511
if s:
531512
return

sassc.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
Optional directory path to find ``@import``\ ed (S)CSS files.
2222
Can be multiply used.
2323
24-
.. option:: -i <dir>, --image-path <dir>
25-
26-
Path to find images. Default is the current directory (:file:`./`).
27-
2824
.. option:: -m, -g, --sourcemap
2925
3026
Emit source map. Requires the second argument (output CSS filename).
@@ -88,8 +84,6 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
8884
dest='include_paths', action='append',
8985
help='Path to find "@import"ed (S)CSS source files. '
9086
'Can be multiply used.')
91-
parser.add_option('-i', '--image-path', metavar='DIR', default='./',
92-
help='Path to find images. [default: %default]')
9387
parser.add_option('-w', '--watch', action='store_true',
9488
help='Watch file for changes. Requires the second '
9589
'argument (output css filename).')
@@ -130,7 +124,6 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
130124
output_style=options.output_style,
131125
source_map_filename=source_map_filename,
132126
include_paths=options.include_paths,
133-
image_path=options.image_path,
134127
precision=options.precision
135128
)
136129
else:
@@ -140,7 +133,6 @@ def main(argv=sys.argv, stdout=sys.stdout, stderr=sys.stderr):
140133
filename=filename,
141134
output_style=options.output_style,
142135
include_paths=options.include_paths,
143-
image_path=options.image_path,
144136
precision=options.precision
145137
)
146138
except (IOError, OSError) as e:

0 commit comments

Comments
 (0)