Skip to content

Commit 5a410ef

Browse files
committed
make various binary distributions
1 parent 04e57c5 commit 5a410ef

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ build.sh
88
depends/qaptools/build/
99
examples/pysnark_*
1010
examples/out
11+
MANIFEST.in
12+
qaptools/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Build and install PySNARK (assuming `python` is Python 3):
5353
python setup.py install
5454
```
5555

56-
To disable the qaptools backend, use `--disable-qaptools`. To disable the libsnark backend, use `--disable-libsnark`. To specify locations of precompiled qaptools binaries (e.g., for Windows), use `--qaptools=bin=<dir>`. Any CMake arguments (`-D...`), for example, for libsnark, can be given direcly on the above command line. For example, on Mac OS X I use `python3 setup.py install -DCMAKE_PREFIX_PATH=/usr/local/Cellar/openssl/1.0.2s -DCMAKE_SHARED_LINKER_FLAGS=-L/usr/local/Cellar/openssl/1.0.2s/lib -DWITH_PROCPS=OFF -DWITH_SUPERCOP=OFF -DOPT_FLAGS=-std=c++11`.
56+
To disable the qaptools backend, use `--disable-qaptools`. To disable the libsnark backend, use `--disable-libsnark`. To specify locations of precompiled qaptools binaries (e.g., for Windows), use `--qaptools=bin=<dir>`. Any CMake arguments (`-D...`), for example, for libsnark, can be given direcly on the above command line. For example, on Mac OS X I use `python3 setup.py install -DCMAKE_PREFIX_PATH=/usr/local/Cellar/openssl/1.0.2t -DCMAKE_SHARED_LINKER_FLAGS=-L/usr/local/Cellar/openssl/1.0.2t/lib -DWITH_PROCPS=OFF -DWITH_SUPERCOP=OFF -DOPT_FLAGS=-std=c++11`.
5757

5858

5959
## Using PySNARK (libsnark backend)

setup.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
# and https://github.com/m-pilia/disptools/blob/master/python_c_extension/CMakeLists.txt
55

66
import os
7+
import os.path
78
import shutil
89
import subprocess
910
import sys
1011

12+
import setuptools.command.egg_info
1113
from setuptools import setup, Extension
1214
from setuptools.command.build_ext import build_ext
1315

@@ -23,6 +25,9 @@
2325
if "--disable-libsnark" in sys.argv:
2426
disable_libsnark = True
2527
sys.argv.remove("--disable-libsnark")
28+
if not os.path.isfile("depends/python-libsnark/CMakeLists.txt"):
29+
print("*** depends/python-libsnark/CMakeLists.txt not found, disabling libsnark backend")
30+
disable_libsnark = True
2631

2732
disable_qaptools = False
2833
if "--disable-qaptools" in sys.argv:
@@ -36,6 +41,29 @@
3641
sys.argv.remove(i)
3742
break
3843

44+
if qaptools_bin is None and os.path.isfile("qaptools/qapgen" + (".exe" if os.name=="nt" else "")):
45+
print("*** Using detected qaptools in qaptools/")
46+
qaptools_bin="qaptools"
47+
48+
if qaptools_bin is None and not os.path.isfile("depends/qaptools/CMakeLists.txt"):
49+
print("*** depends/qaptools/CMakeLists.txt not found, disabling libsnark backend")
50+
disable_qaptools = True
51+
52+
# write manifest
53+
print("writing MANIFEST.in")
54+
mfest = open("MANIFEST.in", "w")
55+
print("recursive-include examples *.py", file=mfest)
56+
print("include examples/binarycircuit_example.txt", file=mfest)
57+
if not disable_qaptools:
58+
if qaptools_bin:
59+
print("recursive-include", qaptools_bin, "*", file=mfest)
60+
else:
61+
print("recursive-include depends/qaptools *", file=mfest)
62+
if not disable_libsnark: print("recursive-include depends/python-libsnark *", file=mfest)
63+
print("include LICENSE.md", file=mfest)
64+
mfest.close()
65+
66+
3967
def use_qaptools_bins(target):
4068
apps = ['qapgen', 'qapgenf', 'qapinput', 'qapcoeffcache', 'qapprove', 'qapver']
4169
exefix = '.exe' if os.name == 'nt' else ''
@@ -97,7 +125,7 @@ def build_extensions(self):
97125

98126

99127
setup(name='PySNARK',
100-
version='0.2',
128+
version='0.2' + ('-nols' if disable_libsnark else '') + ('-noqt' if disable_qaptools else ''),
101129
description='Python zk-SNARK execution environment',
102130
author='Meilof Veeningen',
103131
author_email='[email protected]',

0 commit comments

Comments
 (0)