2

I have a program (written in C and C++) that embeds Python and links with the Python dynamic library. Currently it uses Python 2.6, but the requirement is to use whatever version is being installed on the machine (currently either 2.6 or 2.7; no plans to support 3.x at the moment). How could that be done?

An obvious approach would be loading whatever library is available dynamically, using dlopen()/LoadLibrary(), and fetching function addresses I need.

The problem is that there are data structures that could have been changed between 2.6 and 2.7. If I compile my program against 2.6 headers, will it work against 2.7? Is such a thing supported?

The other alternative would be to compile the program (or at least the module responsible for the Python interface) separately against 2.6 and 2.7, and distribute two separate versions. This is obviously undesirable.

Is there any other approach I'm missing?

The platforms are Windows and Linux.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243

0 Answers0