| @@ -9,4 +9,4 @@ __pycache__ | |||||
| build | build | ||||
| dist | dist | ||||
| docs/_build | docs/_build | ||||
| tools/*.log | |||||
| scripts/*.log | |||||
| @@ -15,10 +15,10 @@ Full documentation is available on ReadTheDocs_. Development occurs on GitHub_. | |||||
| Installation | Installation | ||||
| ------------ | ------------ | ||||
| The easiest way to install the parser is through the `Python Package Index`_, | |||||
| so you can install the latest release with ``pip install mwparserfromhell`` | |||||
| The easiest way to install the parser is through the `Python Package Index`_; | |||||
| you can install the latest release with ``pip install mwparserfromhell`` | |||||
| (`get pip`_). On Windows, make sure you have the latest version of pip | (`get pip`_). On Windows, make sure you have the latest version of pip | ||||
| installed by running `pip install --upgrade pip`. | |||||
| installed by running ``pip install --upgrade pip``. | |||||
| Alternatively, get the latest development version:: | Alternatively, get the latest development version:: | ||||
| @@ -26,11 +26,6 @@ Alternatively, get the latest development version:: | |||||
| cd mwparserfromhell | cd mwparserfromhell | ||||
| python setup.py install | python setup.py install | ||||
| If you get ``error: Unable to find vcvarsall.bat`` while installing, this is | |||||
| because Windows can't find the compiler for C extensions. Consult this | |||||
| `StackOverflow question`_ for help. You can also set ``ext_modules`` in | |||||
| ``setup.py`` to an empty list to prevent the extension from building. | |||||
| You can run the comprehensive unit testing suite with | You can run the comprehensive unit testing suite with | ||||
| ``python setup.py test -q``. | ``python setup.py test -q``. | ||||
| @@ -0,0 +1,36 @@ | |||||
| from __future__ import print_function | |||||
| import os | |||||
| from subprocess import call, STDOUT | |||||
| ENVIRONMENTS = ["26", "27", "32", "33", "34"] | |||||
| def run(pyver, cmds): | |||||
| cmd = [r"C:\Python%s\Python.exe" % pyver, "setup.py"] + cmds | |||||
| print(" ".join(cmd), end=" ") | |||||
| with open("%s%s.log" % (cmds[0], pyver), "w") as logfile: | |||||
| retval = call(cmd, stdout=logfile, stderr=STDOUT, cwd="..") | |||||
| if not retval: | |||||
| print("[OK]") | |||||
| else: | |||||
| print("[FAILED (%i)]" % retval) | |||||
| return retval | |||||
| def main(): | |||||
| path = os.path.split(__file__)[0] | |||||
| if path: | |||||
| os.chdir(path) | |||||
| print("Building Windows wheels for Python %s:" % ", ".join(ENVIRONMENTS)) | |||||
| for pyver in ENVIRONMENTS: | |||||
| print() | |||||
| try: | |||||
| os.unlink("mwparserfromhell/parser/_tokenizer.pyd") | |||||
| except OSError: | |||||
| pass | |||||
| if run(pyver, ["test"]) == 0: | |||||
| run(pyver, ["bdist_wheel", "upload"]) | |||||
| if __name__ == "__main__": | |||||
| main() | |||||
| @@ -25,7 +25,7 @@ import sys | |||||
| if (sys.version_info[0] == 2 and sys.version_info[1] < 6) or \ | if (sys.version_info[0] == 2 and sys.version_info[1] < 6) or \ | ||||
| (sys.version_info[1] == 3 and sys.version_info[1] < 2): | (sys.version_info[1] == 3 and sys.version_info[1] < 2): | ||||
| raise Exception('mwparserfromhell needs Python 2.6+ or 3.2+') | |||||
| raise Exception("mwparserfromhell needs Python 2.6+ or 3.2+") | |||||
| from setuptools import setup, find_packages, Extension | from setuptools import setup, find_packages, Extension | ||||
| @@ -36,7 +36,7 @@ with open("README.rst") as fp: | |||||
| long_docs = fp.read() | long_docs = fp.read() | ||||
| tokenizer = Extension("mwparserfromhell.parser._tokenizer", | tokenizer = Extension("mwparserfromhell.parser._tokenizer", | ||||
| sources = ["mwparserfromhell/parser/tokenizer.c"]) | |||||
| sources=["mwparserfromhell/parser/tokenizer.c"]) | |||||
| setup( | setup( | ||||
| name = "mwparserfromhell", | name = "mwparserfromhell", | ||||
| @@ -21,12 +21,11 @@ | |||||
| # SOFTWARE. | # SOFTWARE. | ||||
| from __future__ import print_function, unicode_literals | from __future__ import print_function, unicode_literals | ||||
| import codecs | |||||
| from os import listdir, path | from os import listdir, path | ||||
| import sys | import sys | ||||
| from mwparserfromhell.compat import py3k | from mwparserfromhell.compat import py3k | ||||
| if not py3k: | |||||
| from codecs import open | |||||
| from mwparserfromhell.parser import tokens | from mwparserfromhell.parser import tokens | ||||
| class _TestParseError(Exception): | class _TestParseError(Exception): | ||||
| @@ -111,7 +110,7 @@ class TokenizerTestCase(object): | |||||
| def build(cls): | def build(cls): | ||||
| """Load and install all tests from the 'tokenizer' directory.""" | """Load and install all tests from the 'tokenizer' directory.""" | ||||
| def load_file(filename): | def load_file(filename): | ||||
| with open(filename, "rU", encoding='utf8') as fp: | |||||
| with codecs.open(filename, "rU", encoding="utf8") as fp: | |||||
| text = fp.read() | text = fp.read() | ||||
| name = path.split(filename)[1][:0-len(extension)] | name = path.split(filename)[1][:0-len(extension)] | ||||
| cls._load_tests(filename, name, text) | cls._load_tests(filename, name, text) | ||||
| @@ -1,43 +0,0 @@ | |||||
| from __future__ import print_function | |||||
| import subprocess | |||||
| import sys | |||||
| import os | |||||
| path = os.path.split(__file__)[0] | |||||
| if path: | |||||
| os.chdir(path) | |||||
| environments = ['26', '27', '32', '33', '34'] | |||||
| target = "pypi" if "--push" in sys.argv else "test" | |||||
| returnvalues = {} | |||||
| def run(pyver, cmds, target=None): | |||||
| cmd = [r"C:\Python%s\Python.exe" % pyver, "setup.py"] + cmds | |||||
| if target: | |||||
| cmd += ["-r", target] | |||||
| print(" ".join(cmd), end=" ") | |||||
| retval = subprocess.call(cmd, stdout=open("%s%s.log" % (cmds[0], pyver), 'w'), stderr=subprocess.STDOUT, cwd="..") | |||||
| if not retval: | |||||
| print("[OK]") | |||||
| else: | |||||
| print("[FAILED (%i)]" % retval) | |||||
| return retval | |||||
| run("27", ["register"], target) | |||||
| if 'failed' in open('register27.log').read(): | |||||
| raise Exception | |||||
| for pyver in environments: | |||||
| print() | |||||
| try: | |||||
| os.unlink('mwparserfromhell/parser/_tokenizer.pyd') | |||||
| except WindowsError: | |||||
| pass | |||||
| if run(pyver, ["test"]) == 0: | |||||
| run(pyver, ["bdist_wheel", "upload"], target) | |||||