Browse Source

Some tweaks, but no change in functionality.

tags/v0.4
Ben Kurtovic 9 years ago
parent
commit
d8adb62454
6 changed files with 44 additions and 57 deletions
  1. +1
    -1
      .gitignore
  2. +3
    -8
      README.rst
  3. +36
    -0
      scripts/win_build.py
  4. +2
    -2
      setup.py
  5. +2
    -3
      tests/_test_tokenizer.py
  6. +0
    -43
      tools/build_mwpfh.py

+ 1
- 1
.gitignore View File

@@ -9,4 +9,4 @@ __pycache__
build
dist
docs/_build
tools/*.log
scripts/*.log

+ 3
- 8
README.rst View File

@@ -15,10 +15,10 @@ Full documentation is available on ReadTheDocs_. Development occurs on GitHub_.
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
installed by running `pip install --upgrade pip`.
installed by running ``pip install --upgrade pip``.

Alternatively, get the latest development version::

@@ -26,11 +26,6 @@ Alternatively, get the latest development version::
cd mwparserfromhell
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
``python setup.py test -q``.



+ 36
- 0
scripts/win_build.py View File

@@ -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()

+ 2
- 2
setup.py View File

@@ -25,7 +25,7 @@ import sys

if (sys.version_info[0] == 2 and sys.version_info[1] < 6) or \
(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

@@ -36,7 +36,7 @@ with open("README.rst") as fp:
long_docs = fp.read()

tokenizer = Extension("mwparserfromhell.parser._tokenizer",
sources = ["mwparserfromhell/parser/tokenizer.c"])
sources=["mwparserfromhell/parser/tokenizer.c"])

setup(
name = "mwparserfromhell",


+ 2
- 3
tests/_test_tokenizer.py View File

@@ -21,12 +21,11 @@
# SOFTWARE.

from __future__ import print_function, unicode_literals
import codecs
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):
@@ -111,7 +110,7 @@ class TokenizerTestCase(object):
def build(cls):
"""Load and install all tests from the 'tokenizer' directory."""
def load_file(filename):
with open(filename, "rU", encoding='utf8') as fp:
with codecs.open(filename, "rU", encoding="utf8") as fp:
text = fp.read()
name = path.split(filename)[1][:0-len(extension)]
cls._load_tests(filename, name, text)


+ 0
- 43
tools/build_mwpfh.py View File

@@ -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)

Loading…
Cancel
Save