pybind / cmake_example

Example pybind11 module built with a CMake-based build system
Other
626 stars 221 forks source link

Where do I need to edit something in setup.py for my custom project #35

Closed AutoSenseTech closed 3 years ago

AutoSenseTech commented 3 years ago

I write a library called AVP_Binding in c++ and want to import AVP_Binding in python. Everything is ok. c++ library can be compiled successfully and generate AVP-Binding.cpython-36m-x86_64-linux-gnu.so also. My os is ubuntu 18.04, and I run pip install . in virtual enviorment in anacoda(python 3.6, cmake 3.14). But when I run pip install . with the same setup.py in cmake_example it failed. The error follows:

Processing /home/xxx/Documents/my_project/AVP_Binding
Building wheels for collected packages: AVP-Binding
  Building wheel for AVP-Binding (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/xxx/anaconda3/envs/habitat/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-qbwspzl2
       cwd: /tmp/pip-req-build-gvd95haj/
  Complete output (45 lines):
  running bdist_wheel
  running build
  running build_ext
  CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
  CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
  -- Configuring incomplete, errors occurred!
  See also "/tmp/pip-req-build-gvd95haj/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-gvd95haj/setup.py", line 113, in <module>
      zip_safe=False,
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
      _build_ext.run(self)
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
      self._build_extensions_serial()
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
      self.build_extension(ext)
    File "/tmp/pip-req-build-gvd95haj/setup.py", line 95, in build_extension
      ["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
    File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/subprocess.py", line 311, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-req-build-gvd95haj', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-req-build-gvd95haj/build/lib.linux-x86_64-3.6/', '-DPYTHON_EXECUTABLE=/home/xxx/anaconda3/envs/habitat/bin/python', '-DEXAMPLE_VERSION_INFO=0.0.1', '-DCMAKE_BUILD_TYPE=Release', '-GNinja']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for AVP-Binding
  Running setup.py clean for AVP-Binding
Failed to build AVP-Binding
Installing collected packages: AVP-Binding
    Running setup.py install for AVP-Binding ... error
    ERROR: Command errored out with exit status 1:
     command: /home/xxx/anaconda3/envs/habitat/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vd7n5m0r/install-record.txt --single-version-externally-managed --compile --install-headers /home/xxx/anaconda3/envs/habitat/include/python3.6m/AVP-Binding
         cwd: /tmp/pip-req-build-gvd95haj/
    Complete output (47 lines):
    running install
    running build
    running build_ext
    CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
    CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    -- Configuring incomplete, errors occurred!
    See also "/tmp/pip-req-build-gvd95haj/build/temp.linux-x86_64-3.6/CMakeFiles/CMakeOutput.log".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-gvd95haj/setup.py", line 113, in <module>
        zip_safe=False,
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 79, in run
        _build_ext.run(self)
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 339, in run
        self.build_extensions()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
        self._build_extensions_serial()
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
        self.build_extension(ext)
      File "/tmp/pip-req-build-gvd95haj/setup.py", line 95, in build_extension
        ["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp
      File "/home/xxx/anaconda3/envs/habitat/lib/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', '/tmp/pip-req-build-gvd95haj', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-req-build-gvd95haj/build/lib.linux-x86_64-3.6/', '-DPYTHON_EXECUTABLE=/home/xxx/anaconda3/envs/habitat/bin/python', '-DEXAMPLE_VERSION_INFO=0.0.1', '-DCMAKE_BUILD_TYPE=Release', '-GNinja']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/xxx/anaconda3/envs/habitat/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-gvd95haj/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vd7n5m0r/install-record.txt --single-version-externally-managed --compile --install-headers /home/xxx/anaconda3/envs/habitat/include/python3.6m/AVP-Binding Check the logs for full command output.

Besides name, author, author_email and description in setup, do I need to modify anything else in this setup.py? My project is here https://github.com/wwtx9/AVP_Binding. It may help to find problem.

AutoSenseTech commented 3 years ago

I found the problem which I miss the .toml file