-
Notifications
You must be signed in to change notification settings - Fork 12
/
setup.py
executable file
·154 lines (126 loc) · 4.03 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
152
153
154
#!/usr/bin/env python
"""Setup.py for eulxml package"""
from distutils.command.build_py import build_py
from distutils.command.clean import clean
from distutils.command.sdist import sdist
from distutils.core import Command
import os
import sys
import shutil
from setuptools import setup, find_packages
import eulxml
class GenerateXmlCatalog(Command):
'''Custom setup command to generate fresh catalog and schemas'''
user_options = []
def initialize_options(self):
"""init options"""
pass
def finalize_options(self):
"""finalize options"""
pass
def run(self):
from eulxml.catalog import generate_catalog
generate_catalog()
def generate_catalog_if_needed():
# helper method to check if catalog is present, and generate if not
if not os.path.exists(eulxml.XMLCATALOG_FILE):
from eulxml.catalog import generate_catalog
print("Cenerating XML catalog...")
generate_catalog()
class CleanSchemaData(clean):
"""Custom cleanup command to delete build and schema files"""
description = "Custom clean command; remove schema files and XML catalog"
def run(self):
# remove schema data and then do any other normal cleaning
try:
shutil.rmtree(eulxml.XMLCATALOG_DIR)
except OSError:
pass
clean.run(self)
class BuildPyWithPly(build_py):
"""Use ply to generate parsetab and lextab modules."""
def run(self):
# importing this forces ply to generate parsetab/lextab
import eulxml.xpath.core
generate_catalog_if_needed()
build_py.run(self)
class SdistWithCatalog(sdist):
"""Extend sdist command to ensure schema catalog is included."""
def run(self):
generate_catalog_if_needed()
sdist.run(self)
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Text Processing :: Markup :: XML',
]
LONG_DESCRIPTION = None
try:
# read the description if it's there
with open('README.rst') as desc_f:
LONG_DESCRIPTION = desc_f.read()
except:
pass
dev_requirements = [
'sphinx>=1.3.5',
'coverage',
'Django<4',
'rdflib>=3.0',
'mock',
'nose',
'tox',
'requests',
]
# NOTE: dev requirements should be duplicated in pip-dev-req.txt
# for generating documentation on readthedocs.org
# unittest2 should only be included for py2.6
if sys.version_info < (2, 7):
dev_requirements.append('unittest2')
setup(
cmdclass={
'build_py': BuildPyWithPly,
'clean': CleanSchemaData,
'sdist': SdistWithCatalog,
'xmlcatalog': GenerateXmlCatalog
},
name='eulxml',
version=eulxml.__version__,
author='Emory University Libraries',
author_email='[email protected]',
url='https://github.com/emory-libraries/eulxml',
license='Apache License, Version 2.0',
packages=find_packages(),
setup_requires=[
'ply>=3.8',
],
install_requires=[
'ply>=3.8',
'lxml>=3.4',
'six>=1.10',
],
extras_require={
'django': ['Django<4'],
'rdf': ['rdflib>=3.0'],
'dev': dev_requirements
},
package_data={'eulxml': [
# include schema catalog and all downloaded schemas in the package
'%s/*' % eulxml.SCHEMA_DATA_DIR
]},
description='XPath-based XML data binding, with Django form support',
long_description=LONG_DESCRIPTION,
classifiers=CLASSIFIERS,
)