Poetry: support for non-python extensions

Created on 4 Sep 2019  路  3Comments  路  Source: python-poetry/poetry

  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] I have searched the documentation and believe that my question is not covered.

Question


Hi, thanks for poetry!
My Python projects for HPC/scientific computing rely heavily on extension modules, written in C++ using pybind11, or Fortran using f2py. The building process is currently organised with CMake (to great satisfaction). Could anyone give me some information about how I can make use of Poetry to package such projects and deploy them to PyPI?
if possible I'd appreciated being pointed to the relevant poetry files to try and understand how the machinery works :)
many thanks in advance.

Feature

Most helpful comment

I am currently using poetry to build multiple projects using cython and pybind11 extensions.

  • As described in https://github.com/sdispater/poetry/issues/11 you'll need to add
    toml [tool.poetry] build = "build.py"
    to the pyproject.toml, and create an appropriate build.py file alongside pyproject.toml.
  • This gist includes the contents of the build.py file (referenced in the previous bullet) that I use with one of my projects containing both cython and pybind11 extensions (the extension names/paths have been changed).

    Depending on your use of CMake, it may require some changes, but it should be simple enough to just read through what it does and make any necessary modifications.

I haven't deployed any packages to PyPI, but I do use poetry build to generate a platform-specific wheel and source distribution; presumably this is ready for publishing.

You may want/need to fiddle with the packages and/or exclude keys in the [tool.poetry] section of the pyproject.toml to build a source distribution / wheel with the right contents. (E.g., if using pybind11 as a git submodule, you'd probably want to exclude its .git folder.)

All 3 comments

I am currently using poetry to build multiple projects using cython and pybind11 extensions.

  • As described in https://github.com/sdispater/poetry/issues/11 you'll need to add
    toml [tool.poetry] build = "build.py"
    to the pyproject.toml, and create an appropriate build.py file alongside pyproject.toml.
  • This gist includes the contents of the build.py file (referenced in the previous bullet) that I use with one of my projects containing both cython and pybind11 extensions (the extension names/paths have been changed).

    Depending on your use of CMake, it may require some changes, but it should be simple enough to just read through what it does and make any necessary modifications.

I haven't deployed any packages to PyPI, but I do use poetry build to generate a platform-specific wheel and source distribution; presumably this is ready for publishing.

You may want/need to fiddle with the packages and/or exclude keys in the [tool.poetry] section of the pyproject.toml to build a source distribution / wheel with the right contents. (E.g., if using pybind11 as a git submodule, you'd probably want to exclude its .git folder.)

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

It would be nice if something akin to setup.cfg/setup.py's approach for console_scripts could be specified under the [tool.poetry] table. Right now I just write a script that just imports a module with a function from a dev dependency named build and nothing else (i.e., from developement_dependency.module import build). It'd be neat if I could just do development_dependency.module_name:function or something to that effect. Then full packages could be used instead of per-project files.

Was this page helpful?
0 / 5 - 0 ratings