# -*- coding: utf-8 -*-importez_setupez_setup.use_setuptools()importosimportsysfromsetuptoolsimportsetup,find_packagesfromdistutilsimportlogimportsphinxlong_desc='''Sphinx is a tool that makes it easy to create intelligent and beautifuldocumentation for Python projects (or other documents consisting ofmultiple reStructuredText sources), written by Georg Brandl.It was originally created to translate the new Python documentation,but has now been cleaned up in the hope that it will be useful to manyother projects.Sphinx uses reStructuredText as its markup language, and many of its strengthscome from the power and straightforwardness of reStructuredText and itsparsing and translating suite, the Docutils.Although it is still under constant development, the following featuresare already present, work fine and can be seen "in action" in the Python docs:* Output formats: HTML (including Windows HTML Help), plain text and LaTeX, for printable PDF versions* Extensive cross-references: semantic markup and automatic links for functions, classes, glossary terms and similar pieces of information* Hierarchical structure: easy definition of a document tree, with automatic links to siblings, parents and children* Automatic indices: general index as well as a module index* Code handling: automatic highlighting using the Pygments highlighter* Various extensions are available, e.g. for automatic testing of snippets and inclusion of appropriately formatted docstrings.'''requires=['Pygments>=0.8','Jinja>=1.2','docutils>=0.4']ifsys.version_info<(2,4):print'ERROR: Sphinx requires at least Python 2.4 to run.'sys.exit(1)ifsys.version_info<(2,5):# Python 2.4's distutils doesn't automatically install an egg-info,# so an existing docutils install won't be detected -- in that case,# remove the dependency from setup.pytry:importdocutilsifint(docutils.__version__[2])<4:raiseValueError('docutils not recent enough')except:passelse:delrequires[-1]# Provide a "compile_catalog" command that also creates the translated# JavaScript files if Babel is available.cmdclass={}try:frombabel.messages.pofileimportread_pofrombabel.messages.frontendimportcompile_catalogtry:fromsimplejsonimportdumpexceptImportError:fromjsonimportdumpexceptImportError:passelse:classcompile_catalog_plusjs(compile_catalog):""" An extended command that writes all message strings that occur in JavaScript files to a JavaScript file along with the .mo file. Unfortunately, babel's setup command isn't built very extensible, so most of the run() code is duplicated here. """defrun(self):compile_catalog.run(self)po_files=[]js_files=[]ifnotself.input_file:ifself.locale:po_files.append((self.locale,os.path.join(self.directory,self.locale,'LC_MESSAGES',self.domain+'.po')))js_files.append(os.path.join(self.directory,self.locale,'LC_MESSAGES',self.domain+'.js'))else:forlocaleinos.listdir(self.directory):po_file=os.path.join(self.directory,locale,'LC_MESSAGES',self.domain+'.po')ifos.path.exists(po_file):po_files.append((locale,po_file))js_files.append(os.path.join(self.directory,locale,'LC_MESSAGES',self.domain+'.js'))else:po_files.append((self.locale,self.input_file))ifself.output_file:js_files.append(self.output_file)else:js_files.append(os.path.join(self.directory,self.locale,'LC_MESSAGES',self.domain+'.js'))forjs_file,(locale,po_file)inzip(js_files,po_files):infile=open(po_file,'r')try:catalog=read_po(infile,locale)finally:infile.close()ifcatalog.fuzzyandnotself.use_fuzzy:continuelog.info('writing JavaScript strings in catalog %r to %r',po_file,js_file)jscatalog={}formessageincatalog:ifany(x[0].endswith('.js')forxinmessage.locations):msgid=message.idifisinstance(msgid,(list,tuple)):msgid=msgid[0]jscatalog[msgid]=message.stringoutfile=open(js_file,'wb')try:outfile.write('Documentation.addTranslations(');dump(dict(messages=jscatalog,plural_expr=catalog.plural_expr,locale=str(catalog.locale)),outfile)outfile.write(');')finally:outfile.close()cmdclass['compile_catalog']=compile_catalog_plusjssetup(name='Sphinx',version=sphinx.__version__,url='http://sphinx.pocoo.org/',download_url='http://pypi.python.org/pypi/Sphinx',license='BSD',author='Georg Brandl',author_email='georg@python.org',description='Python documentation generator',long_description=long_desc,zip_safe=False,classifiers=['Development Status :: 4 - Beta','Environment :: Console','Environment :: Web Environment','Intended Audience :: Developers','License :: OSI Approved :: BSD License','Operating System :: OS Independent','Programming Language :: Python','Topic :: Documentation','Topic :: Utilities',],platforms='any',packages=find_packages(),include_package_data=True,entry_points={'console_scripts':['sphinx-build = sphinx:main','sphinx-quickstart = sphinx.quickstart:main'],'distutils.commands':['build_sphinx = sphinx.setup_command:BuildDoc',],},install_requires=requires,cmdclass=cmdclass,)