GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cannot compile python bindings · Issue #247 · xtensor-stack/xtensor-python

Cannot compile python bindings #247

New issue
Copy link
New issue
Copy link
Open
Open
Cannot compile python bindings#247
Copy link

Description

@sbuschjaeger
sbuschjaeger
opened on Dec 3, 2020
Issue body actions

I have some issues compiling python bindings for my project involving xtensor.
My CMakeList.txt looks like this

cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(XTensorPythonTest LANGUAGES CXX)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_FLAGS "-Wall -Wextra -g")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -march=native -mtune=native")

find_package(xtl REQUIRED)
find_package(xtensor REQUIRED)

find_package(xtensor-python REQUIRED)
find_package(pybind11 REQUIRED)
find_package(NumPy REQUIRED)

message(STATUS "Found numpy: ${NUMPY_INCLUDE_DIRS}")

# These are my includes
include_directories("./include")

# xtensor-python requires numpy includes
include_directories(${NUMPY_INCLUDE_DIRS})

add_executable(run_tests ${SOURCES} run_tests.cpp)

target_link_libraries(run_tests xtensor xtensor::optimize xtensor::use_xsimd xtensor-python)
pybind11_add_module(XTensorPythonTest include/Python.cpp)

with Python.cpp

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
// #include <pybind11/stl_bind.h>
#include <pybind11/operators.h>
#include <pybind11/functional.h>

#define FORCE_IMPORT_ARRAY
#include "xtensor-python/pyarray.hpp"     // Numpy bindings

// My includes

namespace py = pybind11;

PYBIND11_MODULE(XTensorPythonTest, m) {
/* PyBind Stuff */
}

My conda environment has installed:

  • xtensor 0.21.10
  • xtensor-python 0.24.1
  • pybind11 2.4.3
  • numpy 1.19.2

I use gcc 10.2 (system installation) and cmake 3.19.1 (system installation). I also have copied FindNumPy.cmake into cmake/ (Which would have been helpful if documentation would mention this)

Now during compilation I get

include/pybind11/cast.h:921:43: error: ‘std::remove_reference<pybind11::detail::type_caster<xt::xarray_container<xt::uvector<double, std::allocator<double> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, void>&>::type’ {aka ‘class pybind11::detail::type_caster<xt::xarray_container<xt::uvector<double, std::allocator<double> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, void>’} has no member named ‘operator pybind11::detail::xtensor_type_caster_base<xt::xarray_container<xt::uvector<double, std::allocator<double> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag> >::cast_op_type<const xt::xarray_container<xt::uvector<double, std::allocator<double> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>&>’
  920 |     return std::move(caster).operator
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~      
  921 |         typename make_caster<T>::template cast_op_type<typename std::add_rvalue_reference<T>::type>();

...

cast.h:921:43: error: ‘std::remove_reference<pybind11::detail::type_caster<xt::xarray_container<xt::uvector<unsigned int, std::allocator<unsigned int> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, void>&>::type’ {aka ‘class pybind11::detail::type_caster<xt::xarray_container<xt::uvector<unsigned int, std::allocator<unsigned int> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, void>’} has no member named ‘operator pybind11::detail::xtensor_type_caster_base<xt::xarray_container<xt::uvector<unsigned int, std::allocator<unsigned int> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag> >::cast_op_type<const xt::xarray_container<xt::uvector<unsigned int, std::allocator<unsigned int> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>&>’
make[2]: *** [CMakeFiles/PyBPE.dir/build.make:82: CMakeFiles/PyBPE.dir/include/Python.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/PyBPE.dir/all] Error 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.