From 3dd29097e4d436f4fa7a01e2c4213c528168b242 Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Fri, 27 Jun 2014 15:21:16 -0700 Subject: [PATCH 1/5] _test_tokenizer: force utf-8 file encoding --- tests/_test_tokenizer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/_test_tokenizer.py b/tests/_test_tokenizer.py index 7487241..313b959 100644 --- a/tests/_test_tokenizer.py +++ b/tests/_test_tokenizer.py @@ -25,6 +25,8 @@ from os import listdir, path import sys from mwparserfromhell.compat import py3k +if not py3k: + from codecs import open from mwparserfromhell.parser import tokens class _TestParseError(Exception): @@ -109,10 +111,8 @@ class TokenizerTestCase(object): def build(cls): """Load and install all tests from the 'tokenizer' directory.""" def load_file(filename): - with open(filename, "rU") as fp: + with open(filename, "rU", encoding='utf8') as fp: text = fp.read() - if not py3k: - text = text.decode("utf8") name = path.split(filename)[1][:0-len(extension)] cls._load_tests(filename, name, text) From b135e8e473837909c6847f8a52711527409b5224 Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Fri, 27 Jun 2014 15:21:37 -0700 Subject: [PATCH 2/5] Add windows build tools --- tools/build_mwpfh.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/build_mwpfh.py diff --git a/tools/build_mwpfh.py b/tools/build_mwpfh.py new file mode 100644 index 0000000..a090b4d --- /dev/null +++ b/tools/build_mwpfh.py @@ -0,0 +1,43 @@ +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) \ No newline at end of file From 05d048762f2e0c81a9e425425269dcdde4bec251 Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Fri, 27 Jun 2014 15:21:45 -0700 Subject: [PATCH 3/5] Improve .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4068716..8790182 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc +*.pyd *.so *.dll *.egg @@ -8,3 +9,4 @@ __pycache__ build dist docs/_build +tools/*.log From 581ca9a2213d6329a45d3b927873febe9e5ad479 Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Sat, 28 Jun 2014 00:35:50 +0200 Subject: [PATCH 4/5] Update README.rst for the new Windows wheels --- README.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5b4cfe1..d0f67c9 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,10 @@ 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`` -(`get pip`_). Alternatively, get the latest development version:: +(`get pip`_). On Windows, make sure you have the latest version of pip +installed by running `pip install --upgrade pip`. + +Alternatively, get the latest development version:: git clone https://github.com/earwig/mwparserfromhell.git cd mwparserfromhell From 5e9930b8a060d2ad80713809e312eae913ce7a4f Mon Sep 17 00:00:00 2001 From: Merlijn van Deen Date: Sat, 28 Jun 2014 00:37:31 +0200 Subject: [PATCH 5/5] Fix tabs in update_mwpfh.py --- tools/build_mwpfh.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tools/build_mwpfh.py b/tools/build_mwpfh.py index a090b4d..4a86241 100644 --- a/tools/build_mwpfh.py +++ b/tools/build_mwpfh.py @@ -6,7 +6,7 @@ import os path = os.path.split(__file__)[0] if path: - os.chdir(path) + os.chdir(path) environments = ['26', '27', '32', '33', '34'] @@ -15,29 +15,29 @@ 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 +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 + 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) \ No newline at end of file + print() + try: + os.unlink('mwparserfromhell/parser/_tokenizer.pyd') + except WindowsError: + pass + + if run(pyver, ["test"]) == 0: + run(pyver, ["bdist_wheel", "upload"], target)