Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
54 lines (45 sloc) 1.435 kb
from distutils.spawn import find_executable
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import re
import os
import subprocess
import fnmatch
def c_files_in(directory):
paths = []
names = os.listdir(directory)
for f in fnmatch.filter(names, '*.c'):
paths.append(os.path.join(directory, f))
return paths
def process_gperf_file(gperf_file, output_file):
if not find_executable("gperf"):
raise Exception("Couldn't find `gperf`, is it installed?")
subprocess.check_call(["gperf", gperf_file, "--output-file=%s" % output_file])
version = None
version_re = re.compile(r'^#define\s+SNUDOWN_VERSION\s+"([^"]+)"$')
with open('snudown.c', 'r') as f:
for line in f:
m = version_re.match(line)
if m:
version = m.group(1)
assert version
class GPerfingBuildExt(build_ext):
def run(self):
process_gperf_file("src/html_entities.gperf", "src/html_entities.h")
build_ext.run(self)
setup(
name='snudown',
version=version,
author='Vicent Marti',
author_email='vicent@github.com',
license='MIT',
test_suite="test_snudown.test_snudown",
cmdclass={'build_ext': GPerfingBuildExt,},
ext_modules=[
Extension(
name='snudown',
sources=['snudown.c'] + c_files_in('src/') + c_files_in('html/'),
include_dirs=['src', 'html']
)
],
)
Jump to Line
Something went wrong with that request. Please try again.