A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

setup.py 3.8 KiB

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