diff --git a/setup.py b/setup.py index 6471f71..601dbda 100755 --- a/setup.py +++ b/setup.py @@ -1,29 +1,35 @@ import sys, os, shutil, glob - +sys.argv.append('build') # Some Angstrom images are missing the py_compile module; get it if not # present: import random python_lib_path = random.__file__.split('random')[0] if not os.path.exists(python_lib_path + 'py_compile.py'): - print "py_compile module missing; installing to %spy_compile.py" %\ - python_lib_path - import urllib2 - url = "http://hg.python.org/cpython/raw-file/4ebe1ede981e/Lib/py_compile.py" - py_compile = urllib2.urlopen(url) - with open(python_lib_path+'py_compile.py', 'w') as f: - f.write(py_compile.read()) - print "testing py_compile..." + print("py_compile module missing; installing to %spy_compile.py" %\ + python_lib_path) try: import py_compile - print "py_compile installed successfully" - except Exception, e: - print "*py_compile install failed, could not import" - print "*Exception raised:" - raise e + except ImportError: + try: + import urllib.request as urllib2 + except ImportError: + import urllib2 + url = "http://hg.python.org/cpython/raw-file/4ebe1ede981e/Lib/py_compile.py" + py_compile = urllib2.urlopen(url) + with open(python_lib_path+'py_compile.py', 'wb') as f: + f.write(py_compile.read()) + print("testing py_compile...") + try: + import py_compile + print("py_compile installed successfully") + except Exception as e: + print("*py_compile install failed, could not import") + print("*Exception raised:") + raise e -print "Installing PyBBIO..." +print("Installing PyBBIO...") from setuptools import setup, Extension, find_packages