1#!/usr/bin/env python
2
3# Copyright (c) 2006-2021  Andrey Golovizin
4#
5# Permission is hereby granted, free of charge, to any person obtaining
6# a copy of this software and associated documentation files (the
7# "Software"), to deal in the Software without restriction, including
8# without limitation the rights to use, copy, modify, merge, publish,
9# distribute, sublicense, and/or sell copies of the Software, and to
10# permit persons to whom the Software is furnished to do so, subject to
11# the following conditions:
12#
13# The above copyright notice and this permission notice shall be
14# included in all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24
25import os
26import sys
27from collections import OrderedDict
28from distutils.command.sdist import sdist
29from distutils.dep_util import newer
30
31from pybtex import __version__
32from setuptools import find_packages, setup
33
34progname = 'pybtex'
35
36
37class Sdist(sdist):
38
39    def run(self):
40        from pybtex.database.convert import convert
41        bibtex_yaml = os.path.join('examples', 'xampl.yaml')
42        bibtexml = os.path.join('examples', 'xampl.bibtexml')
43        bibtex = os.path.join('examples', 'xampl.bib')
44        if not os.path.exists(bibtex_yaml) or newer(bibtex, bibtex_yaml):
45            convert(bibtex, bibtex_yaml)
46        if not os.path.exists(bibtexml) or newer(bibtex, bibtexml):
47            convert(bibtex, bibtexml)
48
49        sys.path.insert(0, os.path.join(ROOT, 'docs'))
50        from pybtex_doctools.man import generate_manpages
51        generate_manpages(os.path.join(ROOT, 'docs'))
52
53        sdist.run(self)
54
55
56ROOT = os.path.abspath(os.path.dirname(__file__))
57README = open(os.path.join(ROOT, 'README')).read()
58
59install_requires = ['PyYAML>=3.01', 'latexcodec>=1.0.4', 'six']
60extras_require = {
61    'test': ['pytest'],
62}
63
64setup(
65    name=progname,
66    version=__version__,
67    description='A BibTeX-compatible bibliography processor in Python',
68    long_description=README,
69    author='Andrey Golovizin',
70    author_email='ag@sologoc.com',
71    url='https://pybtex.org/',
72    project_urls=OrderedDict((
73        ('Documentation', 'https://docs.pybtex.org/'),
74        ('Code', 'https://bitbucket.org/pybtex-devs/pybtex'),
75        ('Issue tracker', 'https://bitbucket.org/pybtex-devs/pybtex/issues'),
76    )),
77    license='MIT',
78    platforms=['platform-independent'],
79    classifiers=[
80        'Development Status :: 4 - Beta',
81        'Environment :: Console',
82        'Intended Audience :: End Users/Desktop',
83        'License :: OSI Approved :: MIT License',
84        'Operating System :: OS Independent',
85        'Programming Language :: Python',
86        'Programming Language :: Python :: 2',
87        'Programming Language :: Python :: 3',
88        'Topic :: Text Processing :: Markup :: LaTeX',
89        'Topic :: Text Processing :: Markup :: XML',
90        'Topic :: Utilities',
91    ],
92    install_requires=install_requires,
93    extras_require=extras_require,
94    python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*',
95    packages=find_packages(exclude=['docs']),
96    include_package_data=True,
97    cmdclass={'sdist': Sdist},
98    entry_points={
99        'console_scripts': [
100            'pybtex = pybtex.__main__:main',
101            'pybtex-convert = pybtex.database.convert.__main__:main',
102            'pybtex-format = pybtex.database.format.__main__:main',
103        ],
104        'pybtex.database.input': [
105            'bibtex = pybtex.database.input.bibtex:Parser',
106            'bibtexml = pybtex.database.input.bibtexml:Parser',
107            'yaml = pybtex.database.input.bibyaml:Parser',
108        ],
109        'pybtex.database.input.aliases': [
110            'bibyaml = pybtex.database.input.bibyaml:Parser',
111        ],
112        'pybtex.database.input.suffixes': [
113            '.bib = pybtex.database.input.bibtex:Parser',
114            '.xml = pybtex.database.input.bibtexml:Parser',
115            '.bibtexml = pybtex.database.input.bibtexml:Parser',
116            '.bibyaml = pybtex.database.input.bibyaml:Parser',
117            '.yaml = pybtex.database.input.bibyaml:Parser',
118        ],
119        'pybtex.database.output': [
120            'bibtex = pybtex.database.output.bibtex:Writer',
121            'bibtexml = pybtex.database.output.bibtexml:Writer',
122            'yaml = pybtex.database.output.bibyaml:Writer',
123        ],
124        'pybtex.database.output.aliases': [
125            'bibyaml = pybtex.database.output.bibyaml:Writer',
126        ],
127        'pybtex.database.output.suffixes': [
128            '.bib = pybtex.database.output.bibtex:Writer',
129            '.xml = pybtex.database.output.bibtexml:Writer',
130            '.bibtexml = pybtex.database.output.bibtexml:Writer',
131            '.bibyaml = pybtex.database.output.bibyaml:Writer',
132            '.yaml = pybtex.database.output.bibyaml:Writer',
133        ],
134        'pybtex.backends': [
135            'latex = pybtex.backends.latex:Backend',
136            'html = pybtex.backends.html:Backend',
137            'plaintext = pybtex.backends.plaintext:Backend',
138            'markdown = pybtex.backends.markdown:Backend',
139        ],
140        'pybtex.backends.aliases': [
141            'text = pybtex.backends.plaintext:Backend',
142            'md = pybtex.backends.markdown:Backend',
143        ],
144        'pybtex.backends.suffixes': [
145            '.bbl = pybtex.backends.latex:Backend',
146            '.tex = pybtex.backends.latex:Backend',
147            '.latex = pybtex.backends.latex:Backend',
148            '.html = pybtex.backends.html:Backend',
149            '.txt = pybtex.backends.plaintext:Backend',
150            '.md = pybtex.backends.markdown:Backend',
151        ],
152        'pybtex.style.labels': [
153            'number = pybtex.style.labels.number:LabelStyle',
154            'alpha = pybtex.style.labels.alpha:LabelStyle',
155        ],
156        'pybtex.style.names': [
157            'plain = pybtex.style.names.plain:NameStyle',
158            'lastfirst = pybtex.style.names.lastfirst:NameStyle',
159        ],
160        'pybtex.style.names.aliases': [
161            'last_first = pybtex.style.names.lastfirst:NameStyle',
162        ],
163        'pybtex.style.sorting': [
164            'none = pybtex.style.sorting.none:SortingStyle',
165            'author_year_title = pybtex.style.sorting.author_year_title:SortingStyle',
166        ],
167        'pybtex.style.formatting': [
168            'plain = pybtex.style.formatting.plain:Style',
169            'unsrt = pybtex.style.formatting.unsrt:Style',
170            'alpha = pybtex.style.formatting.alpha:Style',
171            'unsrtalpha = pybtex.style.formatting.unsrtalpha:Style',
172        ],
173    },
174    zip_safe=True,
175)
176