-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
clif.python.abc_utils
with abc_utils.PyCLIFABCMeta
.
This CL makes it possible to choose between `_USE_PYTYPE_TYPE_AS_METACLASS` `True` or `False` in clif/pybind11/classes.py. **TO BE DETERMINED:** Choice of metaclass when rolling out PyCLIF-pybind11. Setting `_USE_PYTYPE_TYPE_AS_METACLASS = True` in this CL, for compatibility with PyCLIF-C-API. TGP-tested **fresh** with `_USE_PYTYPE_TYPE_AS_METACLASS = False` and in combination with child CLs cl/603786594 (mox.py) and cl/603757382 (sprawling changes): * http://tap/OCL:603885130:BASE:604107736:1707063723806:7ef9954a TGP **rerun** with `_USE_PYTYPE_TYPE_AS_METACLASS = True`: * http://tap/OCL:603885130:BASE:604107736:1707077805857:f8d8b6a3 (25 passing) * b/287289622#comment59 shows the 25 passing targets Additional manual testing with `_USE_PYTYPE_TYPE_AS_METACLASS = False`: ``` blaze test third_party/clif/testing/python:classes_test --//devtools/clif/python:pyclif_codegen_mode=pybind11 ``` * http://sponge2/57affbde-047e-42d2-a04c-2acea2c5430c PiperOrigin-RevId: 605333960
- Loading branch information
Showing
6 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""PyCLIF-pybind11 abc compatibility (in particular abc.ABCMeta). | ||
This is for compatibility between the "default pybind11 metaclass" | ||
(which is a custom metaclass) and https://docs.python.org/3/library/abc.html. | ||
For background see: | ||
* Description of https://github.com/pybind/pybind11/pull/5015 | ||
* Corresponding tests in clif/testing/python/classes_test.py | ||
""" | ||
|
||
import abc | ||
import typing | ||
|
||
from clif.python import _meta_ext | ||
|
||
PyCLIFMeta = type(_meta_ext.empty) | ||
|
||
|
||
if typing.TYPE_CHECKING: | ||
PyCLIFABCMeta = abc.ABCMeta | ||
else: | ||
|
||
class PyCLIFABCMeta(abc.ABCMeta, PyCLIFMeta): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from "clif/python/meta_ext.h": | ||
namespace `clif_meta_ext`: | ||
class empty: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef CLIF_PYTHON_META_EXT_H_ | ||
#define CLIF_PYTHON_META_EXT_H_ | ||
|
||
namespace clif_meta_ext { | ||
|
||
struct empty {}; | ||
|
||
} // namespace clif_meta_ext | ||
|
||
#endif // CLIF_PYTHON_META_EXT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters