forked from FSX/misaka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
109 lines (91 loc) · 3.2 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
import os
import glob
import shutil
import os.path
try:
from setuptools import setup, Extension, Command
except ImportError:
from distutils.core import setup, Extension, Command
dirname = os.path.dirname(os.path.abspath(__file__))
class BaseCommand(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
class CleanCommand(BaseCommand):
description = 'cleanup directories created by packaging and build processes'
def run(self):
for path in ['build', 'dist', 'misaka.egg-info', 'docs/_build']:
if os.path.exists(path):
path = os.path.join(dirname, path)
print('removing %s' % path)
shutil.rmtree(path)
class CythonCommand(BaseCommand):
description = 'compile Cython files(s) into C file(s)'
def run(self):
try:
from Cython.Compiler.Main import compile
path = os.path.join(dirname, 'src', 'misaka.pyx')
print('compiling %s' % path)
compile(path)
except ImportError:
print('Cython is not installed. Please install Cython first.')
class VendorCommand(BaseCommand):
description = 'update Sundown files. Use `git submodule init`, '\
'`git submodule update` and `git submodule foreach git pull origin master`'\
' to the most recent files'
def run(self):
files = []
dest = os.path.join(dirname, 'src/sundown')
for path in ['vendor/sundown/src/*', 'vendor/sundown/html/*']:
files += glob.glob(os.path.join(dirname, path))
for path in files:
if os.path.exists(path):
print('copy %s -> %s' % (path, dest))
shutil.copy(path, dest)
class TestCommand(BaseCommand):
description = 'run unit tests'
def run(self):
os.system('python tests/misaka_test.py')
setup(
name='misaka',
version='1.0.3',
description='The Python binding for Sundown, a markdown parsing library.',
author='Frank Smit',
author_email='[email protected]',
url='https://misaka.61924.nl/',
license='MIT',
long_description=open(os.path.join(dirname, 'README.rst')).read(),
scripts=['scripts/misaka'],
cmdclass={
'clean': CleanCommand,
'compile_cython': CythonCommand,
'update_vendor': VendorCommand,
'test': TestCommand
},
ext_modules=[Extension('misaka', [
'src/misaka.c',
'src/wrapper.c',
'src/sundown/stack.c',
'src/sundown/buffer.c',
'src/sundown/markdown.c',
'src/sundown/html.c',
'src/sundown/html_smartypants.c',
'src/sundown/houdini_href_e.c',
'src/sundown/houdini_html_e.c',
'src/sundown/autolink.c'
])],
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: C',
'Programming Language :: Cython',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.2',
'Topic :: Text Processing :: Markup',
'Topic :: Text Processing :: Markup :: HTML',
'Topic :: Utilities'
]
)