You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Building Python 2 and Python 3 support in parallel #18
Hi,
Got the same need, I need to run python2 & python3 code at the same time. And having 2 instance of Inline::Python one binded on python2 and the other on python3 but it doesn't work because I guess they are using the same namespace from the C library.
There's just no way that Inline::Python could support Python 2 and Python 3 in the same program at the same time for the same reason that the switch to Python 3 requires you to upgrade all of your program including all libraries to Python 3. The Python interpreter uses the same symbol names (i.e. functions) in both versions and the linker gets confused by that.
There would actually have been a way for them to work around this: run Python 2 and Python 3 in different processes and forward calls and data over some kind of IPC mechanism. That's really not that different from how Inline::Python works (or Inline::Perl5 for example). If you really need to use both Python versions in a program, you could do the same.
As for supporting both Python version in a single build, that would certainly be possible. It would probably not even be all that hard. But it would be a major refactor of the build system and would require restructuring of the code, i.e. just a lot of work. I would definitely support someone doing this and be happy to take pull requests. Considering the existing workarounds (like local::lib) I just don't see this ever making it up far enough on my TODO list for me to do this all on my own. That we have Python 3 at all was due to the great work of @Imazuel
Activity
marghidanu commentedon Jul 7, 2017
Use separate developments, something like local::lib. This way you can add multiple installations against different Python versions.
Zer0-Tolerance commentedon Jun 29, 2019
Hi,
Got the same need, I need to run python2 & python3 code at the same time. And having 2 instance of Inline::Python one binded on python2 and the other on python3 but it doesn't work because I guess they are using the same namespace from the C library.
Any idea how to build two different flavour ?
niner commentedon Jun 30, 2019
There's just no way that Inline::Python could support Python 2 and Python 3 in the same program at the same time for the same reason that the switch to Python 3 requires you to upgrade all of your program including all libraries to Python 3. The Python interpreter uses the same symbol names (i.e. functions) in both versions and the linker gets confused by that.
There would actually have been a way for them to work around this: run Python 2 and Python 3 in different processes and forward calls and data over some kind of IPC mechanism. That's really not that different from how Inline::Python works (or Inline::Perl5 for example). If you really need to use both Python versions in a program, you could do the same.
As for supporting both Python version in a single build, that would certainly be possible. It would probably not even be all that hard. But it would be a major refactor of the build system and would require restructuring of the code, i.e. just a lot of work. I would definitely support someone doing this and be happy to take pull requests. Considering the existing workarounds (like local::lib) I just don't see this ever making it up far enough on my TODO list for me to do this all on my own. That we have Python 3 at all was due to the great work of @Imazuel