Skip to content

Libsass 3.3 betas #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
include libsass/*.h
include libsass/*.hpp
include libsass/*.cpp
recursive-include libsas *.c
recursive-include libsas *.cpp
recursive-include libsas *.h
recursive-include libsas *.hpp
include libsass/Makefile
include libsass/Makefile.am
include libsass/b64/*.h
include libsass/utf8/*.h
include win32/*.h
include test/*.scss
include README.rst
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
# $ make -j 4 && python -m unittest sasstests

PY_HEADERS := -I/usr/include/python2.7
C_SOURCES := $(wildcard libsass/*.c)
C_OBJECTS = $(patsubst libsass/%.c,build2/libsass/c/%.o,$(C_SOURCES))
CPP_SOURCES := $(wildcard libsass/*.cpp)
CPP_OBJECTS = $(patsubst libsass/%.cpp,build2/libsass/cpp/%.o,$(CPP_SOURCES))
C_SOURCES := $(wildcard libsass/src/*.c)
C_OBJECTS = $(patsubst libsass/src/%.c,build2/libsass/c/%.o,$(C_SOURCES))
CPP_SOURCES := $(wildcard libsass/src/*.cpp)
CPP_OBJECTS = $(patsubst libsass/src/%.cpp,build2/libsass/cpp/%.o,$(CPP_SOURCES))

all: _sass.so

build2/libsass/c/%.o: libsass/%.c
build2/libsass/c/%.o: libsass/src/%.c
@mkdir -p build2/libsass/c/
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses

build2/libsass/cpp/%.o: libsass/%.cpp
build2/libsass/cpp/%.o: libsass/src/%.cpp
@mkdir -p build2/libsass/cpp/
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses

build2/pysass.o: pysass.cpp
@mkdir -p build2
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I./libsass/include $(PY_HEADERS) -c $^ -o $@ -c -O2 -fPIC -std=c++0x -Wall -Wno-parentheses

_sass.so: $(C_OBJECTS) $(CPP_OBJECTS) build2/pysass.o
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro $^ -L./libsass -o $@ -fPIC -lstdc++
Expand Down
2 changes: 1 addition & 1 deletion libsass
Submodule libsass updated 155 files
2 changes: 1 addition & 1 deletion pysass.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string.h>
#include <Python.h>
#include "sass_context.h"
#include <sass/context.h>

#if PY_MAJOR_VERSION >= 3
#define PySass_IF_PY3(three, two) (three)
Expand Down
23 changes: 12 additions & 11 deletions sasstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ def normalize_path(path):
'version': 3,
'file': 'test/a.css',
'sources': ['test/a.scss'],
'sourcesContent': [],
'names': [],
'mappings': ';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;;'
'EAEJ,IAAI,CAAC,CAAC,CAAJ;IACA,KAAK,EAAE,IAAK,GADX',
'mappings': (
';AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAQzB;;EALD,IAAI,CAEF,CAAC,'
'CAAC;IACA,KAAK,EAAE,IAAK,GACb'
),
}

B_EXPECTED_CSS = '''\
Expand Down Expand Up @@ -457,10 +458,10 @@ def test_build_one(self):
'version': 3,
'file': '../test/b.css',
'sources': ['../test/b.scss'],
'sourcesContent': [],
'names': [],
'mappings': ';AACE,CAAC,CAAC,CAAC,CAAD;'
'EACA,SAAS,EAAE,IAAK,GADf',
'mappings': (
';AAAA,CAAC,CACC,CAAC,CAAC;EACA,SAAS,EAAE,IAAK,GACjB'
),
},
os.path.join(d, 'css', 'b.scss.css.map')
)
Expand All @@ -476,11 +477,11 @@ def test_build_one(self):
'version': 3,
'file': '../test/d.css',
'sources': ['../test/d.scss'],
'sourcesContent': [],
'names': [],
'mappings': ';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAGpB;'
';EAEJ,IAAI,CAAC,CAAC,CAAJ'
';IACA,IAAI,EAAE,0BAA2B,GADhC',
'mappings': (
';;AAKA,IAAI,CAAC;EAHH,gBAAgB,EAAE,KAAM,GAQzB;;EALD,'
'IAAI,CAEF,CAAC,CAAC;IACA,IAAI,EAAE,0BAA2B,GAClC'
),
},
os.path.join(d, 'css', 'd.scss.css.map')
)
Expand Down Expand Up @@ -757,7 +758,7 @@ def test_error(self):
except sass.CompileError as e:
msg, = e.args
assert msg.decode('UTF-8').startswith(
'Error: invalid property name'
'Error: Invalid CSS after '
), msg
return
except Exception as e:
Expand Down
34 changes: 19 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@
use_setuptools()
from setuptools import Extension, setup

LIBSASS_DIR = 'libsass'
LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src')


if not os.path.isfile(os.path.join(LIBSASS_DIR, 'Makefile')) and \
if not os.path.isfile(os.path.join('libsass', 'Makefile')) and \
os.path.isdir('.git'):
print(file=sys.stderr)
print('You seem to miss initializing submodules; '
'try the following command', file=sys.stderr)
print(' git submodule update --init', file=sys.stderr)
print(file=sys.stderr)

libsass_files = os.listdir(LIBSASS_DIR)
libsass_sources = [f for f in libsass_files if f.endswith(('.c', '.cpp'))]
libsass_headers = [f for f in libsass_files if f.endswith(('.h', '.hpp'))]
headers = [os.path.join(LIBSASS_DIR, f) for f in libsass_headers]
sources = [os.path.join(LIBSASS_DIR, f) for f in libsass_sources]
sources.append('pysass.cpp')
sources = ['pysass.cpp']
headers = []
for directory in (
os.path.join('libsass', 'src'),
os.path.join('libsass', 'include')
):
for pth, _, filenames in os.walk(directory):
for filename in filenames:
filename = os.path.join(pth, filename)
if filename.endswith(('.c', '.cpp')):
sources.append(filename)
elif filename.endswith('.h'):
headers.append(filename)

if sys.platform == 'win32':
from distutils.msvc9compiler import get_build_version
Expand Down Expand Up @@ -98,7 +104,7 @@ def customize_compiler(compiler):
# Dirty workaround to avoid link error...
# Python distutils doesn't provide any way to configure different
# flags for each cc and c++.
cencode_path = os.path.join(LIBSASS_DIR, 'cencode.c')
cencode_path = os.path.join(LIBSASS_SOURCE_DIR, 'cencode.c')
cencode_body = ''
with open(cencode_path) as f:
cencode_body = f.read()
Expand Down Expand Up @@ -131,9 +137,9 @@ def restore_cencode():
sass_extension = Extension(
'_sass',
sources,
library_dirs=[os.path.join('.', LIBSASS_DIR)],
include_dirs=[os.path.join('.', LIBSASS_DIR)],
depends=libsass_headers,
library_dirs=[os.path.join('.', 'libsass', 'src')],
include_dirs=[os.path.join('.', 'libsass', 'include')],
depends=headers,
extra_compile_args=flags,
extra_link_args=link_flags,
)
Expand Down Expand Up @@ -216,8 +222,6 @@ def run(self):
package_data={
'': [
'README.rst',
os.path.join(LIBSASS_DIR, 'Makefile'),
os.path.join(LIBSASS_DIR, 'Makefile.am'),
'test/*.sass'
]
},
Expand Down