summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2011-12-06 17:53:19 -0500
committerEli Collins <elic@assurancetechnologies.com>2011-12-06 17:53:19 -0500
commit01dfa4e439db76b6991aa729672a02efcd835e77 (patch)
tree44adee11c2f51f2b52601f4e22c1fdb873ab7cfc
parent7645cfde280b228c537d19bcb4d4aab0fdde27ef (diff)
downloadpasslib-01dfa4e439db76b6991aa729672a02efcd835e77.tar.gz
removed 2to3 translation step from setup
-rw-r--r--docs/install.rst11
-rw-r--r--passlib/_setup/__init__.py6
-rw-r--r--passlib/_setup/cond2to3.py152
-rw-r--r--setup.py23
4 files changed, 5 insertions, 187 deletions
diff --git a/docs/install.rst b/docs/install.rst
index b524725..3b4f7d3 100644
--- a/docs/install.rst
+++ b/docs/install.rst
@@ -17,7 +17,7 @@ as it contains builtin fallbacks
for almost all OS-dependant features.
Google App Engine is supported as well.
-.. _optional-libraries:
+.. _optional-libraries:
Optional Libraries
==================
@@ -50,15 +50,6 @@ To install from a source directory using :command:`setup.py`::
python setup.py install
-.. note::
-
- Passlib's source ships as Python 2 code,
- and the setup script invokes the :command:`2to3` tool + a preprocessor
- to translate the source to Python 3 code at install time.
- Aside from this internal detail,
- installation under Python 3
- should be identical to that of Python 2.
-
Testing
=======
PassLib contains a comprehensive set of unittests providing nearly complete coverage.
diff --git a/passlib/_setup/__init__.py b/passlib/_setup/__init__.py
index 814c93a..3881943 100644
--- a/passlib/_setup/__init__.py
+++ b/passlib/_setup/__init__.py
@@ -1,5 +1 @@
-"""passlib.setup - helpers used by passlib's setup.py script
-
-note that unlike the rest of passlib, the code in this package must
-work *unaltered* under both python 2 & 3
-"""
+"""passlib.setup - helpers used by passlib's setup.py script"""
diff --git a/passlib/_setup/cond2to3.py b/passlib/_setup/cond2to3.py
deleted file mode 100644
index 12cb0a8..0000000
--- a/passlib/_setup/cond2to3.py
+++ /dev/null
@@ -1,152 +0,0 @@
-"""passlib.setup.cond2to3 - moneypatches 2to3 to provide conditional macros, ala SQLAlchemy"""
-#=========================================================
-#imports
-#=========================================================
-#core
-from lib2to3.refactor import RefactoringTool
-import re
-#site
-#local
-__all__ = [
- "patch2to3",
-]
-
-#=========================================================
-#macro preprocessor
-#=========================================================
-py3k_start_re = re.compile(r"^(\s*)# Py3K #", re.I)
-py3k_stop_re = re.compile(r"^(\s*)# end Py3K #", re.I)
-
-py2k_start_re = re.compile(r"^(\s*)# Py2K #", re.I)
-py2k_stop_re = re.compile(r"^(\s*)# end Py2K #", re.I)
-
-bare_comment_re = re.compile(r"^(\s*)#(.*)")
-bare_re = re.compile(r"^(\s*)(.*)")
-
-def preprocess(data, name):
- #TODO: add flag so this can also function in reverse, for 3to2
- changed = False
-
- lines = data.split("\n")
- state = 0
- #0: parsing normally, looking for start-p3k or start-py2k
- #1: in Py3K block - removing comment chars until end-py3k
- #2: in Py2K block - adding comment chars until end-py2k
- idx = 0
- indent = ''
- while idx < len(lines):
- line = lines[idx]
-
- #hack to detect ''"abc" strings - using this as py25-compat way to indicate bytes.
- #should really turn into a proper fixer.
- #also, this check is really weak, and might fail in some cases
- if '\'\'".*"' in line:
- line = lines[idx] = line.replace("''", "b")
- changed = True
-
- #check for py3k start marker
- m = py3k_start_re.match(line)
- if m:
- if state in (0,2):
- ident = m.group(1)
- state = 1
- idx += 1
- continue
- #states 1 this is an error...
- raise SyntaxError("unexpected py3k-start marker on line %d of %r: %r" % (idx, name, line))
-
- #check for py3k stop marker
- if py3k_stop_re.match(line):
- if state == 1:
- state = 0
- idx += 1
- continue
- #states 0,2 this is an error...
- raise SyntaxError("unexpected py3k-stop marker on line %d of %r: %r" % (idx, name, line))
-
- #check for py2k start marker
- m = py2k_start_re.match(line)
- if m:
- if state in (0,1):
- ident = m.group(1)
- state = 2
- idx += 1
- continue
- #states 2 this is an error...
- raise SyntaxError("unexpected py2k-start marker on line %d of %r: %r" % (idx, name, line))
-
- #check for py2k end marker
- if py2k_stop_re.match(line):
- if state == 2:
- state = 0
- idx += 1
- continue
- #states 0,1 this is an error...
- raise SyntaxError("unexpected py2k-stop marker on line %d of %r: %r" % (idx, name, line))
-
- #state 0 - leave non-marker lines alone
- if state == 0:
- idx += 1
- continue
-
- #state 1 - uncomment comment lines, throw error on bare lines
- if state == 1:
- m = bare_comment_re.match(line)
- if not m:
- raise SyntaxError("unexpected non-comment in py3k block on line %d of %r: %r" % (idx,name, line))
- pad, content = m.group(1,2)
- lines[idx] = pad + content
- changed = True
- idx += 1
- continue
-
- #state 2 - comment out all lines
- if state == 2:
- m = bare_re.match(line)
- if not m:
- raise RuntimeError("unexpected failure to parse line %d of %r: %r" % (idx, name, line))
- pad, content = m.group(1,2)
- if pad.startswith(ident): #try to put comments on same level
- content = pad[len(ident):] + content
- pad = ident
- lines[idx] = "%s#%s" % (pad,content)
- changed = True
- idx += 1
- continue
-
- #should never get here
- raise AssertionError("invalid state: %r" % (state,))
-
- if changed:
- return "\n".join(lines)
- else:
- return data
-
-orig_rs = RefactoringTool.refactor_string
-
-def refactor_string(self, data, name):
- "replacement for RefactoringTool.refactor_string which honors conditional includes"
- newdata = preprocess(data, name)
- tree = orig_rs(self, newdata, name)
- if tree and newdata != data:
- tree.was_changed = True
- return tree
-
-#=========================================================
-#main
-#=========================================================
-
-def patch2to3():
- "frontend to patch preprocessor into lib2to3"
- RefactoringTool.refactor_string = refactor_string
-
-#helper for development purposes - runs 2to3 w/ patch
-if __name__ == "__main__":
- import sys
- from lib2to3.main import main
- patch2to3()
- sys.exit(main("lib2to3.fixes"))
-
-#=========================================================
-#eof
-#=========================================================
diff --git a/setup.py b/setup.py
index 36b55e8..6a03fcf 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ try:
except ImportError:
from distutils import setup
has_distribute = False
-
+
#=========================================================
# init setup options
#=========================================================
@@ -29,23 +29,6 @@ opts = { "cmdclass": { } }
args = sys.argv[1:]
#=========================================================
-# 2to3 translation
-#=========================================================
-if py3k:
- # monkeypatch preprocessor into lib2to3
- from passlib._setup.cond2to3 import patch2to3
- patch2to3()
-
- # enable 2to3 translation in build_py
- if has_distribute:
- opts['use_2to3'] = True
- else:
- # if we can't use distribute's "use_2to3" flag,
- # have to override build_py command
- from distutils.command.build_py import build_py_2to3 as build_py
- opts['cmdclass']['build_py'] = build_py
-
-#=========================================================
#register docdist command (not required)
#=========================================================
try:
@@ -75,7 +58,7 @@ if os.path.exists(os.path.join(root_dir, "passlib.komodoproject")):
elif not v.startswith("-"):
break
i += 1
-
+
if for_release:
assert '.dev' not in VERSION and '.post' not in VERSION
else:
@@ -91,7 +74,7 @@ if os.path.exists(os.path.join(root_dir, "passlib.komodoproject")):
# to have the correct version string
from passlib._setup.stamp import stamp_distutils_output
stamp_distutils_output(opts, VERSION)
-
+
#=========================================================
#static text
#=========================================================