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

fix build: support python3, update cryptopp, update ed25519 #47

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "src-cryptopp"]
path = src-cryptopp
url = https://github.com/weidai11/cryptopp
[submodule "src-ed25519"]
path = src-ed25519
url = https://github.com/orlp/ed25519
60 changes: 30 additions & 30 deletions misc/build_helpers/show-tool-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,40 @@ def print_platform():
try:
import platform
out = platform.platform()
print
print "platform:", foldlines(out)
print "machine: ", platform.machine()
print()
print("platform:", foldlines(out))
print("machine: ", platform.machine())
if hasattr(platform, 'linux_distribution'):
print "linux_distribution:", repr(platform.linux_distribution())
print("linux_distribution:", repr(platform.linux_distribution()))
except EnvironmentError:
sys.stderr.write("Got exception using 'platform'. Exception follows\n")
traceback.print_exc(file=sys.stderr)
sys.stderr.flush()
pass

def print_python_ver():
print "python:", foldlines(sys.version)
print 'maxunicode: ' + str(sys.maxunicode)
print("python:", foldlines(sys.version))
print('maxunicode: ' + str(sys.maxunicode))

def print_python_encoding_settings():
print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
print('filesystem.encoding: ' + str(sys.getfilesystemencoding()))
print('locale.getpreferredencoding: ' + str(locale.getpreferredencoding()))
try:
print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
except ValueError, e:
print 'got exception from locale.getdefaultlocale(): ', e
print 'locale.locale: ' + str(locale.getlocale())
print('locale.defaultlocale: ' + str(locale.getdefaultlocale()))
except ValueError as e:
print('got exception from locale.getdefaultlocale(): ', e)
print('locale.locale: ' + str(locale.getlocale()))

def print_stdout(cmdlist, label=None, numlines=None):
if label is None:
label = cmdlist[0]
try:
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
stdout=subprocess.PIPE).communicate()[0]
print label + ': ' + foldlines(res, numlines)
except EnvironmentError, e:
print(label + ': ' + foldlines(res, numlines))
except EnvironmentError as e:
if isinstance(e, OSError) and e.errno == errno.ENOENT:
print str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory'
print(str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory')
return
sys.stderr.write("\n%s: Got exception invoking '%s'. Exception follows.\n" % (label, cmdlist[0],))
traceback.print_exc(file=sys.stderr)
Expand All @@ -58,10 +58,10 @@ def print_stderr(cmdlist, label=None):
try:
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
stderr=subprocess.PIPE).communicate()[1]
print label + ': ' + foldlines(res)
except EnvironmentError, e:
print(label + ': ' + foldlines(res))
except EnvironmentError as e:
if isinstance(e, OSError) and e.errno == errno.ENOENT:
print str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory'
print(str(label) + ': ' + str(cmdlist[0]) + ': no such file or directory')
return
sys.stderr.write("\n%s: Got exception invoking '%s'. Exception follows.\n" % (label, cmdlist[0],))
traceback.print_exc(file=sys.stderr)
Expand All @@ -71,12 +71,12 @@ def print_stderr(cmdlist, label=None):

def print_as_ver():
if os.path.exists('a.out'):
print "WARNING: a file named a.out exists, and getting the version of the 'as' assembler writes to that filename, so I'm not attempting to get the version of 'as'."
print("WARNING: a file named a.out exists, and getting the version of the 'as' assembler writes to that filename, so I'm not attempting to get the version of 'as'.")
return
try:
res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print 'as: ' + foldlines(res[0]+' '+res[1])
print('as: ' + foldlines(res[0]+' '+res[1]))
if os.path.exists('a.out'):
os.remove('a.out')
except EnvironmentError:
Expand All @@ -89,51 +89,51 @@ def print_setuptools_ver():
try:
import pkg_resources
out = str(pkg_resources.require("setuptools"))
print "setuptools:", foldlines(out)
print("setuptools:", foldlines(out))
except (ImportError, EnvironmentError):
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
traceback.print_exc(file=sys.stderr)
sys.stderr.flush()
pass
except pkg_resources.DistributionNotFound:
print 'setuptools: DistributionNotFound'
print('setuptools: DistributionNotFound')
pass

