A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 4.3 KiB

12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
12 vuotta sitten
11 vuotta sitten
12 vuotta sitten
11 vuotta sitten
10 vuotta sitten
12 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #! /usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright (C) 2012-2016 Ben Kurtovic <ben.kurtovic@gmail.com>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. # SOFTWARE.
  23. from __future__ import print_function
  24. from distutils.errors import DistutilsError, CCompilerError
  25. from glob import glob
  26. from os import environ
  27. import sys
  28. if ((sys.version_info[0] == 2 and sys.version_info[1] < 6) or
  29. (sys.version_info[1] == 3 and sys.version_info[1] < 2)):
  30. raise RuntimeError("mwparserfromhell needs Python 2.6+ or 3.2+")
  31. from setuptools import setup, find_packages, Extension
  32. from setuptools.command.build_ext import build_ext
  33. from mwparserfromhell import __version__
  34. from mwparserfromhell.compat import py26, py3k
  35. with open("README.rst", **({'encoding':'utf-8'} if py3k else {})) as fp:
  36. long_docs = fp.read()
  37. use_extension = True
  38. fallback = True
  39. # Allow env var WITHOUT_EXTENSION and args --with[out]-extension:
  40. env_var = environ.get("WITHOUT_EXTENSION")
  41. if "--without-extension" in sys.argv:
  42. use_extension = False
  43. elif "--with-extension" in sys.argv:
  44. fallback = False
  45. elif env_var is not None:
  46. if env_var == "1":
  47. use_extension = False
  48. elif env_var == "0":
  49. fallback = False
  50. # Remove the command line argument as it isn't understood by setuptools:
  51. sys.argv = [arg for arg in sys.argv
  52. if arg != "--without-extension" and arg != "--with-extension"]
  53. def build_ext_patched(self):
  54. try:
  55. build_ext_original(self)
  56. except (DistutilsError, CCompilerError) as exc:
  57. print("error: " + str(exc))
  58. print("Falling back to pure Python mode.")
  59. del self.extensions[:]
  60. if fallback:
  61. build_ext.run, build_ext_original = build_ext_patched, build_ext.run
  62. # Project-specific part begins here:
  63. tokenizer = Extension("mwparserfromhell.parser._tokenizer",
  64. sources=sorted(glob("mwparserfromhell/parser/ctokenizer/*.c")),
  65. depends=glob("mwparserfromhell/parser/ctokenizer/*.h"))
  66. setup(
  67. name = "mwparserfromhell",
  68. packages = find_packages(exclude=("tests",)),
  69. ext_modules = [tokenizer] if use_extension else [],
  70. tests_require = ["unittest2"] if py26 else [],
  71. test_suite = "tests.discover",
  72. version = __version__,
  73. author = "Ben Kurtovic",
  74. author_email = "ben.kurtovic@gmail.com",
  75. url = "https://github.com/earwig/mwparserfromhell",
  76. description = "MWParserFromHell is a parser for MediaWiki wikicode.",
  77. long_description = long_docs,
  78. download_url = "https://github.com/earwig/mwparserfromhell/tarball/v{0}".format(__version__),
  79. keywords = "earwig mwparserfromhell wikipedia wiki mediawiki wikicode template parsing",
  80. license = "MIT License",
  81. classifiers = [
  82. "Development Status :: 4 - Beta",
  83. "Environment :: Console",
  84. "Intended Audience :: Developers",
  85. "License :: OSI Approved :: MIT License",
  86. "Operating System :: OS Independent",
  87. "Programming Language :: Python :: 2.6",
  88. "Programming Language :: Python :: 2.7",
  89. "Programming Language :: Python :: 3",
  90. "Programming Language :: Python :: 3.2",
  91. "Programming Language :: Python :: 3.3",
  92. "Programming Language :: Python :: 3.4",
  93. "Programming Language :: Python :: 3.5",
  94. "Programming Language :: Python :: 3.6",
  95. "Topic :: Text Processing :: Markup"
  96. ],
  97. )