Skip to content

Commit

Permalink
Merge branch 'master' into new_code
Browse files Browse the repository at this point in the history
  • Loading branch information
fchirica committed May 18, 2020
2 parents c0646f9 + a56e037 commit c03743c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 32 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
fetch-depth: 0
# we need fetch-depth 0 so setuptools_scm can resolve tags

- name: Checkout submodules
uses: snickerbockers/submodules-init@v4

- uses: actions/setup-python@v1
name: Install Python
with:
Expand All @@ -28,7 +25,8 @@ jobs:
- name: Install cibuildwheel
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel==1.3.0
pip install wheel
pip install cibuildwheel==1.3.0
- name: Lint source with flake8
run: |
Expand All @@ -46,7 +44,7 @@ jobs:
pip install pep517
python -m pep517.build --source --out-dir dist .
- name: Build ${{ matrix.os }} wheels
- name: Build ${{ matrix.os }} wheels and test
run: |
python -m cibuildwheel --output-dir dist
env:
Expand All @@ -56,16 +54,41 @@ jobs:
CIBW_SKIP: '*-manylinux_i686 *-win32'
# we need boost
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_BUILD_LINUX: curl -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-`uname -m`.sh > cmake.sh && yes | sh cmake.sh | cat && rm -f /usr/bin/cmake && yum -y install boost-devel gmp-devel && python -m pip install --upgrade pip && which cmake && cmake --version
CIBW_BEFORE_BUILD_MACOS: brew install boost && python -m pip install --upgrade pip
CIBW_BEFORE_BUILD_LINUX: >
curl -L https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-`uname -m`.sh > cmake.sh
&& yes | sh cmake.sh | cat
&& rm -f /usr/bin/cmake
&& yum -y install boost-devel gmp-devel
&& python -m pip install --upgrade pip
CIBW_BEFORE_BUILD_MACOS: >
brew install boost
&& python -m pip install --upgrade pip
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=10.14
CIBW_BUILD_VERBOSITY_MACOS: 0
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests
CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.0-Linux-`uname -m`/bin:$PATH BUILD_VDF_CLIENT=N"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: "pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git && delocate-listdeps {wheel} && delocate-wheel -v {wheel} && cp {wheel} {dest_dir} && ls -l {dest_dir} && pwd && ls -l dist"
CIBW_BEFORE_BUILD_WINDOWS: python -m pip install --upgrade pip && pwd && git clone https://github.com/Chia-Network/mpir_gc_x64.git && ls -l mpir_gc_x64
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "ls -l mpir_gc_x64 && pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git && delocate-wheel -v -i mpir_gc_x64/mpir.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_gc.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_broadwell.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_broadwell_avx.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_bulldozer.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_haswell.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_piledriver.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_skylake.dll {wheel} && delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel} && cp {wheel} {dest_dir} && ls -l {dest_dir} && pwd && ls -l dist && rm -fr mpir_gc_x64"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
pip uninstall -y delocate && pip install git+https://github.com/Chia-Network/delocate.git
&& delocate-listdeps {wheel} && delocate-wheel -v {wheel}
&& cp {wheel} {dest_dir}
CIBW_BEFORE_BUILD_WINDOWS: >
python -m pip install --upgrade pip
&& git clone https://github.com/Chia-Network/mpir_gc_x64.git
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
ls -l mpir_gc_x64 && pip uninstall -y delocate
&& pip install git+https://github.com/Chia-Network/delocate.git
&& delocate-wheel -v -i mpir_gc_x64/mpir.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_gc.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_broadwell.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_broadwell_avx.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_bulldozer.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_haswell.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_piledriver.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_skylake.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel}
&& cp {wheel} {dest_dir}
&& rm -rf mpir_gc_x64
- name: Upload artifacts
uses: actions/upload-artifact@v1
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
## Building
This component requires cmake, boost and GMP.
```
git submodule update --init --recursive
pip install wheel setuptools_scm
pip wheel .
```

The primary build process for this repository is to use GitHub Actions to
build binary wheels for MacOS, Linux, and Windows and publish them with
a source wheel on PyPi. See `.github/workflows/build.yml`. setup.py adds
a dependency on [pybind11](https://github.com/pybind/pybind11) that is then
managed by [cibuildwheel](https://github.com/joerick/cibuildwheel). Further
installation is then available via `pip install chiavdf` e.g.
a dependency on [pybind11](https://github.com/pybind/pybind11) by invoking git
to check out the pybind submodules. Building is then managed by
[cibuildwheel](https://github.com/joerick/cibuildwheel). Further installation
is then available via `pip install chiavdf` e.g.

## Building Timelord and related binaries
In addition to building the required binary and source wheels for Windows,
MacOS and Linux, chiavdf can be used to compile vdf_client and vdf_bench.
vdf_client is the core VDF process that completes the Proof of Time submitted
to it by the Timelord. This also includes a benchmarking tool to get a sense
of the iterations per second of a given CPU called vdf_bench. Try
to it by the Timelord. The repo also includes a benchmarking tool to get a
sense of the iterations per second of a given CPU called vdf_bench. Try
`./vdf_bench square_asm 250000` for an ips estimate.

To build vdf_client set the environment variable BUILD_VDF_CLIENT to "Y".
Expand All @@ -39,7 +39,8 @@ Similarly, to build vdf_bench set the environment variable BUILD_VDF_BENCH to

This is currently automated in the
[install-timelord.sh](https://github.com/Chia-Network/chia-blockchain/blob/master/install-timelord.sh)
script in the [chia-blockchain repository](https://github.com/Chia-Network/chia-blockchain)
script in the
[chia-blockchain repository](https://github.com/Chia-Network/chia-blockchain)
which depends on this repository.

## Contributing and workflow
Expand Down
32 changes: 18 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ def run(self):
class build_hook(HookCommand):
hooks = BUILD_HOOKS


class install_hook(HookCommand):
hooks = INSTALL_HOOKS




############################################


Expand All @@ -66,7 +64,6 @@ def __init__(self, name, sourcedir=''):
self.sourcedir = os.path.abspath(sourcedir)



def copy_vdf_client(build_dir, install_dir):
shutil.copy("src/vdf_client", install_dir)
shutil.copy("src/prover_test", install_dir)
Expand All @@ -92,7 +89,6 @@ def invoke_make(**kwargs):
if BUILD_VDF_CLIENT:
add_install_hook(copy_vdf_client)


if BUILD_VDF_BENCH:
add_install_hook(copy_vdf_bench)

Expand All @@ -105,10 +101,15 @@ def run(self):
raise RuntimeError("CMake must be installed to build" +
" the following extensions: " +
", ".join(e.name for e in self.extensions))
"""
Work around pybind11's need to be on the filesystem
"""
if os.path.exists('.gitmodules'):
out = subprocess.run(['git', 'submodule', 'update', '--init', '--recursive'])

if platform.system() == "Windows":
cmake_version = LooseVersion(
re.search(r'version\s*([\d.]+)', out.decode()).group(1))
re.search(r'version\s*([\d.]+)', out.decode()).group(1))
if cmake_version < '3.1.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows")

Expand Down Expand Up @@ -159,10 +160,12 @@ def __str__(self):
ext_modules = [
Extension(
'chiavdf',
[
"src/python_bindings/fastvdf.cpp",
"src/refcode/lzcnt.c",
],
sorted (
[
"src/python_bindings/fastvdf.cpp",
"src/refcode/lzcnt.c",
]
),
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
Expand Down Expand Up @@ -239,9 +242,7 @@ def build_extensions(self):
build_ext.build_extensions(self)


import platform

if platform.system()=="Windows":
if platform.system() == "Windows":
setup(
name='chiavdf',
author='Mariano Sorgente',
Expand All @@ -252,6 +253,7 @@ def build_extensions(self):
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
build_requires=["pybind11"],
url="https://github.com/Chia-Network/chiavdf",
ext_modules=ext_modules,
cmdclass={'build_ext': BuildExt},
zip_safe=False,
Expand All @@ -266,9 +268,11 @@ def build_extensions(self):
author_email='[email protected]',
description='Chia vdf verification (wraps C++)',
license='Apache License',
python_requires='>=3.5',
python_requires='>=3.7',
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
url="https://github.com/Chia-Network/chiavdf",
setup_requires=['pybind11>=2.5.0'],
ext_modules=[CMakeExtension('chiavdf', 'src')],
cmdclass=dict(build_ext=CMakeBuild, install_hook=install_hook, build_hook=build_hook),
zip_safe=False,
Expand Down
1 change: 0 additions & 1 deletion src/classgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def __new__(cls, t):
return tuple.__new__(cls, (a, b, c))

def __init__(self, t):
a, b, c = t
super(ClassGroup, self).__init__()
self._discriminant = None

Expand Down

0 comments on commit c03743c

Please sign in to comment.