def print_py_pkg_ver(pkgname, modulename=None):
if modulename is None:
modulename = pkgname
print
print()
try:
import pkg_resources
out = str(pkg_resources.require(pkgname))
print pkgname + ': ' + foldlines(out)
print(pkgname + ': ' + foldlines(out))
except (ImportError, EnvironmentError):
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
traceback.print_exc(file=sys.stderr)
sys.stderr.flush()
pass
except pkg_resources.DistributionNotFound:
print pkgname + ': DistributionNotFound'
print(pkgname + ': DistributionNotFound')
pass
try:
__import__(modulename)
except ImportError:
pass
else:
modobj = sys.modules.get(modulename)
print pkgname + ' module: ' + str(modobj)
print(pkgname + ' module: ' + str(modobj))
try:
print pkgname + ' __version__: ' + str(modobj.__version__)
print(pkgname + ' __version__: ' + str(modobj.__version__))
except AttributeError:
pass

print_platform()
print
print()
print_python_ver()
print
print()
print_stdout(['locale'])
print_python_encoding_settings()
print
print()
print_stdout(['buildbot', '--version'])
print_stdout(['buildslave', '--version'])
if 'windows' in platform.system().lower():
Expand Down
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

# Link with a Crypto++ library that is already installed on the system.

# TODO use pkg-config to find incldir and libdir of cryptopp
for inclpath in ["/usr/local/include/cryptopp", "/usr/include/cryptopp"]:
if os.path.exists(inclpath):
libraries.append("cryptopp")
Expand All @@ -91,9 +92,9 @@
break

if not libraries:
print "Did not locate libcryptopp in the usual places."
print "Adding /usr/local/{include,lib} and -lcryptopp in the hopes"
print "that they will work."
print("Did not locate libcryptopp in the usual places.")
print("Adding /usr/local/{include,lib} and -lcryptopp in the hopes")
print("that they will work.")

# Note that when using cygwin build tools (including gcc) to build
# Windows-native binaries, the os.path.exists() will not see the
Expand Down Expand Up @@ -159,10 +160,10 @@
# python-ed25519
sources = [os.path.join("src-ed25519","glue","ed25519module.c")]
sources.extend([os.path.join("src-ed25519","supercop-ref",s)
for s in os.listdir(os.path.join("src-ed25519","supercop-ref"))
for s in os.listdir(os.path.join("src-ed25519","src"))
if s.endswith(".c") and s!="test.c"])
m = Extension("pycryptopp.publickey.ed25519._ed25519",
include_dirs=[os.path.join("src-ed25519","supercop-ref")],
include_dirs=[os.path.join("src-ed25519","src")],
sources=sources)
ext_modules.append(m)

Expand All @@ -189,7 +190,7 @@

data_fnames=['COPYING.GPL', 'COPYING.TGPPL.rst', 'COPYING.MIT.txt', 'COPYING.SPL.txt', 'README.rst']

readmetext = open('README.rst').read()
readmetext = open('README.rst', 'rb').read()
if readmetext[:3] == '\xef\xbb\xbf':
# utf-8 "BOM"
readmetext = readmetext[3:]
Expand Down Expand Up @@ -330,7 +331,7 @@ def write_version_py(self, pkgname, version, outfname, body, EXE_NAME):
f.close()

def write_extraversion_h(self, pkgname, version, outfname, body):
f = open(outfname, "wb")
f = open(outfname, "wt")
f.write(body % {"pkgname": pkgname, "pkgversion": version})
f.close()

Expand Down
1 change: 1 addition & 0 deletions src-cryptopp
Submodule src-cryptopp added at a75a7d
Loading