Add ability to set python module file string instead of it always being None
Environment
- Pythonnet version: Latest
- Python version: 3.7+
- Operating System: All
- .NET Runtime: All
Details
-
Describe what you were trying to get done.
When creating a python module from a string (PyModule FromString) the file parameter is always set to None. If I want to create a virtual package structure in memory I need to be able to set file to a specified file structure.
You have to set it yourself, that's how it works in the C-API as well: https://docs.python.org/3/c-api/module.html#c.PyModule_NewObject
Sorry, I just saw your PR (#2044), is this not the same as just setting __file__ explicitly on the PyModule object?
Yes, it is the same thing. It just seems a bit clunky that it is initially set to none then I have to overwrite it with the correct file structure.