Skip to content

Commit fce282e

Browse files
committed
Emit warning when importing panda3d using Python 2.7
Fixes panda3d#602
1 parent a92dce2 commit fce282e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

makepanda/makepanda.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,14 @@ def CreatePandaVersionFiles():
28802880
p3d_init = """"Python bindings for the Panda3D libraries"
28812881
28822882
__version__ = '%s'
2883+
2884+
if __debug__:
2885+
import sys
2886+
if sys.version_info < (3, 0):
2887+
sys.stderr.write("WARNING: Python 2.7 will reach EOL after December 31, 2019.\\n")
2888+
sys.stderr.write("To suppress this warning, upgrade to Python 3.\\n")
2889+
sys.stderr.flush()
2890+
del sys
28832891
""" % (WHLVERSION)
28842892

28852893
if GetTarget() == 'windows':

makepanda/makewheel.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,23 @@ def makewheel(version, output_dir, platform=None):
596596

597597
# Write the panda3d tree. We use a custom empty __init__ since the
598598
# default one adds the bin directory to the PATH, which we don't have.
599-
whl.write_file_data('panda3d/__init__.py', """"Python bindings for the Panda3D libraries"
599+
p3d_init = """"Python bindings for the Panda3D libraries"
600600
601601
__version__ = '{0}'
602-
""".format(version))
602+
""".format(version)
603+
604+
if '27' in ABI_TAG:
605+
p3d_init += """
606+
if __debug__:
607+
import sys
608+
if sys.version_info < (3, 0):
609+
sys.stderr.write("WARNING: Python 2.7 will reach EOL after December 31, 2019.\\n")
610+
sys.stderr.write("To suppress this warning, upgrade to Python 3.\\n")
611+
sys.stderr.flush()
612+
del sys
613+
"""
614+
615+
whl.write_file_data('panda3d/__init__.py', p3d_init)
603616

604617
# Copy the extension modules from the panda3d directory.
605618
ext_suffix = GetExtensionSuffix()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy