Emit warning when importing panda3d using Python 2.7

Fixes #602
This commit is contained in:
rdb 2019-05-03 22:04:24 +02:00
parent a92dce29cc
commit fce282ea33
2 changed files with 23 additions and 2 deletions

View File

@ -2880,6 +2880,14 @@ for basename in del_files:
p3d_init = """"Python bindings for the Panda3D libraries"
__version__ = '%s'
if __debug__:
import sys
if sys.version_info < (3, 0):
sys.stderr.write("WARNING: Python 2.7 will reach EOL after December 31, 2019.\\n")
sys.stderr.write("To suppress this warning, upgrade to Python 3.\\n")
sys.stderr.flush()
del sys
""" % (WHLVERSION)
if GetTarget() == 'windows':

View File

@ -596,10 +596,23 @@ def makewheel(version, output_dir, platform=None):
# Write the panda3d tree. We use a custom empty __init__ since the
# default one adds the bin directory to the PATH, which we don't have.
whl.write_file_data('panda3d/__init__.py', """"Python bindings for the Panda3D libraries"
p3d_init = """"Python bindings for the Panda3D libraries"
__version__ = '{0}'
""".format(version))
""".format(version)
if '27' in ABI_TAG:
p3d_init += """
if __debug__:
import sys
if sys.version_info < (3, 0):
sys.stderr.write("WARNING: Python 2.7 will reach EOL after December 31, 2019.\\n")
sys.stderr.write("To suppress this warning, upgrade to Python 3.\\n")
sys.stderr.flush()
del sys
"""
whl.write_file_data('panda3d/__init__.py', p3d_init)
# Copy the extension modules from the panda3d directory.
ext_suffix = GetExtensionSuffix()