-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): replace zenroom.h in favour of
zencode-exec
(#725)
* feat: use zencode-exec instead of zenroom.h in python bindings * fix: one more python-sdist dependency * fix: add extra argument
- Loading branch information
1 parent
2654cad
commit 7421f08
Showing
9 changed files
with
106 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,8 @@ | ||
import os | ||
import subprocess | ||
import time | ||
from setuptools import Extension, setup | ||
|
||
ECP_CURVE = 'BLS381' | ||
ECDH_CURVE = 'SECP256K1' | ||
|
||
PYTHON_ROOT = os.getcwd() | ||
ZENROOM_ROOT = os.path.join( os.getcwd(), 'src') | ||
|
||
ZENROOM_LIB_ROOT_REL= 'src/src' | ||
LUA_ROOT = os.path.join(ZENROOM_ROOT, 'lib/lua54/src') | ||
MILAGRO_INCLUDE_DIR = os.path.join(ZENROOM_ROOT, 'lib/milagro-crypto-c/include') | ||
QP_ROOT = os.path.join(ZENROOM_ROOT, 'lib/pqclean') | ||
ED25519_INCLUDE_DIR = os.path.join(ZENROOM_ROOT, 'lib/ed25519-donna') | ||
MIMALLOC_INCLUDE_DIR = os.path.join(ZENROOM_ROOT, 'lib/mimalloc/include') | ||
ZENROOM_ROOT = os.path.join(os.getcwd(), 'src') | ||
|
||
def get_versions(): | ||
with open(os.path.join(ZENROOM_ROOT, 'git_utils')) as f: | ||
|
@@ -23,96 +11,10 @@ def get_versions(): | |
return python_version, zenroom_version | ||
|
||
|
||
ZENROOM_SOURCES = [ | ||
'rmd160.c', | ||
'base58.c', | ||
'segwit_addr.c', | ||
'cortex_m.c', | ||
'encoding.c', | ||
'lua_functions.c', | ||
'lualibs_detected.c', | ||
'lua_modules.c', | ||
'lua_shims.c', | ||
'mutt_sprintf.c', | ||
'randombytes.c', | ||
'repl.c', | ||
'zen_aes.c', | ||
'zen_big.c', | ||
'zen_config.c', | ||
'zen_ecdh.c', | ||
'zen_ecp2.c', | ||
'zen_ecp.c', | ||
'zen_error.c', | ||
'zen_fp12.c', | ||
'zen_hash.c', | ||
'zen_io.c', | ||
'zen_memory.c', | ||
'zen_octet.c', | ||
'zen_parse.c', | ||
'zen_qp.c', | ||
'zen_float.c', | ||
'zen_ed.c', | ||
'zen_random.c', | ||
'zenroom.c', | ||
'zen_ecdh_factory.c' | ||
] | ||
|
||
# Add meson build variables to the environment | ||
# source_root = os.path.join(ZENROOM_ROOT, 'build') | ||
meson_root = os.path.join(ZENROOM_ROOT, 'meson') | ||
# env = dict(os.environ, | ||
# MESON_SOURCE_ROOT=source_root, | ||
# MESON_BUILD_ROOT=PYTHON_ROOT) | ||
|
||
os.chdir(ZENROOM_ROOT) | ||
subprocess.check_call(['make', 'clean']) | ||
subprocess.check_call(['make', 'meson']) | ||
python_version, zenroom_version = get_versions() | ||
os.chdir(PYTHON_ROOT) | ||
|
||
zenroom_lib = Extension('zenroom', | ||
sources=[ | ||
os.path.join(ZENROOM_LIB_ROOT_REL, src) | ||
for src in ZENROOM_SOURCES | ||
], | ||
# + [zenroom_ecdh_factory] + [ | ||
# os.path.join(LUA_ROOT, src) | ||
# for src in LUA_SOURCES | ||
# ], | ||
include_dirs=[ | ||
os.getcwd(), | ||
ZENROOM_LIB_ROOT_REL, | ||
LUA_ROOT, | ||
MILAGRO_INCLUDE_DIR, | ||
ED25519_INCLUDE_DIR, | ||
MIMALLOC_INCLUDE_DIR, | ||
os.path.join(meson_root, 'milagro-crypto-c/include'), | ||
os.path.join(meson_root, 'milagro-crypto-c/include'), | ||
# os.path.join(QP_ROOT, 'dilithium2'), | ||
# os.path.join(QP_ROOT, 'kyber512'), | ||
# os.path.join(QP_ROOT, 'sntrup761'), | ||
], | ||
|
||
extra_compile_args=[ | ||
'-DVERSION="' + zenroom_version + '"', | ||
# '-DLUA_COMPAT_5_3', | ||
# '-DLUA_COMPAT_MODULE', | ||
# '-DLUA_COMPAT_BITLIB' | ||
], | ||
extra_objects=[ | ||
os.path.join(meson_root, 'milagro-crypto-c/lib/libamcl_core.a'), | ||
os.path.join(meson_root, 'milagro-crypto-c/lib/libamcl_core.a'), | ||
os.path.join(meson_root, 'milagro-crypto-c/lib/libamcl_curve_' + ECDH_CURVE + '.a'), | ||
os.path.join(meson_root, 'milagro-crypto-c/lib/libamcl_pairing_' + ECP_CURVE + '.a'), | ||
os.path.join(meson_root, 'milagro-crypto-c/lib/libamcl_curve_' + ECP_CURVE + '.a'), | ||
os.path.join(meson_root, 'libqpz.a'), | ||
os.path.join(meson_root, 'liblua.a'), | ||
os.path.join(meson_root, 'libed25519.a'), | ||
os.path.join(meson_root, 'libmimalloc-static.a'), | ||
], | ||
extra_link_args=['-lm'] | ||
) | ||
|
||
|
||
def get_readme(): | ||
try: | ||
|
@@ -128,8 +30,8 @@ def get_readme(): | |
version=python_version, | ||
long_description=get_readme(), | ||
long_description_content_type='text/markdown', | ||
license = 'AGPLv3', | ||
keywords = 'zenroom crypto-language-processing virtual-machine blockchain crypto ecc dyne ecdh ecdsa zero-knowledge-proofs javascript npm ecp2 miller-loop hamming-distance elgamal aes-gcm aead seccomp goldilocks'.split(), | ||
license='AGPLv3', | ||
keywords='zenroom crypto-language-processing virtual-machine blockchain crypto ecc dyne ecdh ecdsa zero-knowledge-proofs javascript npm ecp2 miller-loop hamming-distance elgamal aes-gcm aead seccomp goldilocks'.split(), | ||
url='https://github.com/dyne/Zenroom', | ||
author='Danilo Spinella, David Dashyan, Puria Nafisi Azizi', | ||
author_email='[email protected], [email protected], [email protected]', | ||
|
@@ -154,7 +56,6 @@ def get_readme(): | |
}, | ||
packages=['zenroom'], | ||
include_package_data=True, | ||
ext_modules=[zenroom_lib], | ||
python_requires='>=3.8, <4', | ||
extras_require={ | ||
'dev': [], | ||
|
Oops, something went wrong.