QuArK Forums
Welcome,
Guest
. Please
login
or
register
.
May 23, 2013, 11:34:21 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Need help? Don't forget to check QuArK's documentation first! You can find it
here
!
Search:
Advanced search
QuArK Forums
QuArK 7 Development
QuArK 7 Design
Python bindings
Pages: [
1
]
« previous
next »
Author
Topic: Python bindings (Read 1075 times)
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Python bindings
«
on:
December 28, 2010, 02:00:46 PM »
QuArK 7 will use Python, and therefore needs a connection to the Python library. There's various ways of linking, and this is what I've come up with:
There will be no static linking (inclusion of the library file into the executable), because that would cause the executable to become larger, while Python is often already installed on many systems.
QuArK's executable will NOT have the OS load the Python lib when the executable is started; this would cause a pretty weird and non-friendly error message if the library mismatches. So the executable will load the needed function calls (after checking the lib's version) during start-up. (Technical note: This means all calls to Python in the executable will have to go through some extra hoops, but it should be pretty painless.)
However, all plugins will be loaded after all of that, so they will be able to use the not-at-runtime dynamic linking (what's the official term for this anyway?), since the Python lib is already loaded and its version verified. We need to be sure however no copy of Python gets loaded this way. Does anybody know a way to do that?
Any comments?
Logged
xmm0
Jr. Member
Posts: 28
Re: Python bindings
«
Reply #1 on:
December 28, 2010, 10:46:31 PM »
Quote from: DanielPharos on December 28, 2010, 02:00:46 PM
However, all plugins will be loaded after all of that, so they will be able to use the not-at-runtime dynamic linking (what's the official term for this anyway?), since the Python lib is already loaded and its version verified. We need to be sure however no copy of Python gets loaded this way. Does anybody know a way to do that?
I'm not sure what you mean.
Are you saying that you want to implicitly link to the Python run-time and make sure that it doesn't link to the wrong version (to avoid "DLL Hell")? I know of several ways to do this on Windows but I'm no Unix guru
. It shouldn't be a problem on Windows since the python dynamic libs, in the System32 folder, are named python24.dll, python25.dll, python26.dll and so on.
Or are you saying that you want to link up the other way? With LoadLibrary() and GetProcAddress() and all that fun stuff
I apologize for my confusion
«
Last Edit: December 29, 2010, 01:09:12 AM by xmm0
»
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #2 on:
December 29, 2010, 04:43:35 AM »
On *nix, this is usually done by the "dlopen" call etc. (I had to google it too, but it works fine on even Mac OS X).
Nope, even though the filename looks nice on Windows, the different sub-versions of Python are also not compatible (at least not on the API-level), so you cannot rely on the filename.
Yep, the main executable will do the LoadLibrary and GetProcAddress stuff, verify the version, and then allow the plugins to load. The plugins will use the (what's the name) load-on-startup linking.
Logged
xmm0
Jr. Member
Posts: 28
Re: Python bindings
«
Reply #3 on:
December 30, 2010, 06:08:59 AM »
Quote from: DanielPharos on December 29, 2010, 04:43:35 AM
Nope, even though the filename looks nice on Windows, the different sub-versions of Python are also not compatible (at least not on the API-level), so you cannot rely on the filename.
Really? This will be difficult then.
Since Python should already be installed on the user's system, should we include the version we will be using in the installer/package just in case?
What version were you planning on using anyway?
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #4 on:
December 30, 2010, 06:47:48 AM »
QuArK 6 has a folder containing all needed Python files (the 'lib' folder) and has the Python dll in its 'dlls' folder. I think this is the approach that we should take on Windows systems to ensure we get the right Python version, with all the needed files. On *nix, the package manager should take care of getting the right version of Python, so we don't need to distribute any Python-stuff with Q7 there.
(Determining the version of the Python DLL is possible, though not nice: There's a function that returns the Python version number as part of a string, and with a little bit of parsing, one can get the version number from that. This is what I've done with QuArK 6, and it works fine (for at least Python 2.2-2.6).
Currently, I'm using Python 2.4.4 (the latest binary release of the 2.4 branch), as this is what QuArK 6 uses so this is the one I know. However, I plan to switch to Python 3 ASAP, since there's a few features in Python 3 that would really come in handy (plus, it's supposed to be 'much' faster). This WILL break Python 2- compatibility though...
Logged
xmm0
Jr. Member
Posts: 28
Re: Python bindings
«
Reply #5 on:
January 19, 2011, 10:18:07 PM »
Quote from: DanielPharos on December 30, 2010, 06:47:48 AM
QuArK 6 has a folder containing all needed Python files (the 'lib' folder) and has the Python dll in its 'dlls' folder. I think this is the approach that we should take on Windows systems to ensure we get the right Python version, with all the needed files. On *nix, the package manager should take care of getting the right version of Python, so we don't need to distribute any Python-stuff with Q7 there.
Sounds good to me
Will all of the 2.x scripts have to be rewritten to be compatible with the new Python 3.x?
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #6 on:
March 19, 2011, 12:56:00 PM »
(Sorry for the late reply; I lost track of this thread.)
Yeah, everything will have to be rewritten anyway, because even though the difference between Python 2.x and 3.x isn't THAT large, the entire QuArK-stuff will change, so I don't think it's going to be possible to fix most scripts with only minor adjustments. Of course, there are some exceptions, and a lot of code will be similar enough that a careful copy-paste-adjust strategy might work just fine.
Logged
xmm0
Jr. Member
Posts: 28
Re: Python bindings
«
Reply #7 on:
April 14, 2011, 03:18:46 PM »
Awesome! I've been trying to bring my python 3 skills up to par for this project
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #8 on:
April 17, 2011, 08:53:34 AM »
Some issues with Boost have gotten me thinking... This loading Python dynamically is just a pain in the you-know-what. I now think both Boost and Python should be *statically* linked at run-time. If either is corrupt, the OS will display a cryptic error message, but that's okay: If the install is corrupt, you're perfectly allowed to do that!
It'll vastly simplify the interface to Python (much less chance of bugs there), and makes all the Python tutorials etc. on the web work out-of-the-box. We can always switch back to dynamic loading (by just digging up the now-obsoleted code from the repository), but for now, I don't want to waste time doing this unless there's a good reason.
For Windows, we'll have to either include a Python into the main QuArK folder (recommended), or rely on a system-install (bad idea without a package manager). On *nix, we'll rely entirely on the package manager to deal with dependancies.
(Note: The main reason for this: without Boost, no filesystem interface, except for C++'s main one, which means certain parts of the code (logging) can NOT be unified into the QuArK filesystem. Boost cannot be statically linked (as it is now), because then plugins won't be able to access the Boost functions (BAD!).)
I'm not really happy with this, but sometimes choices need to be made...
«
Last Edit: April 17, 2011, 09:00:38 AM by DanielPharos
»
Logged
xmm0
Jr. Member
Posts: 28
Re: Python bindings
«
Reply #9 on:
April 17, 2011, 04:38:50 PM »
Sounds good to me Dan. Whatever needs to be done to make it work
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #10 on:
April 21, 2012, 12:09:15 PM »
Just an update on this topic: Python 3 introduced Unicode support, but they borked up the implementation so bad (apparently), they're reworking it in Python 3.3. So we'll be doing 3.3+. Also, there's an (known) irritating bug in one of the main packages of Python, causing Python 3.2.x installs in custom locations to fail to start-up on *nix machines. I just hope they fix this bug before releasing 3.3...
Logged
DanielPharos
Global Moderator
Hero Member
Posts: 966
Dancing Dan
Re: Python bindings
«
Reply #11 on:
August 11, 2012, 02:25:12 PM »
I haven't tried Python 3.3 yet (it's in Beta 1). I suppost I should get off my @$$ and check it out, just to see if the aforementioned problems are now fixed.
Logged
Pages: [
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
QuArK
-----------------------------
=> Announcements
=> General Discussion
=> Showcasing
=> Technical Questions (How To)
=> Troubleshooting
=> Feature Requests
=> Game Support
===> 6DX
===> Alice
===> CoD1
===> Crystal Space
===> Doom 3
===> EF2
===> FAKK2
===> Genesis3D
===> Half-Life (and derivatives)
===> Half-Life 2 (and derivatives)
===> Heretic II
===> Hexen II
===> JA
===> JK2
===> KingPin
===> MOHAA
===> Nexuiz
===> Prey
===> Quake 1
===> Quake 2
===> Quake 3
===> Quake 4
===> RTCW
===> RTCW-ET
===> SiN
===> SOF
===> SoF2
===> STVEF
===> Sylphis
===> TF2
===> Torque
===> Warsow
===> WildWest
-----------------------------
Website and Forums
-----------------------------
=> Feedback
-----------------------------
QuArK 7 Development
-----------------------------
=> Chatter
=> QuArK 7 Design
Loading...