Browse Source

add setup.py... this builds the library and copies it over to the

build dir so it will get installed...  Also update the library finding
code to look in the modules install directory.
master
John-Mark Gurney 8 years ago
parent
commit
065e3eaabf
3 changed files with 43 additions and 3 deletions
  1. +7
    -0
      python/edgold/__init__.py
  2. +10
    -3
      python/edgold/ed448.py
  3. +26
    -0
      python/setup.py

+ 7
- 0
python/edgold/__init__.py View File

@@ -0,0 +1,7 @@
#!/usr/bin/env python

'''This is a wrapper around the Goldilocks libdecaf library.

Currently only the ed448 code is wrapped. It is available in the
submodule ed448.
'''

python/ed448.py → python/edgold/ed448.py View File

@@ -40,17 +40,22 @@ __status__ = 'alpha'

import array
import os
import os.path
import sys
import unittest
import warnings
import sys

from ctypes import *

try:
decaf = CDLL('../build/lib/libdecaf.so')
_dname = os.path.dirname(__file__)
if not _dname:
_dname = '.'
_path = os.path.join(_dname, 'libdecaf.so')
decaf = CDLL(_path)
except OSError as e: # pragma: no cover
import warnings
warnings.warn('goldilocks.so not installed.')
warnings.warn('libdecaf.so not installed.')
raise ImportError(str(e))

DECAF_EDDSA_448_PUBLIC_BYTES = 57
@@ -232,6 +237,8 @@ class TestEd448(unittest.TestCase):
key3 = EDDSA448(pub=pubkey)
key3.verify(sig, message)

self.assertRaises(ValueError, key.export_key, 'PEM')

def test_keyimportexport(self):
privkey = b'1' * DECAF_EDDSA_448_PRIVATE_BYTES
key = EDDSA448(privkey)

+ 26
- 0
python/setup.py View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python

from distutils.command.build import build
from distutils.core import setup

import os

class my_build(build):
def run(self):
build.run(self)
if not self.dry_run:
os.spawnlp(os.P_WAIT, 'sh', 'sh', '-c', 'cd .. && gmake lib')
self.copy_file(os.path.join('..', 'build', 'lib', 'libdecaf.so'), os.path.join(self.build_lib, 'edgold'))

cmdclass = {}
cmdclass['build'] = my_build

setup(name='edgold',
version='0.1',
description='The Ed ECC Goldilocks Python wrapper',
author='John-Mark Gurney',
author_email='jmg@funkthat.com',
#url='',
cmdclass=cmdclass,
packages=['edgold', ],
)

Loading…
Cancel
Save