From 3dfdafbdc1e6a558d76162c88cb0bf0dda51731c Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Fri, 22 Sep 2017 16:28:17 +0200 Subject: [PATCH 01/14] Use env var to allow system libsass --- setup.py | 162 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 92 insertions(+), 70 deletions(-) diff --git a/setup.py b/setup.py index 978f63a9..215ad4ad 100644 --- a/setup.py +++ b/setup.py @@ -14,55 +14,63 @@ from setuptools import Extension, setup -LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src') +try: + system_sass = bool(os.environ["SYSTEMSASS"]) +except KeyError: + system_sass = False -if ( - not os.path.isfile(os.path.join('libsass', 'Makefile')) and - os.path.isdir('.git') -): - print(file=sys.stderr) - print('Missing the libsass sumbodule. Try:', file=sys.stderr) - print(' git submodule update --init', file=sys.stderr) - print(file=sys.stderr) - exit(1) +sources = ['pysass.cpp'] +headers = [] +version_define='' +if not system_sass: + LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src') -# Determine the libsass version from the git checkout -if os.path.exists(os.path.join('libsass', '.git')): - proc = subprocess.Popen( - ( - 'git', '-C', 'libsass', 'describe', - '--abbrev=4', '--dirty', '--always', '--tags', - ), - stdout=subprocess.PIPE, - ) - out, _ = proc.communicate() - assert not proc.returncode, proc.returncode - with open('.libsass-upstream-version', 'wb') as libsass_version_file: - libsass_version_file.write(out) + if ( + not os.path.isfile(os.path.join('libsass', 'Makefile')) and + os.path.isdir('.git') + ): + print(file=sys.stderr) + print('Missing the libsass sumbodule. Try:', file=sys.stderr) + print(' git submodule update --init', file=sys.stderr) + print(file=sys.stderr) + exit(1) -# The version file should always exist at this point -with open('.libsass-upstream-version', 'rb') as libsass_version_file: - libsass_version = libsass_version_file.read().decode('UTF-8').strip() - if sys.platform == 'win32': - # This looks wrong, but is required for some reason :( - version_define = r'/DLIBSASS_VERSION="\"{0}\""'.format(libsass_version) - else: - version_define = '-DLIBSASS_VERSION="{0}"'.format(libsass_version) -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) + # Determine the libsass version from the git checkout + if os.path.exists(os.path.join('libsass', '.git')): + proc = subprocess.Popen( + ( + 'git', '-C', 'libsass', 'describe', + '--abbrev=4', '--dirty', '--always', '--tags', + ), + stdout=subprocess.PIPE, + ) + out, _ = proc.communicate() + assert not proc.returncode, proc.returncode + with open('.libsass-upstream-version', 'wb') as libsass_version_file: + libsass_version_file.write(out) + + # The version file should always exist at this point + with open('.libsass-upstream-version', 'rb') as libsass_version_file: + libsass_version = libsass_version_file.read().decode('UTF-8').strip() + if sys.platform == 'win32': + # This looks wrong, but is required for some reason :( + version_define = r'/DLIBSASS_VERSION="\"{0}\""'.format(libsass_version) + else: + version_define = '-DLIBSASS_VERSION="{0}"'.format(libsass_version) + + 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 @@ -108,31 +116,32 @@ def customize_compiler(compiler): flags.append( '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa ) - # 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_SOURCE_DIR, 'cencode.c') - cencode_body = '' - with open(cencode_path) as f: - cencode_body = f.read() - with open(cencode_path, 'w') as f: - f.write(''' - #ifdef __cplusplus - extern "C" { - #endif - ''') - f.write(cencode_body) - f.write(''' - #ifdef __cplusplus - } - #endif - ''') + if not system_sass: + # 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_SOURCE_DIR, 'cencode.c') + cencode_body = '' + with open(cencode_path) as f: + cencode_body = f.read() + with open(cencode_path, 'w') as f: + f.write(''' + #ifdef __cplusplus + extern "C" { + #endif + ''') + f.write(cencode_body) + f.write(''' + #ifdef __cplusplus + } + #endif + ''') - @atexit.register - def restore_cencode(): - if os.path.isfile(cencode_path): - with open(cencode_path, 'w') as f: - f.write(cencode_body) + @atexit.register + def restore_cencode(): + if os.path.isfile(cencode_path): + with open(cencode_path, 'w') as f: + f.write(cencode_body) flags = ['-c', '-O3'] + flags @@ -141,14 +150,27 @@ def restore_cencode(): else: link_flags = ['-fPIC', '-lstdc++'] +if system_sass: + libraries = ['sass'] + include_dirs=[] + extra_compile_args=flags + extra_link_args=link_flags +else: + libraries = [] + include_dirs=[os.path.join('.', 'libsass', 'include')] + extra_compile_args=flags + [version_define] + extra_link_args=link_flags + libraries=libraries + sources.sort() sass_extension = Extension( '_sass', sources, - include_dirs=[os.path.join('.', 'libsass', 'include')], + include_dirs=include_dirs, depends=headers, - extra_compile_args=flags + [version_define], + extra_compile_args=extra_compile_args, extra_link_args=link_flags, + libraries=libraries ) install_requires = ['six'] From 483364b97604a2f5ac15ae81bfbf37381f79976c Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Fri, 22 Sep 2017 16:41:09 +0200 Subject: [PATCH 02/14] minor fixes --- setup.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 215ad4ad..a9e85c5b 100644 --- a/setup.py +++ b/setup.py @@ -14,10 +14,7 @@ from setuptools import Extension, setup -try: - system_sass = bool(os.environ["SYSTEMSASS"]) -except KeyError: - system_sass = False +system_sass = bool(os.environ["SYSTEMSASS"], False) sources = ['pysass.cpp'] headers = [] @@ -152,25 +149,24 @@ def restore_cencode(): if system_sass: libraries = ['sass'] - include_dirs=[] - extra_compile_args=flags - extra_link_args=link_flags + include_dirs = [] + extra_compile_args = flags + extra_link_args = link_flags else: libraries = [] - include_dirs=[os.path.join('.', 'libsass', 'include')] - extra_compile_args=flags + [version_define] - extra_link_args=link_flags - libraries=libraries + include_dirs = [os.path.join('.', 'libsass', 'include')] + extra_compile_args = flags + [version_define] + extra_link_args = link_flags sources.sort() sass_extension = Extension( '_sass', sources, - include_dirs=include_dirs, - depends=headers, - extra_compile_args=extra_compile_args, - extra_link_args=link_flags, - libraries=libraries + include_dirs = include_dirs, + depends = headers, + extra_compile_args = extra_compile_args, + extra_link_args = link_flags, + libraries = libraries ) install_requires = ['six'] From 1105f09ce12d2a58fead8e937572a4fae52a0ef0 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Fri, 22 Sep 2017 16:50:09 +0200 Subject: [PATCH 03/14] minor fixes --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a9e85c5b..fccb2b44 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ from setuptools import Extension, setup -system_sass = bool(os.environ["SYSTEMSASS"], False) +system_sass = os.environ.get('SYSTEMSASS', False) sources = ['pysass.cpp'] headers = [] From 3107729935293507dc624f160a38564abf2b529f Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Fri, 22 Sep 2017 16:57:21 +0200 Subject: [PATCH 04/14] minor fixes --- setup.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index fccb2b44..536560eb 100644 --- a/setup.py +++ b/setup.py @@ -162,11 +162,11 @@ def restore_cencode(): sass_extension = Extension( '_sass', sources, - include_dirs = include_dirs, - depends = headers, - extra_compile_args = extra_compile_args, - extra_link_args = link_flags, - libraries = libraries + include_dirs=include_dirs, + depends=headers, + extra_compile_args=extra_compile_args, + extra_link_args=link_flags, + libraries=libraries ) install_requires = ['six'] From 9965820fc6650688b2dcd84085de416f0bf4ba2a Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Fri, 22 Sep 2017 17:15:48 +0200 Subject: [PATCH 05/14] minor fixes --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 536560eb..9a6e4ce0 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ sources = ['pysass.cpp'] headers = [] -version_define='' +version_define = '' if not system_sass: LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src') @@ -33,7 +33,6 @@ print(file=sys.stderr) exit(1) - # Determine the libsass version from the git checkout if os.path.exists(os.path.join('libsass', '.git')): proc = subprocess.Popen( @@ -53,7 +52,8 @@ libsass_version = libsass_version_file.read().decode('UTF-8').strip() if sys.platform == 'win32': # This looks wrong, but is required for some reason :( - version_define = r'/DLIBSASS_VERSION="\"{0}\""'.format(libsass_version) + version_define = r'/DLIBSASS_VERSION="\"{0}\""'.format( + libsass_version) else: version_define = '-DLIBSASS_VERSION="{0}"'.format(libsass_version) From b81a91ef8684c943df5859b7ea095cc1a48cf547 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 25 Sep 2017 16:29:14 +0200 Subject: [PATCH 06/14] rename SYSTEMSASS and merge if system_sass blocks --- setup.py | 201 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 115 insertions(+), 86 deletions(-) diff --git a/setup.py b/setup.py index 9a6e4ce0..45deeaeb 100644 --- a/setup.py +++ b/setup.py @@ -14,13 +14,49 @@ from setuptools import Extension, setup -system_sass = os.environ.get('SYSTEMSASS', False) +system_sass = os.environ.get('SYSTEM_SASS', False) sources = ['pysass.cpp'] headers = [] version_define = '' -if not system_sass: +if system_sass: + flags = [ + '-fPIC', '-std=gnu++0x', '-Wall', '-Wno-parentheses', '-Werror=switch', + ] + platform.mac_ver() + if platform.system() in ['Darwin', 'FreeBSD']: + os.environ.setdefault('CC', 'clang') + os.environ.setdefault('CXX', 'clang++') + orig_customize_compiler = distutils.sysconfig.customize_compiler + + def customize_compiler(compiler): + orig_customize_compiler(compiler) + compiler.compiler[0] = os.environ['CC'] + compiler.compiler_so[0] = os.environ['CXX'] + compiler.compiler_cxx[0] = os.environ['CXX'] + compiler.linker_so[0] = os.environ['CXX'] + return compiler + distutils.sysconfig.customize_compiler = customize_compiler + flags.append('-stdlib=libc++') + if platform.system() == 'Darwin': + flags.append('-mmacosx-version-min=10.7',) + if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): + flags.append( + '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa + ) + + flags = ['-c', '-O3'] + flags + + if platform.system() == 'FreeBSD': + link_flags = ['-fPIC', '-lc++'] + else: + link_flags = ['-fPIC', '-lstdc++'] + libraries = ['sass'] + include_dirs = [] + extra_compile_args = flags + extra_link_args = link_flags +else: LIBSASS_SOURCE_DIR = os.path.join('libsass', 'src') if ( @@ -69,94 +105,87 @@ elif filename.endswith('.h'): headers.append(filename) -if sys.platform == 'win32': - from distutils.msvc9compiler import get_build_version - vscomntools_env = 'VS{0}{1}COMNTOOLS'.format( - int(get_build_version()), - int(get_build_version() * 10) % 10 - ) - try: - os.environ[vscomntools_env] = os.environ['VS140COMNTOOLS'] - except KeyError: - distutils.log.warn('You probably need Visual Studio 2015 (14.0) ' - 'or higher') - from distutils import msvccompiler, msvc9compiler - if msvccompiler.get_build_version() < 14.0: - msvccompiler.get_build_version = lambda: 14.0 - if get_build_version() < 14.0: - msvc9compiler.get_build_version = lambda: 14.0 - msvc9compiler.VERSION = 14.0 - flags = ['/Od', '/EHsc', '/MT'] - link_flags = [] -else: - flags = [ - '-fPIC', '-std=gnu++0x', '-Wall', '-Wno-parentheses', '-Werror=switch', - ] - platform.mac_ver() - if platform.system() in ['Darwin', 'FreeBSD']: - os.environ.setdefault('CC', 'clang') - os.environ.setdefault('CXX', 'clang++') - orig_customize_compiler = distutils.sysconfig.customize_compiler - - def customize_compiler(compiler): - orig_customize_compiler(compiler) - compiler.compiler[0] = os.environ['CC'] - compiler.compiler_so[0] = os.environ['CXX'] - compiler.compiler_cxx[0] = os.environ['CXX'] - compiler.linker_so[0] = os.environ['CXX'] - return compiler - distutils.sysconfig.customize_compiler = customize_compiler - flags.append('-stdlib=libc++') - if platform.system() == 'Darwin': - flags.append('-mmacosx-version-min=10.7',) - if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): - flags.append( - '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa - ) - if not system_sass: - # 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_SOURCE_DIR, 'cencode.c') - cencode_body = '' - with open(cencode_path) as f: - cencode_body = f.read() - with open(cencode_path, 'w') as f: - f.write(''' - #ifdef __cplusplus - extern "C" { - #endif - ''') - f.write(cencode_body) - f.write(''' - #ifdef __cplusplus - } - #endif - ''') + if sys.platform == 'win32': + from distutils.msvc9compiler import get_build_version + vscomntools_env = 'VS{0}{1}COMNTOOLS'.format( + int(get_build_version()), + int(get_build_version() * 10) % 10 + ) + try: + os.environ[vscomntools_env] = os.environ['VS140COMNTOOLS'] + except KeyError: + distutils.log.warn('You probably need Visual Studio 2015 (14.0) ' + 'or higher') + from distutils import msvccompiler, msvc9compiler + if msvccompiler.get_build_version() < 14.0: + msvccompiler.get_build_version = lambda: 14.0 + if get_build_version() < 14.0: + msvc9compiler.get_build_version = lambda: 14.0 + msvc9compiler.VERSION = 14.0 + flags = ['/Od', '/EHsc', '/MT'] + link_flags = [] + else: + flags = [ + '-fPIC', '-std=gnu++0x', '-Wall', '-Wno-parentheses', '-Werror=switch', + ] + platform.mac_ver() + if platform.system() in ['Darwin', 'FreeBSD']: + os.environ.setdefault('CC', 'clang') + os.environ.setdefault('CXX', 'clang++') + orig_customize_compiler = distutils.sysconfig.customize_compiler - @atexit.register - def restore_cencode(): - if os.path.isfile(cencode_path): - with open(cencode_path, 'w') as f: - f.write(cencode_body) + def customize_compiler(compiler): + orig_customize_compiler(compiler) + compiler.compiler[0] = os.environ['CC'] + compiler.compiler_so[0] = os.environ['CXX'] + compiler.compiler_cxx[0] = os.environ['CXX'] + compiler.linker_so[0] = os.environ['CXX'] + return compiler + distutils.sysconfig.customize_compiler = customize_compiler + flags.append('-stdlib=libc++') + if platform.system() == 'Darwin': + flags.append('-mmacosx-version-min=10.7',) + if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): + flags.append( + '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa + ) + if not system_sass: + # 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_SOURCE_DIR, 'cencode.c') + cencode_body = '' + with open(cencode_path) as f: + cencode_body = f.read() + with open(cencode_path, 'w') as f: + f.write(''' + #ifdef __cplusplus + extern "C" { + #endif + ''') + f.write(cencode_body) + f.write(''' + #ifdef __cplusplus + } + #endif + ''') - flags = ['-c', '-O3'] + flags + @atexit.register + def restore_cencode(): + if os.path.isfile(cencode_path): + with open(cencode_path, 'w') as f: + f.write(cencode_body) - if platform.system() == 'FreeBSD': - link_flags = ['-fPIC', '-lc++'] - else: - link_flags = ['-fPIC', '-lstdc++'] + flags = ['-c', '-O3'] + flags -if system_sass: - libraries = ['sass'] - include_dirs = [] - extra_compile_args = flags - extra_link_args = link_flags -else: - libraries = [] - include_dirs = [os.path.join('.', 'libsass', 'include')] - extra_compile_args = flags + [version_define] - extra_link_args = link_flags + if platform.system() == 'FreeBSD': + link_flags = ['-fPIC', '-lc++'] + else: + link_flags = ['-fPIC', '-lstdc++'] + libraries = [] + include_dirs = [os.path.join('.', 'libsass', 'include')] + extra_compile_args = flags + [version_define] + extra_link_args = link_flags sources.sort() sass_extension = Extension( From 0403d08e46abccea1f18d45c64596a115608698e Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 25 Sep 2017 16:41:45 +0200 Subject: [PATCH 07/14] debugging push (windows 2.7) --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 45deeaeb..509c1622 100644 --- a/setup.py +++ b/setup.py @@ -184,10 +184,12 @@ def restore_cencode(): link_flags = ['-fPIC', '-lstdc++'] libraries = [] include_dirs = [os.path.join('.', 'libsass', 'include')] + print('Assigned include_dirs = %s' % (include_dirs)) extra_compile_args = flags + [version_define] extra_link_args = link_flags sources.sort() +print('Include_dirs = %s' % (include_dirs)) sass_extension = Extension( '_sass', sources, From 1b739030a6f459af2af31a1ad39bdda28e1ba0e7 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 25 Sep 2017 16:46:59 +0200 Subject: [PATCH 08/14] bugfixes --- setup.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 509c1622..804d94ef 100644 --- a/setup.py +++ b/setup.py @@ -178,18 +178,17 @@ def restore_cencode(): flags = ['-c', '-O3'] + flags - if platform.system() == 'FreeBSD': - link_flags = ['-fPIC', '-lc++'] - else: - link_flags = ['-fPIC', '-lstdc++'] - libraries = [] - include_dirs = [os.path.join('.', 'libsass', 'include')] - print('Assigned include_dirs = %s' % (include_dirs)) - extra_compile_args = flags + [version_define] - extra_link_args = link_flags + if platform.system() == 'FreeBSD': + link_flags = ['-fPIC', '-lc++'] + else: + link_flags = ['-fPIC', '-lstdc++'] + +libraries = [] +include_dirs = [os.path.join('.', 'libsass', 'include')] +extra_compile_args = flags + [version_define] +extra_link_args = link_flags sources.sort() -print('Include_dirs = %s' % (include_dirs)) sass_extension = Extension( '_sass', sources, From c1db77d16ae70b2f668bc8d5b1d4844f58e18f07 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 25 Sep 2017 16:49:22 +0200 Subject: [PATCH 09/14] bugfixes --- setup.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 804d94ef..f909d571 100644 --- a/setup.py +++ b/setup.py @@ -178,15 +178,15 @@ def restore_cencode(): flags = ['-c', '-O3'] + flags - if platform.system() == 'FreeBSD': - link_flags = ['-fPIC', '-lc++'] - else: - link_flags = ['-fPIC', '-lstdc++'] + if platform.system() == 'FreeBSD': + link_flags = ['-fPIC', '-lc++'] + else: + link_flags = ['-fPIC', '-lstdc++'] -libraries = [] -include_dirs = [os.path.join('.', 'libsass', 'include')] -extra_compile_args = flags + [version_define] -extra_link_args = link_flags + libraries = [] + include_dirs = [os.path.join('.', 'libsass', 'include')] + extra_compile_args = flags + [version_define] + extra_link_args = link_flags sources.sort() sass_extension = Extension( From 434157fddb500e32e5693adcb1107eb6f545fdf9 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 25 Sep 2017 17:20:36 +0200 Subject: [PATCH 10/14] minor changes --- setup.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index f909d571..144198e2 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,8 @@ def customize_compiler(compiler): flags.append('-mmacosx-version-min=10.7',) if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): flags.append( - '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa + '-Wno-error=unused-command-line-'+ + 'argument-hard-error-in-future', # noqa ) flags = ['-c', '-O3'] + flags @@ -126,7 +127,8 @@ def customize_compiler(compiler): link_flags = [] else: flags = [ - '-fPIC', '-std=gnu++0x', '-Wall', '-Wno-parentheses', '-Werror=switch', + '-fPIC', '-std=gnu++0x', '-Wall', + '-Wno-parentheses', '-Werror=switch', ] platform.mac_ver() if platform.system() in ['Darwin', 'FreeBSD']: @@ -145,14 +147,17 @@ def customize_compiler(compiler): flags.append('-stdlib=libc++') if platform.system() == 'Darwin': flags.append('-mmacosx-version-min=10.7',) - if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): + if tuple( + map(int, platform.mac_ver()[0].split('.')) + ) >= (10, 9): flags.append( - '-Wno-error=unused-command-line-argument-hard-error-in-future', # noqa + '-Wno-error=unused-command-line-'+ + 'argument-hard-error-in-future', # noqa ) if not system_sass: # Dirty workaround to avoid link error... - # Python distutils doesn't provide any way to configure different - # flags for each cc and c++. + # Python distutils doesn't provide any way + # to configure different flags for each cc and c++. cencode_path = os.path.join(LIBSASS_SOURCE_DIR, 'cencode.c') cencode_body = '' with open(cencode_path) as f: From 3b7935ae5742a7886ec9c37f44e3ee7bf76c54b6 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Tue, 26 Sep 2017 14:37:20 +0200 Subject: [PATCH 11/14] minor changes --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 144198e2..52b6a547 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def customize_compiler(compiler): flags.append('-mmacosx-version-min=10.7',) if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): flags.append( - '-Wno-error=unused-command-line-'+ + '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa ) @@ -149,9 +149,9 @@ def customize_compiler(compiler): flags.append('-mmacosx-version-min=10.7',) if tuple( map(int, platform.mac_ver()[0].split('.')) - ) >= (10, 9): + ) >= (10, 9): flags.append( - '-Wno-error=unused-command-line-'+ + '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa ) if not system_sass: From 99cd9b1c8533793897657bb8831a9984e78f41e4 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Tue, 26 Sep 2017 15:10:38 +0200 Subject: [PATCH 12/14] minor changes --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 52b6a547..c8ebe082 100644 --- a/setup.py +++ b/setup.py @@ -148,8 +148,8 @@ def customize_compiler(compiler): if platform.system() == 'Darwin': flags.append('-mmacosx-version-min=10.7',) if tuple( - map(int, platform.mac_ver()[0].split('.')) - ) >= (10, 9): + map(int, platform.mac_ver()[0].split('.')) + ) >= (10, 9): flags.append( '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa From 237ceec5ccf513aa4d70120562e4e9278c117c1d Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Tue, 26 Sep 2017 15:22:51 +0200 Subject: [PATCH 13/14] minor changes --- setup.py | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/setup.py b/setup.py index c8ebe082..faa83b8b 100644 --- a/setup.py +++ b/setup.py @@ -148,38 +148,37 @@ def customize_compiler(compiler): if platform.system() == 'Darwin': flags.append('-mmacosx-version-min=10.7',) if tuple( - map(int, platform.mac_ver()[0].split('.')) + map(int, platform.mac_ver()[0].split('.')) ) >= (10, 9): flags.append( '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa ) - if not system_sass: - # 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_SOURCE_DIR, 'cencode.c') - cencode_body = '' - with open(cencode_path) as f: - cencode_body = f.read() - with open(cencode_path, 'w') as f: - f.write(''' - #ifdef __cplusplus - extern "C" { - #endif - ''') - f.write(cencode_body) - f.write(''' - #ifdef __cplusplus - } - #endif - ''') - - @atexit.register - def restore_cencode(): - if os.path.isfile(cencode_path): - with open(cencode_path, 'w') as f: - f.write(cencode_body) + # 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_SOURCE_DIR, 'cencode.c') + cencode_body = '' + with open(cencode_path) as f: + cencode_body = f.read() + with open(cencode_path, 'w') as f: + f.write(''' + #ifdef __cplusplus + extern "C" { + #endif + ''') + f.write(cencode_body) + f.write(''' + #ifdef __cplusplus + } + #endif + ''') + + @atexit.register + def restore_cencode(): + if os.path.isfile(cencode_path): + with open(cencode_path, 'w') as f: + f.write(cencode_body) flags = ['-c', '-O3'] + flags From f93219237038e66b25705ff657f89dd36270638c Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Wed, 27 Sep 2017 09:27:08 +0200 Subject: [PATCH 14/14] simpler line size reduction --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index faa83b8b..bb798b38 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,8 @@ def customize_compiler(compiler): flags.append('-stdlib=libc++') if platform.system() == 'Darwin': flags.append('-mmacosx-version-min=10.7',) - if tuple(map(int, platform.mac_ver()[0].split('.'))) >= (10, 9): + macver = tuple(map(int, platform.mac_ver()[0].split('.'))) + if macver >= (10, 9): flags.append( '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa @@ -147,9 +148,8 @@ def customize_compiler(compiler): flags.append('-stdlib=libc++') if platform.system() == 'Darwin': flags.append('-mmacosx-version-min=10.7',) - if tuple( - map(int, platform.mac_ver()[0].split('.')) - ) >= (10, 9): + macver = tuple(map(int, platform.mac_ver()[0].split('.'))) + if macver >= (10, 9): flags.append( '-Wno-error=unused-command-line-' + 'argument-hard-error-in-future', # noqa