Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop python2 support and fix setup.py install #134

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyminifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
# Import built-in modules
import os, sys, re, io
from optparse import OptionParser
from collections import Iterable
from collections.abc import Iterable

# Import our own modules
from . import minification
Expand Down
5 changes: 1 addition & 4 deletions pyminifier/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

# Import builtins
import os, sys, re, tokenize, keyword
try:
import cStringIO as io
except ImportError: # Ahh, Python 3
import io
import io

# Globals
py3 = False
Expand Down
5 changes: 1 addition & 4 deletions pyminifier/minification.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

# Import built-in modules
import re, tokenize, keyword
try:
import cStringIO as io
except ImportError: # We're using Python 3
import io
import io

# Import our own modules
from . import analyze, token_utils
Expand Down
5 changes: 1 addition & 4 deletions pyminifier/obfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
from . import analyze
from . import token_utils

if not isinstance(sys.version_info, tuple):
if sys.version_info.major == 3:
unichr = chr # So we can support both 2 and 3

try:
unichr(0x10000) # Will throw a ValueError on narrow Python builds
chr(0x10000) # Will throw a ValueError on narrow Python builds
HIGHEST_UNICODE = 0x10FFFF # 1114111
except:
HIGHEST_UNICODE = 0xFFFF # 65535
Expand Down
5 changes: 1 addition & 4 deletions pyminifier/token_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"""

import tokenize
try:
import cStringIO as io
except ImportError: # We're using Python 3
import io
import io

def untokenize(tokens):
"""
Expand Down
24 changes: 2 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
import sys
import pyminifier
from setuptools import setup
from distutils.command.install import INSTALL_SCHEMES

for scheme in INSTALL_SCHEMES.values():
scheme['data'] = scheme['purelib']

extra = {}

if isinstance(sys.version_info, tuple):
major = sys.version_info[0]
else:
major = sys.version_info.major

if major == 2:
from distutils.command.build_py import build_py
elif major == 3:
extra['use_2to3'] = True # Automatically convert to Python 3; love it!
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
print("Python 3.X support requires the 2to3 tool.")
print(
"It normally comes with Python 3.X but (apparenty) not on your "
"distribution.\nPlease find out what package you need to get 2to3"
"and install it.")
sys.exit(1)

cmdclass = {'build_py': build_py}
print("Python 2 is no longer supported.")
sys.exit(1)

setup(
name="pyminifier",
version=pyminifier.__version__,
description="Python code minifier, obfuscator, and compressor",
author=pyminifier.__author__,
cmdclass=cmdclass,
author_email="[email protected]",
url="https://github.com/liftoff/pyminifier",
license="Proprietary",
Expand Down Expand Up @@ -63,5 +44,4 @@
],
},
test_suite = "tests",
**extra
)