Proposal: Implement binding manager to hold binding overrides by koubaa · Pull Request #2543 · pythonnet/pythonnet
Repository navigation
Proposal: Implement binding manager to hold binding overrides - #2543
Open
koubaa wants to merge 1 commit into pythonnet:master from koubaa:add-binding-options-upstream
Open
Proposal: Implement binding manager to hold binding overrides #2543 koubaa wants to merge 1 commit into pythonnet:master from koubaa:add-binding-options-upstream
Conversation
koubaa commented Jan 13, 2025 · edited Loading
Copy link Copy Markdown
Contributor
What does this implement/fix? Explain your changes.
This adds a place to register at runtime options to customize the binding of types. This customization can be specified at a type or assembly level.
Does this close any currently open issues?
No, but it can be used as a way to close issues going forwards - especially in cases where there is disagreement about what the correct way to bind to python, or if there are legacy compatibility reasons to bind in a way that is not the default way. For example, in the ansys-pythonnet fork, this is proposed to be used in two ways:
- to bind properties and methods coming from explicit interface implementation in order to satisfy a requirement in one library for compatibility with legacy IronPython scripts. In IronPython, explicit interface implementations are provided in Python, even when that is not the idiomatic choice.
- to automatically add pep8 aliases , allowing python code to use normal python style even when the C# library uses the normal C# style.
As this is just a proposal - I will move forward with the checklist if the maintainers of pythonnet agree with the direction.
Example usage (from python)
m = clr.AddReference('MyLib')
from Python.Runtime import BindingManager, BindingOptions
binding_options = BindingOptions()
binding_options.SuppressDocs = True
BindingManager.SetBindingOptions(m, binding_options)
Checklist
Check all those that are applicable and complete.
- Make sure to include one or more tests for your change
- If an enhancement PR, please create docs and at best an example
- Ensure you have signed the .NET Foundation CLA
- Add yourself to
AUTHORS - Updated the
CHANGELOG
0295dd2 to
fe63b01
Compare
December 8, 2025 10:33
koubaa commented Feb 26, 2026
Copy link Copy Markdown
Contributor
Author
|
@filmor is this PR under consideration? |
lostmsu commented Feb 27, 2026 · edited Loading
Copy link Copy Markdown
Member
|
We wouldn't want to have binding options as it immensely increases the test matrix: every toggle doubles the space to test. A option to completely override the binding mechanism with deferring the responsibility to the user might be a good idea, but that would require exceptionally careful work with virtual methods. |
filmor commented May 13, 2026
Copy link Copy Markdown
Member
|
@koubaa I would like to take this into consideration after we have finally landed the 3.14 changes some time this week. I would like to revisit the interface, though. I'm not a huge fan of using Python.NET to configure itself (documenting the |
koubaa commented May 18, 2026
Copy link Copy Markdown
Contributor
Author
|
@filmor @lostmsu I would be open to working on this if you have any API designs you'd like to explore |
Implement binding manager to hold binding overrides
fcf0bea
filmor
force-pushed
the
add-binding-options-upstream
branch
from
fe63b01 to
fcf0bea
Compare
September 29, 2026 12:00
This branch has not been deployed
No deployments
Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment