Skip to content

Commit

Permalink
Use FetchContent to get pybind11 (Chia-Network#111)
Browse files Browse the repository at this point in the history
* Use FetchContent to get pybind11 src
* Only add_subdir for python-bindings
* Update readme for CMake version and python version in setup.py
  • Loading branch information
hoffmang9 authored May 19, 2020
1 parent 28559ac commit 9d6c442
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ jobs:
&& delocate-wheel -v {wheel}
&& cp {wheel} {dest_dir}
- name: Checkout submodules
uses: snickerbockers/submodules-init@v4
# - name: Checkout submodules
# uses: snickerbockers/submodules-init@v4

- name: Mac OS build C++ and test
if: startsWith(matrix.os, 'macos')
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,5 @@ if (EMSCRIPTEN)
add_subdirectory(js-bindings)
else()
# emscripten can't build python bindings, it produces only javascript
add_subdirectory(contrib/pybind11)
add_subdirectory(python-bindings)
endif()
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@ prependAgg.Verify(hashes, prependPubKeys);
```

### Build
Cmake, a c++ compiler, and python3 (for bindings) are required for building.
Cmake 3.14+, a c++ compiler, and python3 (for bindings) are required for building.
```bash
git submodule update --init --recursive

mkdir build
cd build
cmake ../
Expand Down Expand Up @@ -292,26 +293,28 @@ PrependSignatures, which prepend public keys to messages, making them secure.
### ci Building
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) by invoking git
to check out the pybind submodules. Building is then managed by
a source wheel on PyPi. See `.github/workflows/build.yml`. CMake uses
[FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)
to download [pybind11](https://github.com/pybind/pybind11) for the Python
bindings. Building is then managed by
[cibuildwheel](https://github.com/joerick/cibuildwheel). Further installation
is then available via `pip install chiapos` e.g. The ci builds include GMP and
is then available via `pip install blspy` e.g. The ci builds include GMP and
libsoduium.

### Contributing and workflow
Contributions are welcome and more details are available in chia-blockchain's
[CONTRIBUTING.md](https://github.com/Chia-Network/chia-blockchain/blob/master/CONTRIBUTING.md).

The master branch is usually the currently released latest version on PyPI.
Note that at times bls-signatures/blspy will be ahead of the release version that
chia-blockchain requires in it's master/release version in preparation for a
new chia-blockchain release. Please branch or fork master and then create a
pull request to the master branch. Linear merging is enforced on master and
Note that at times bls-signatures/blspy will be ahead of the release version
that chia-blockchain requires in it's master/release version in preparation
for a new chia-blockchain release. Please branch or fork master and then create
a pull request to the master branch. Linear merging is enforced on master and
merging requires a completed review. PRs will kick off a GitHub actions ci build
and analysis of bls-signatures at
[lgtm.com](https://lgtm.com/projects/g/Chia-Network/chiapos/?mode=list). Please
make sure your build is passing and that it does not increase alerts at lgtm.
[lgtm.com](https://lgtm.com/projects/g/Chia-Network/bls-signatures/?mode=list).
Please make sure your build is passing and that it does not increase alerts
at lgtm.

### Specification and test vectors
The specification and test vectors can be found
Expand Down
12 changes: 11 additions & 1 deletion python-bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR)
set (CMAKE_CXX_STANDARD 11)

include_directories(
Expand All @@ -8,6 +8,16 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../contrib/catch
)

# CMake 3.14+
include(FetchContent)

FetchContent_Declare(
pybind11-src
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.5.0
)
FetchContent_MakeAvailable(pybind11-src)

pybind11_add_module(blspy ${CMAKE_CURRENT_SOURCE_DIR}/pythonbindings.cpp)

if (SODIUM_FOUND)
Expand Down
12 changes: 1 addition & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ def run(self):
if cmake_version < '3.1.0':
raise RuntimeError("CMake >= 3.1.0 is required on Windows")

"""
Work around pybind11's need to be on the filesystem
"""
if os.path.exists('.gitmodules'):
try:
subprocess.run(['git', 'submodule', 'update', '--init', '--recursive'])
except OSError:
raise RuntimeError("git is not available"
+ ", ".join(e.name for e in self.extensions))

for ext in self.extensions:
self.build_extension(ext)

Expand Down Expand Up @@ -209,7 +199,7 @@ def build_extensions(self):
author='Mariano Sorgente',
author_email='[email protected]',
description='BLS signatures in c++ (python bindings)',
python_requires='>3.1',
python_requires='>3.7',
install_requires=["wheel"],
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 9d6c442

Please sign in to comment.