Skip to content

Commit

Permalink
Use CMake FetchContent to install pybind11 (watercompany#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmang9 authored May 18, 2020
1 parent bef9f1e commit e0de0b2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests -s


- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
Expand Down
12 changes: 10 additions & 2 deletions 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 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -26,7 +26,15 @@ include_directories(

add_library(fse ${FSE_FILES})

add_subdirectory(lib/pybind11)
# 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(chiapos ${CMAKE_CURRENT_SOURCE_DIR}/python-bindings/chiapos.cpp)

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ format, move to chacha8, and otherwise improve plotting performance.
### Compile

```bash
# Optional as CMake will install pybind11 src
git submodule update --init --recursive

mkdir -p build && cd build
Expand Down Expand Up @@ -86,11 +87,11 @@ py.test ./tests -s -v
## 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
[cibuildwheel](https://github.com/joerick/cibuildwheel). Further installation
is then available via `pip install chiapos` e.g.
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). Building is then
managed by [cibuildwheel](https://github.com/joerick/cibuildwheel). Further
installation is then available via `pip install chiapos` e.g.

## Contributing and workflow
Contributions are welcome and more details are available in chia-blockchain's
Expand Down
6 changes: 0 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ def run(self):
+ " 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))
Expand Down

0 comments on commit e0de0b2

Please sign in to comment.