| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
""" |
| 4 |
Setup script for citeproc-py |
| 5 |
""" |
| 6 |
|
| 7 |
import io |
| 8 |
import os |
| 9 |
|
| 10 |
from setuptools import setup |
| 11 |
from setuptools.command.build_py import build_py |
| 12 |
from setuptools.command.develop import develop |
| 13 |
import versioneer |
| 14 |
|
| 15 |
PACKAGE = 'citeproc' |
| 16 |
BASE_PATH = os.path.dirname(os.path.abspath(__file__)) |
| 17 |
PACKAGE_ABSPATH = os.path.join(BASE_PATH, PACKAGE) |
| 18 |
VERSION_FILE = os.path.join(PACKAGE_ABSPATH, 'version.py') |
| 19 |
|
| 20 |
|
| 21 |
# All external commands are relative to BASE_PATH |
| 22 |
os.chdir(BASE_PATH) |
| 23 |
|
| 24 |
|
| 25 |
CSL_SCHEMA_RNC = 'citeproc/data/schema/schemas/styles/csl.rnc' |
| 26 |
|
| 27 |
def convert_rnc(): |
| 28 |
import rnc2rng |
| 29 |
|
| 30 |
filename_root, _ = os.path.splitext(CSL_SCHEMA_RNC) |
| 31 |
root = rnc2rng.load(CSL_SCHEMA_RNC) |
| 32 |
with io.open(filename_root + '.rng', 'w', encoding='utf-8') as rng: |
| 33 |
rnc2rng.dump(root, rng) |
| 34 |
|
| 35 |
|
| 36 |
class custom_build_py(build_py): |
| 37 |
def run(self): |
| 38 |
convert_rnc() |
| 39 |
build_py.run(self) |
| 40 |
|
| 41 |
|
| 42 |
class custom_develop(develop): |
| 43 |
def run(self): |
| 44 |
convert_rnc() |
| 45 |
develop.run(self) |
| 46 |
|
| 47 |
|
| 48 |
setup( |
| 49 |
version=versioneer.get_version(), |
| 50 |
cmdclass=versioneer.get_cmdclass({'build_py': custom_build_py, 'develop': custom_develop}), |
| 51 |
#test_suite='nose.collector', |
| 52 |
) |