Skip to content

Implement py_extension rule #3283

@rickeylev

Description

@rickeylev

This is a tracking issue to design and implement a rule, py_extension whose purpose is to create Python C extension objects.

A Python C extension itself is fairly simple: a shared library with a PyInit_<name> symbol. What makes it complicated are the myriad of different C++ linkages the extension may be used with.

I've written rules_python py_extension design to go into detail about the cases and design I'm currently thinking.

In short, there are 6 types of linkages, which come from two ways a terminal binary links its external dependencies and three ways a py_extension links its external dependencies, and how overlapping external dependencies are handled when those interact. (what constitutes "external" depends on the situation, but is usually code it doesn't own)

The most relevant use case is:

  • A prebuilt Python binary (i.e. RPATH is unknown)
  • A dynamically linked extension (whose RPATH we can control)
  • In a virtual environment site-packages layout (i.e. the relative location of libraries is assumed)

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