forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
151 lines (133 loc) · 4.71 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
from __future__ import with_statement
import distutils.cmd
import os
import os.path
import shutil
import sys
import tempfile
import warnings
try:
from setuptools import Extension, setup
except ImportError:
from distribute_setup import use_setuptools
use_setuptools()
from setuptools import Extension, setup
version = '0.3.0'
libsass_sources = [
'ast.cpp', 'bind.cpp', 'constants.cpp', 'context.cpp', 'contextualize.cpp',
'copy_c_str.cpp', 'error_handling.cpp', 'eval.cpp', 'expand.cpp',
'extend.cpp', 'file.cpp', 'functions.cpp', 'inspect.cpp',
'output_compressed.cpp', 'output_nested.cpp', 'parser.cpp', 'prelexer.cpp',
'sass.cpp', 'sass_interface.cpp', 'to_c.cpp', 'to_string.cpp', 'units.cpp'
]
libsass_headers = [
'sass_interface.h', 'sass.h', 'win32/unistd.h'
]
if sys.platform == 'win32':
try:
os.environ['VS90COMNTOOLS'] = os.environ['VS110COMNTOOLS']
except KeyError:
warnings.warn('You probably need Visual Studio 2012 (11.0) or higher')
# Workaround http://bugs.python.org/issue4431 under Python <= 2.6
if sys.version_info < (2, 7):
def spawn(self, cmd):
from distutils.spawn import spawn
if cmd[0] == self.linker:
for i, val in enumerate(cmd):
if val.startswith('/MANIFESTFILE:'):
spawn(cmd[:i] + ['/MANIFEST'] + cmd[i:],
dry_run=self.dry_run)
return
spawn(cmd, dry_run=self.dry_run)
from distutils.msvc9compiler import MSVCCompiler
MSVCCompiler.spawn = spawn
flags = ['-I' + os.path.abspath('win32')]
link_flags = []
macros = {'LIBSASS_PYTHON_VERSION': '\\"' + version + '\\"'}
else:
flags = ['-fPIC', '-Wall', '-Wno-parentheses']
link_flags = ['-fPIC', '-lstdc++']
macros = {'LIBSASS_PYTHON_VERSION': '"' + version + '"'}
sass_extension = Extension(
'sass',
['pysass.c'] + libsass_sources,
define_macros=macros.items(),
depends=libsass_headers,
extra_compile_args=['-c', '-O2'] + flags,
extra_link_args=link_flags,
)
def readme():
try:
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
return f.read()
except IOError:
pass
class upload_doc(distutils.cmd.Command):
"""Uploads the documentation to GitHub pages."""
description = __doc__
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
path = tempfile.mkdtemp()
build = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'build', 'sphinx', 'html')
os.chdir(path)
os.system('git clone git@github.com:dahlia/libsass-python.git .')
os.system('git checkout gh-pages')
os.system('git rm -r .')
os.system('touch .nojekyll')
os.system('cp -r ' + build + '/* .')
os.system('git stage .')
os.system('git commit -a -m "Documentation updated."')
os.system('git push origin gh-pages')
shutil.rmtree(path)
setup(
name='libsass',
description='SASS for Python: '
'A straightforward binding of libsass for Python.',
long_description=readme(),
version=version,
ext_modules=[sass_extension],
packages=['sassutils'],
py_modules=['sassc', 'sasstests'],
package_data={'': ['README.rst', 'test/*.sass']},
scripts=['sassc.py'],
license='MIT License',
author='Hong Minhee',
author_email='minhee' '@' 'dahlia.kr',
url='http://dahlia.kr/libsass-python/',
entry_points={
'distutils.commands': [
'build_sass = sassutils.distutils:build_sass'
],
'distutils.setup_keywords': [
'sass_manifests = sassutils.distutils:validate_manifests'
],
'console_scripts': [
['sassc = sassc:main']
]
},
tests_require=['Werkzeug < 0.9'],
test_suite='sasstests.suite',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: C',
'Programming Language :: C++',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 2 :: Only',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Code Generators',
'Topic :: Software Development :: Compilers'
],
cmdclass={'upload_doc': upload_doc}
)