Importing a Python file into both "setup.py" and my game

Is it safe to import a Python file in the “setup.py” script associated with building a game when that game itself imports the same Python file?

To explain, I want to create a single file that defines my game’s current version number. This would be used by the game to fill in its version string, as well as to create a version-file for identifying whether the game has been newly-run–and thus might want to delete old save- or config- files. It would also, however, be used by “setup.py” to specify the version number for that script.

Right now, the version number is entered by hand in each location–but this is prone to mistakes, and it would in any case be more convenient to change it in just one location.

However, since the setup process would be acting on the version-number file in the process of creating a build, I’m not sure of whether it’s safe to import that file into “setup.py” itself…

If it is a problem then I can simply read from a text-file instead of a Python file; a Python file would simply be a little bit more convenient.

Yes, this is a good idea. I just recommend against importing any other libraries like Panda3D inside your version Python file.

Okay, great then–that reassures me! Thank you. :slight_smile: