Merge remote-tracking branch 'panda3d-upstream/master'

This commit is contained in:
John Cote 2020-05-18 18:58:44 -04:00
commit 19d6f7484d
No known key found for this signature in database
GPG Key ID: 84EA3A723A87E0A9
176 changed files with 1375 additions and 2107 deletions

22
.editorconfig Normal file
View File

@ -0,0 +1,22 @@
root = true
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[*.{py,pyw}]
indent_style = space
indent_size = 4
[*.{h,c,cxx,cpp,I}]
indent_style = space
indent_size = 2
[{CMakeLists.txt,*.cmake}]
indent_style = space
indent_size = 2
[*.bat]
end_of_line = crlf

16
.github/codecov.yml vendored Normal file
View File

@ -0,0 +1,16 @@
coverage:
status:
project:
default:
threshold: 0.1
patch:
default:
threshold: 0.1
codecov:
require_ci_to_pass: true
notify:
after_n_builds: 2
wait_for_ci: true
comment:
require_changes: true
after_n_builds: 2

View File

@ -109,6 +109,7 @@ jobs:
libeigen3-dev libfreetype6-dev libgl1-mesa-dev libjpeg-dev libode-dev
libopenal-dev libpng-dev libssl-dev libvorbis-dev libx11-dev
libxcursor-dev libxrandr-dev nvidia-cg-toolkit zlib1g-dev
python3-setuptools
# Workaround for CMake 3.12 finding this first:
@ -180,37 +181,6 @@ jobs:
run: cmake --build . --config ${{ matrix.config }} --parallel 4
# END A
- name: Setup Python (Python 2.7)
if: contains(matrix.python, 'YES')
uses: actions/setup-python@v1
with:
python-version: 2.7
- name: Configure (Python 2.7)
if: contains(matrix.python, 'YES')
working-directory: build
shell: bash
run: >
cmake -DWANT_PYTHON_VERSION=2.7
-DPython_FIND_REGISTRY=NEVER -DPython_ROOT=$pythonLocation .
- name: Build (Python 2.7)
if: contains(matrix.python, 'YES')
# BEGIN A
working-directory: build
run: cmake --build . --config ${{ matrix.config }} --parallel 4
# END A
- name: Test (Python 2.7)
# BEGIN B
if: contains(matrix.python, 'YES')
working-directory: build
shell: bash
env:
PYTHONPATH: ${{ matrix.config }}
run: |
PYTHON_EXECUTABLE=$(grep 'Python_EXECUTABLE:' CMakeCache.txt | sed 's/.*=//')
$PYTHON_EXECUTABLE -m pip install pytest
$PYTHON_EXECUTABLE -m pytest ../tests
# END B
- name: Setup Python (Python 3.5)
if: contains(matrix.python, 'YES')
uses: actions/setup-python@v1
@ -353,7 +323,7 @@ jobs:
llvm-profdata merge pid-*.profraw -o coverage.profdata
llvm-cov show $(grep -Rl LLVM_PROFILE_FILE . | sed 's/^/-object /') -instr-profile=coverage.profdata > coverage.txt
bash <(curl -s https://codecov.io/bash)
bash <(curl -s https://codecov.io/bash) -y ../.github/codecov.yml
makepanda:
strategy:
@ -365,6 +335,7 @@ jobs:
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-16.04'
run: |
sudo apt-get update
sudo apt-get install build-essential bison flex libfreetype6-dev libgl1-mesa-dev libjpeg-dev libode-dev libopenal-dev libpng-dev libssl-dev libvorbis-dev libx11-dev libxcursor-dev libxrandr-dev nvidia-cg-toolkit zlib1g-dev
- name: Get thirdparty packages (Windows)
if: runner.os == 'Windows'
@ -406,18 +377,6 @@ jobs:
run: |
python -m pip install pytest
PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest
- name: Set up Python 2.7
uses: actions/setup-python@v1
with:
python-version: 2.7
- name: Build Python 2.7
run: |
python makepanda/makepanda.py --no-copy-python --git-commit=${{github.sha}} --outputdir=built --everything --no-eigen --python-incdir=$pythonLocation/include --python-libdir=$pythonLocation/lib --verbose --threads=4
- name: Test Python 2.7
shell: bash
run: |
python -m pip install pytest
PYTHONPATH=built LD_LIBRARY_PATH=built/lib DYLD_LIBRARY_PATH=built/lib python -m pytest
- name: Make installer
run: |
python makepanda/makepackage.py --verbose --lzma

View File

@ -5,9 +5,9 @@ matrix:
- compiler: clang
env: PYTHONV=python3 FLAGS=--installer
- compiler: clang
env: PYTHONV=python2.7 FLAGS=--override=STDFLOAT_DOUBLE=1
env: PYTHONV=python3 FLAGS=--override=STDFLOAT_DOUBLE=1
- compiler: gcc
env: PYTHONV=python2.7 FLAGS=--optimize=4
env: PYTHONV=python3 FLAGS=--optimize=4
before_install:
- export CC=gcc-4.7
- export CXX=g++-4.7

View File

@ -40,7 +40,6 @@ endif()
if(IS_MULTICONFIG)
message(STATUS "Using multi-configuration generator")
set(CMAKE_CONFIGURATION_TYPES ${_configs})
else()
# Set the default CMAKE_BUILD_TYPE before calling project().
if(NOT CMAKE_BUILD_TYPE)
@ -80,6 +79,7 @@ include(GNUInstallDirs) # Defines CMAKE_INSTALL_<dir> variables
# Include global modules needed for configure scripts
include(PackageConfig) # Defines package_option
include(PerConfigOption) # Defines per_config_option
# Configure Panda3D
include(dtool/CompilerFlags.cmake)

View File

@ -146,7 +146,7 @@ python makepanda/makepanda.py --everything --installer
```
You may target a specific minimum macOS version using the --osxtarget flag
followed by the release number, eg. 10.7 or 10.9.
followed by the release number, eg. 10.9 or 10.14.
If the build was successful, makepanda will have generated a .dmg file in
the source directory containing the installer. Simply open it and run the
@ -164,11 +164,11 @@ pkg install pkgconf bison png jpeg-turbo tiff freetype2 harfbuzz eigen squish op
```
You will also need to choose which version of Python you want to use.
Install the appropriate package for it (such as `python2` or `python36`) and
Install the appropriate package for it (such as `python37` or `python38`) and
run the makepanda script with your chosen Python version:
```bash
python3.6 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2
python3.7 makepanda/makepanda.py --everything --installer --no-egl --no-gles --no-gles2
```
If successful, this will produce a .pkg file in the root of the source

View File

@ -0,0 +1,50 @@
# Filename: PerConfigOption.cmake
#
# This contains a convenience function for defining per-config options.
# In single-config generators, it will set the option based on the defined
# CMAKE_BUILD_TYPE. In multi-config generators, it will create separate
# options, one per config.
#
# Function: per_config_option
# Usage:
# option(name "help string" [Config1] [Config2] [...ConfigN])
#
# Example:
# per_config_option(DO_DEBUGGING "Enables debugging." Debug Standard)
set(_PER_CONFIG_OPTIONS CACHE INTERNAL "Internal variable")
function(per_config_option name help)
set(_configs ${ARGN})
# In single-config generatotrs, we simply create one config.
if(NOT IS_MULTICONFIG)
list(FIND _configs "${CMAKE_BUILD_TYPE}" _index)
if(${_index} GREATER -1)
option("${name}" "${help}" ON)
else()
option("${name}" "${help}" OFF)
endif()
elseif(DEFINED "${name}")
# It's been explicitly defined, so that makes it not a multi-configuration
# variable anymore.
option("${name}" "${help}")
return()
else()
foreach(_config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${_config}" _config_upper)
list(FIND _configs "${_config}" _index)
if(${_index} GREATER -1)
option("${name}_${_config_upper}" "${help}" ON)
else()
option("${name}_${_config_upper}" "${help}" OFF)
endif()
endforeach()
endif()
list(APPEND _PER_CONFIG_OPTIONS "${name}")
set(_PER_CONFIG_OPTIONS "${_PER_CONFIG_OPTIONS}" CACHE INTERNAL "Internal variable")
endfunction(per_config_option)

View File

@ -0,0 +1,7 @@
Metadata-Version: 2.0
Name: Panda3D
Version: ${PROJECT_VERSION}
License: BSD
Home-page: https://www.panda3d.org/
Author: Panda3D Team
Author-email: etc-panda3d@lists.andrew.cmu.edu

View File

@ -31,18 +31,16 @@ CLUSTER_DAEMON_PORT = 8001
CLUSTER_SERVER_PORT = 1970
# Precede command string with ! to tell server to execute command string
# NOTE: Had to stick with the import __builtin__ scheme, at startup,
# __builtins__ is a module, not a dictionary, like it is inside of a module
# Note, this startup string obviates the need to set any cluster related
# config variables in the client Configrc files
SERVER_STARTUP_STRING = (
'!bash ppython -c ' +
'"import __builtin__; ' +
'__builtin__.clusterMode = \'server\';' +
'__builtin__.clusterServerPort = %s;' +
'__builtin__.clusterSyncFlag = %d;' +
'__builtin__.clusterDaemonClient = \'%s\';' +
'__builtin__.clusterDaemonPort = %d;'
'"import builtins; ' +
'builtins.clusterMode = \'server\';' +
'builtins.clusterServerPort = %s;' +
'builtins.clusterSyncFlag = %d;' +
'builtins.clusterDaemonClient = \'%s\';' +
'builtins.clusterDaemonPort = %d;'
'from direct.directbase.DirectStart import *; run()"')
class ClusterMsgHandler:

View File

@ -85,9 +85,7 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) :
*/
DCClass::
~DCClass() {
if (_constructor != nullptr) {
delete _constructor;
}
delete _constructor;
Fields::iterator fi;
for (fi = _fields.begin(); fi != _fields.end(); ++fi) {

View File

@ -540,11 +540,7 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id,
for (int i = 0; i < num_optional_fields; i++) {
PyObject *py_field_name = PySequence_GetItem(optional_fields, i);
#if PY_MAJOR_VERSION >= 3
std::string field_name = PyUnicode_AsUTF8(py_field_name);
#else
std::string field_name = PyString_AsString(py_field_name);
#endif
Py_XDECREF(py_field_name);
DCField *field = _this->get_field_by_name(field_name);
@ -621,11 +617,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id,
for (int i = 0; i < num_optional_fields; ++i) {
PyObject *py_field_name = PySequence_GetItem(optional_fields, i);
#if PY_MAJOR_VERSION >= 3
std::string field_name = PyUnicode_AsUTF8(py_field_name);
#else
std::string field_name = PyString_AsString(py_field_name);
#endif
Py_XDECREF(py_field_name);
DCField *field = _this->get_field_by_name(field_name);

View File

@ -266,22 +266,14 @@ get_pystr(PyObject *value) {
PyObject *str = PyObject_Str(value);
if (str != nullptr) {
#if PY_MAJOR_VERSION >= 3
std::string result = PyUnicode_AsUTF8(str);
#else
std::string result = PyString_AsString(str);
#endif
Py_DECREF(str);
return result;
}
PyObject *repr = PyObject_Repr(value);
if (repr != nullptr) {
#if PY_MAJOR_VERSION >= 3
std::string result = PyUnicode_AsUTF8(repr);
#else
std::string result = PyString_AsString(repr);
#endif
Py_DECREF(repr);
return result;
}
@ -289,11 +281,7 @@ get_pystr(PyObject *value) {
if (value->ob_type != nullptr) {
PyObject *typestr = PyObject_Str((PyObject *)(value->ob_type));
if (typestr != nullptr) {
#if PY_MAJOR_VERSION >= 3
std::string result = PyUnicode_AsUTF8(typestr);
#else
std::string result = PyString_AsString(typestr);
#endif
Py_DECREF(typestr);
return result;
}

View File

@ -1124,7 +1124,9 @@ operator new(size_t size) {
*/
INLINE void DCPacker::StackElement::
operator delete(void *ptr) {
StackElement *obj = (StackElement *)ptr;
obj->_next = _deleted_chain;
_deleted_chain = obj;
if (ptr != nullptr) {
StackElement *obj = (StackElement *)ptr;
obj->_next = _deleted_chain;
_deleted_chain = obj;
}
}

View File

@ -44,9 +44,7 @@ DCPackerCatalog(const DCPackerCatalog &copy) :
*/
DCPackerCatalog::
~DCPackerCatalog() {
if (_live_catalog != nullptr) {
delete _live_catalog;
}
delete _live_catalog;
SwitchCatalogs::iterator si;
for (si = _switch_catalogs.begin(); si != _switch_catalogs.end(); ++si) {

View File

@ -60,9 +60,7 @@ DCPackerInterface(const DCPackerInterface &copy) :
*/
DCPackerInterface::
~DCPackerInterface() {
if (_catalog != nullptr) {
delete _catalog;
}
delete _catalog;
}
/**

View File

@ -40,12 +40,6 @@ pack_object(PyObject *object) {
_this->pack_int64(PyLong_AsLongLong(object));
return;
}
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(object)) {
_this->pack_int64(PyInt_AsLong(object));
return;
}
#endif
break;
case PT_uint64:
@ -53,14 +47,6 @@ pack_object(PyObject *object) {
_this->pack_uint64(PyLong_AsUnsignedLongLong(object));
return;
}
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(object)) {
PyObject *obj1 = PyNumber_Long(object);
_this->pack_int(PyLong_AsUnsignedLongLong(obj1));
Py_DECREF(obj1);
return;
}
#endif
break;
case PT_int:
@ -68,12 +54,6 @@ pack_object(PyObject *object) {
_this->pack_int(PyLong_AsLong(object));
return;
}
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(object)) {
_this->pack_int(PyInt_AsLong(object));
return;
}
#endif
break;
case PT_uint:
@ -81,14 +61,6 @@ pack_object(PyObject *object) {
_this->pack_uint(PyLong_AsUnsignedLong(object));
return;
}
#if PY_MAJOR_VERSION < 3
else if (PyInt_Check(object)) {
PyObject *obj1 = PyNumber_Long(object);
_this->pack_uint(PyLong_AsUnsignedLong(obj1));
Py_DECREF(obj1);
return;
}
#endif
break;
default:
@ -97,15 +69,10 @@ pack_object(PyObject *object) {
if (PyLong_Check(object)) {
_this->pack_int(PyLong_AsLong(object));
#if PY_MAJOR_VERSION < 3
} else if (PyInt_Check(object)) {
_this->pack_int(PyInt_AS_LONG(object));
#endif
} else if (PyFloat_Check(object)) {
_this->pack_double(PyFloat_AS_DOUBLE(object));
} else if (PyLong_Check(object)) {
_this->pack_int64(PyLong_AsLongLong(object));
#if PY_MAJOR_VERSION >= 3
} else if (PyUnicode_Check(object)) {
const char *buffer;
Py_ssize_t length;
@ -120,15 +87,6 @@ pack_object(PyObject *object) {
if (buffer) {
_this->pack_blob(vector_uchar(buffer, buffer + length));
}
#else
} else if (PyString_Check(object) || PyUnicode_Check(object)) {
char *buffer;
Py_ssize_t length;
PyString_AsStringAndSize(object, &buffer, &length);
if (buffer) {
_this->pack_string(std::string(buffer, length));
}
#endif
} else {
// For some reason, PySequence_Check() is incorrectly reporting that a
// class instance is a sequence, even if it doesn't provide __len__, so we
@ -230,26 +188,14 @@ unpack_object() {
case PT_int:
{
int value = _this->unpack_int();
#if PY_MAJOR_VERSION >= 3
object = PyLong_FromLong(value);
#else
object = PyInt_FromLong(value);
#endif
}
break;
case PT_uint:
{
unsigned int value = _this->unpack_uint();
#if PY_MAJOR_VERSION >= 3
object = PyLong_FromLong(value);
#else
if (value & 0x80000000) {
object = PyLong_FromUnsignedLong(value);
} else {
object = PyInt_FromLong(value);
}
#endif
}
break;
@ -268,25 +214,18 @@ unpack_object() {
break;
case PT_blob:
#if PY_MAJOR_VERSION >= 3
{
std::string str;
_this->unpack_string(str);
object = PyBytes_FromStringAndSize(str.data(), str.size());
}
break;
#endif
// On Python 2, fall through to below.
case PT_string:
{
std::string str;
_this->unpack_string(str);
#if PY_MAJOR_VERSION >= 3
object = PyUnicode_FromStringAndSize(str.data(), str.size());
#else
object = PyString_FromStringAndSize(str.data(), str.size());
#endif
}
break;

View File

@ -42,21 +42,15 @@ DCSwitch::
nassertv(_key_parameter != nullptr);
delete _key_parameter;
Cases::iterator ci;
for (ci = _cases.begin(); ci != _cases.end(); ++ci) {
SwitchCase *dcase = (*ci);
for (SwitchCase *dcase : _cases) {
delete dcase;
}
CaseFields::iterator fi;
for (fi = _case_fields.begin(); fi != _case_fields.end(); ++fi) {
SwitchFields *fields = (*fi);
for (SwitchFields *fields : _case_fields) {
delete fields;
}
Fields::iterator ni;
for (ni = _nested_fields.begin(); ni != _nested_fields.end(); ++ni) {
DCField *field = (*ni);
for (DCField *field : _nested_fields) {
delete field;
}
}

View File

@ -9,7 +9,7 @@ from __future__ import print_function
__all__ = []
import os, sys
import os
from distutils import sysconfig
import panda3d, pandac
from panda3d.interrogatedb import *
@ -309,13 +309,8 @@ if __name__ == "__main__":
processModule(handle, "core")
# Determine the suffix for the extension modules.
if sys.version_info >= (3, 0):
import _imp
ext_suffix = _imp.extension_suffixes()[0]
elif sys.platform == "win32":
ext_suffix = ".pyd"
else:
ext_suffix = ".so"
import _imp
ext_suffix = _imp.extension_suffixes()[0]
for lib in os.listdir(os.path.dirname(panda3d.__file__)):
if lib.endswith(ext_suffix) and not lib.startswith('core.'):

View File

@ -1,5 +1,4 @@
import math
import sys
from panda3d.core import *
from .DirectUtil import *
@ -942,10 +941,7 @@ class DirectSession(DirectObject):
def getAndSetName(self, nodePath):
""" Prompt user for new node path name """
if sys.version_info >= (3, 0):
from tkinter.simpledialog import askstring
else:
from tkSimpleDialog import askstring
from tkinter.simpledialog import askstring
newName = askstring('Node Path: ' + nodePath.getName(),
'Enter new name:')
if newName:

View File

@ -36,21 +36,15 @@ isDebugBuild = (python.lower().endswith('_d'))
# NB. if encodings are removed, be sure to remove them from the shortcut in
# deploy-stub.c.
startupModules = [
'imp', 'encodings', 'encodings.*',
'imp', 'encodings', 'encodings.*', 'io', 'marshal', 'importlib.machinery',
'importlib.util',
]
if sys.version_info >= (3, 0):
# Modules specific to Python 3
startupModules += ['io', 'marshal', 'importlib.machinery', 'importlib.util']
else:
# Modules specific to Python 2
startupModules += []
# These are some special init functions for some built-in Python modules that
# deviate from the standard naming convention. A value of None means that a
# dummy entry should be written to the inittab.
builtinInitFuncs = {
'builtins': None,
'__builtin__': None,
'sys': None,
'exceptions': None,
'_warnings': '_PyWarnings_Init',
@ -76,6 +70,7 @@ hiddenImports = {
'datetime': ['_strptime'],
'keyring.backends': ['keyring.backends.*'],
'matplotlib.font_manager': ['encodings.mac_roman'],
'matplotlib.backends._backend_tk': ['tkinter'],
'direct.particles': ['direct.particles.ParticleManagerGlobal'],
'numpy.core._multiarray_umath': [
'numpy.core._internal',
@ -84,12 +79,6 @@ hiddenImports = {
],
}
if sys.version_info >= (3,):
hiddenImports['matplotlib.backends._backend_tk'] = ['tkinter']
else:
hiddenImports['matplotlib.backends._backend_tk'] = ['Tkinter']
# These are overrides for specific modules.
overrideModules = {
# Used by the warnings module, among others, to get line numbers. Since
@ -1311,11 +1300,7 @@ class Freezer:
def __addPyc(self, multifile, filename, code, compressionLevel):
if code:
data = imp.get_magic() + b'\0\0\0\0'
if sys.version_info >= (3, 0):
data += b'\0\0\0\0'
data = imp.get_magic() + b'\0\0\0\0\0\0\0\0'
data += marshal.dumps(code)
stream = StringStream(data)
@ -1672,10 +1657,7 @@ class Freezer:
# initmodule or PyInit_module function.
modname = mod.split('.')[-1]
libfile = modname + '.lib'
if sys.version_info >= (3, 0):
symbolName = 'PyInit_' + modname
else:
symbolName = 'init' + modname
symbolName = 'PyInit_' + modname
os.system('lib /nologo /def /export:%s /name:%s.pyd /out:%s' % (symbolName, modname, libfile))
extraLink.append(libfile)
cleanFiles += [libfile, modname + '.exp']
@ -1779,10 +1761,7 @@ class Freezer:
code = 'import sys;del sys.modules["%s"];import sys,os,imp;imp.load_dynamic("%s",os.path.join(sys.path[0], "%s%s"))' % (moduleName, moduleName, moduleName, modext)
else:
code = 'import sys;del sys.modules["%s"];import sys,os,imp;imp.load_dynamic("%s",os.path.join(os.path.dirname(sys.executable), "%s%s"))' % (moduleName, moduleName, moduleName, modext)
if sys.version_info >= (3, 2):
code = compile(code, moduleName, 'exec', optimize=2)
else:
code = compile(code, moduleName, 'exec')
code = compile(code, moduleName, 'exec', optimize=2)
code = marshal.dumps(code)
moduleList.append((moduleName, len(pool), len(code)))
pool += code
@ -2274,7 +2253,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
except KeyError:
return None
if sys.version_info >= (3, 0) and 'b' not in mode:
if 'b' not in mode:
return io.TextIOWrapper(fp, encoding='utf8')
return fp
@ -2359,27 +2338,14 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
raise
co = marshal.loads(memoryview(data)[16:])
elif sys.version_info >= (3, 4):
else:
try:
if sys.version_info >= (3, 5):
marshal_data = importlib._bootstrap_external._validate_bytecode_header(fp.read())
else:
marshal_data = importlib._bootstrap._validate_bytecode_header(fp.read())
marshal_data = importlib._bootstrap_external._validate_bytecode_header(fp.read())
except ImportError as exc:
self.msgout(2, "raise ImportError: " + str(exc), pathname)
raise
co = marshal.loads(marshal_data)
else:
if fp.read(4) != imp.get_magic():
self.msgout(2, "raise ImportError: Bad magic number", pathname)
raise ImportError("Bad magic number in %s" % pathname)
fp.read(4)
if sys.version_info >= (3, 3):
fp.read(4)
co = marshal.load(fp)
else:
co = None
@ -2489,7 +2455,7 @@ class PandaModuleFinder(modulefinder.ModuleFinder):
# If we found folders on the path with this module name without an
# __init__.py file, we should consider this a namespace package.
if ns_dirs and sys.version_info >= (3, 3):
if ns_dirs:
return (None, ns_dirs, ('', '', _PKG_NAMESPACE_DIRECTORY))
raise ImportError(name)

View File

@ -30,10 +30,6 @@ from .icon import Icon
import panda3d.core as p3d
if 'basestring' not in globals():
basestring = str
if sys.version_info < (3, 0):
# Python 3 defines these subtypes of IOError, but Python 2 doesn't.
FileNotFoundError = IOError
@ -48,7 +44,7 @@ if sys.version_info < (3, 0):
def _parse_list(input):
if isinstance(input, basestring):
if isinstance(input, str):
input = input.strip().replace(',', '\n')
if input:
return [item.strip() for item in input.split('\n') if item.strip()]
@ -123,45 +119,7 @@ PACKAGE_LIB_DIRS = {
'scipy': ['scipy/extra-dll'],
}
# site.py for Python 2.
SITE_PY2 = u"""
import sys
sys.frozen = True
# Override __import__ to set __file__ for frozen modules.
prev_import = __import__
def __import__(*args, **kwargs):
mod = prev_import(*args, **kwargs)
if mod:
mod.__file__ = sys.executable
return mod
# Add our custom __import__ version to the global scope, as well as a builtin
# definition for __file__ so that it is available in the module itself.
import __builtin__
__builtin__.__import__ = __import__
__builtin__.__file__ = sys.executable
del __builtin__
# Set the TCL_LIBRARY directory to the location of the Tcl/Tk/Tix files.
import os
tcl_dir = os.path.join(os.path.dirname(sys.executable), 'tcl')
if os.path.isdir(tcl_dir):
for dir in os.listdir(tcl_dir):
sub_dir = os.path.join(tcl_dir, dir)
if os.path.isdir(sub_dir):
if dir.startswith('tcl'):
os.environ['TCL_LIBRARY'] = sub_dir
if dir.startswith('tk'):
os.environ['TK_LIBRARY'] = sub_dir
if dir.startswith('tix'):
os.environ['TIX_LIBRARY'] = sub_dir
del os
"""
# site.py for Python 3.
SITE_PY3 = u"""
SITE_PY = u"""
import sys
from _frozen_importlib import _imp, FrozenImporter
@ -209,8 +167,6 @@ if os.path.isdir(tcl_dir):
del os
"""
SITE_PY = SITE_PY3 if sys.version_info >= (3,) else SITE_PY2
class build_apps(setuptools.Command):
description = 'build Panda3D applications'
@ -407,10 +363,6 @@ class build_apps(setuptools.Command):
if sys.version_info < (3, 8):
abi_tag += 'm'
# For these distributions, we need to append 'u' on Linux
if abi_tag in ('cp26m', 'cp27m', 'cp32m') and not platform.startswith('win') and not platform.startswith('macosx'):
abi_tag += 'u'
whldir = os.path.join(whlcache, '_'.join((platform, abi_tag)))
os.makedirs(whldir, exist_ok=True)
@ -571,15 +523,19 @@ class build_apps(setuptools.Command):
libdir = os.path.dirname(dtool_fn.to_os_specific())
etcdir = os.path.join(libdir, '..', 'etc')
for fn in os.listdir(etcdir):
etcfiles = os.listdir(etcdir)
etcfiles.sort(reverse=True)
for fn in etcfiles:
if fn.lower().endswith('.prc'):
with open(os.path.join(etcdir, fn)) as f:
prcstring += f.read()
else:
etcfiles = [i for i in p3dwhl.namelist() if i.endswith('.prc')]
etcfiles.sort(reverse=True)
for fn in etcfiles:
with p3dwhl.open(fn) as f:
prcstring += f.read().decode('utf8')
user_prcstring = self.extra_prc_data
for fn in self.extra_prc_files:
with open(fn) as f:
@ -598,12 +554,33 @@ class build_apps(setuptools.Command):
for ln in prcstr.split('\n'):
ln = ln.strip()
useline = True
if ln.startswith('#') or not ln:
continue
if 'model-cache-dir' in ln:
ln = ln.replace('/panda3d', '/{}'.format(self.distribution.get_name()))
words = ln.split(None, 1)
if not words:
continue
var = words[0]
value = words[1] if len(words) > 1 else ''
# Strip comment after value.
c = value.find(' #')
if c > 0:
value = value[:c].rstrip()
if var == 'model-cache-dir' and value:
value = value.replace('/panda3d', '/{}'.format(self.distribution.get_name()))
if var == 'audio-library-name':
# We have the default set to p3fmod_audio on macOS in 1.10,
# but this can be unexpected as other platforms use OpenAL
# by default. Switch it up if FMOD is not included.
if value not in self.plugins and value == 'p3fmod_audio' and 'p3openal_audio' in self.plugins:
self.warn("Missing audio plugin p3fmod_audio referenced in PRC data, replacing with p3openal_audio")
for plugin in check_plugins:
if plugin in ln and plugin not in self.plugins:
if plugin in value and plugin not in self.plugins:
useline = False
if warn_on_missing_plugin:
self.warn(
@ -611,7 +588,10 @@ class build_apps(setuptools.Command):
)
break
if useline:
out.append(ln)
if value:
out.append(var + ' ' + value)
else:
out.append(var)
return out
prcexport = parse_prc(prcstring, 0) + parse_prc(user_prcstring, 1)
@ -778,11 +758,10 @@ class build_apps(setuptools.Command):
basename = module.rsplit('.', 1)[0] + '.' + basename
# Remove python version string
if sys.version_info >= (3, 0):
parts = basename.split('.')
if len(parts) >= 3 and '-' in parts[-2]:
parts = parts[:-2] + parts[-1:]
basename = '.'.join(parts)
parts = basename.split('.')
if len(parts) >= 3 and '-' in parts[-2]:
parts = parts[:-2] + parts[-1:]
basename = '.'.join(parts)
else:
# Builtin module, but might not be builtin in wheel libs, so double check
if module in whl_modules:
@ -801,9 +780,8 @@ class build_apps(setuptools.Command):
#TODO: get this to work on non-Windows platforms.
if sys.platform == "win32" and platform.startswith('win'):
tcl_dir = os.path.join(sys.prefix, 'tcl')
tkinter_name = 'tkinter' if sys.version_info >= (3, 0) else 'Tkinter'
if os.path.isdir(tcl_dir) and tkinter_name in freezer_modules:
if os.path.isdir(tcl_dir) and 'tkinter' in freezer_modules:
self.announce('Copying Tcl files', distutils.log.INFO)
os.makedirs(os.path.join(builddir, 'tcl'))

View File

@ -10,11 +10,7 @@ from collections import namedtuple
from array import array
import time
from io import BytesIO
import sys
if sys.version_info >= (3, 0):
unicode = str
unichr = chr
# Define some internally used structures.
RVASize = namedtuple('RVASize', ('addr', 'size'))
@ -38,7 +34,7 @@ def _unpack_wstring(mem, offs=0):
name = ""
for i in range(name_len):
offs += 2
name += unichr(*unpack('<H', mem[offs:offs+2]))
name += chr(*unpack('<H', mem[offs:offs+2]))
return name
def _padded(n, boundary):
@ -208,7 +204,7 @@ class VersionInfoResource(object):
if isinstance(value, dict):
type = 1
value_length = 0
elif isinstance(value, bytes) or isinstance(value, unicode):
elif isinstance(value, bytes) or isinstance(value, str):
type = 1
value_length = len(value) * 2 + 2
else:
@ -227,7 +223,7 @@ class VersionInfoResource(object):
if isinstance(value, dict):
for key2, value2 in sorted(value.items(), key=lambda x:x[0]):
self._pack_info(data, key2, value2)
elif isinstance(value, bytes) or isinstance(value, unicode):
elif isinstance(value, bytes) or isinstance(value, str):
for c in value:
data += pack('<H', ord(c))
data += b'\x00\x00'
@ -294,7 +290,7 @@ class VersionInfoResource(object):
c, = unpack('<H', data[offset:offset+2])
offset += 2
while c:
key += unichr(c)
key += chr(c)
c, = unpack('<H', data[offset:offset+2])
offset += 2
@ -309,7 +305,7 @@ class VersionInfoResource(object):
c, = unpack('<H', data[offset:offset+2])
offset += 2
while c:
value += unichr(c)
value += chr(c)
c, = unpack('<H', data[offset:offset+2])
offset += 2
else:
@ -705,7 +701,7 @@ class PEFile(object):
Returns the newly created Section object. """
if isinstance(name, unicode):
if isinstance(name, str):
name = name.encode('ascii')
section = Section()

View File

@ -2,12 +2,7 @@
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.PyDatagram import PyDatagram
from direct.showbase.Messenger import Messenger
import sys
if sys.version_info >= (3, 0):
from pickle import dumps, loads
else:
from cPickle import dumps, loads
from pickle import dumps, loads
class NetMessenger(Messenger):

View File

@ -628,7 +628,7 @@ class ServerRepository:
del self.clientsByConnection[client.connection]
del self.clientsByDoIdBase[client.doIdBase]
id = client.doIdBase / self.doIdRange
id = client.doIdBase // self.doIdRange
self.idAllocator.free(id)
self.qcr.removeConnection(client.connection)
@ -689,7 +689,7 @@ class ServerRepository:
def clientHardDisconnectTask(self, task):
""" client did not tell us he was leaving but we lost connection to
him, so we need to update our data and tell others """
for client in self.clientsByConnection.values():
for client in list(self.clientsByConnection.values()):
if not self.qcr.isConnectionOk(client.connection):
self.handleClientDisconnect(client)
return Task.cont

View File

@ -411,19 +411,12 @@ send_datagram(const Datagram &dg) {
if (!result && _bdc.IsConnected()) {
#ifdef HAVE_PYTHON
std::ostringstream s;
#if PY_VERSION_HEX >= 0x03030000
PyObject *exc_type = PyExc_ConnectionError;
#else
PyObject *exc_type = PyExc_OSError;
#endif
s << endl << "Error sending message: " << endl;
dg.dump_hex(s);
s << "Message data: " << dg.get_data() << endl;
string message = s.str();
PyErr_SetString(exc_type, message.c_str());
PyErr_SetString(PyExc_ConnectionError, message.c_str());
#endif
}
return result;
@ -922,22 +915,14 @@ describe_message(std::ostream &out, const string &prefix,
if (_python_repository != nullptr) {
PyObject *msgId = PyLong_FromLong(msg_type);
nassertv(msgId != nullptr);
#if PY_MAJOR_VERSION >= 3
PyObject *methodName = PyUnicode_FromString("_getMsgName");
#else
PyObject *methodName = PyString_FromString("_getMsgName");
#endif
nassertv(methodName != nullptr);
PyObject *result = PyObject_CallMethodObjArgs(_python_repository, methodName,
msgId, nullptr);
nassertv(result != nullptr);
#if PY_MAJOR_VERSION >= 3
msgName += string(PyUnicode_AsUTF8(result));
#else
msgName += string(PyString_AsString(result));
#endif
Py_DECREF(methodName);
Py_DECREF(msgId);

View File

@ -52,10 +52,7 @@ of the slider to change settings. Click on:
You can pack multiple sliders into a single panel:
if sys.version_info >= (3, 0):
from tkinter import *
else:
from Tkinter import *
from tkinter import *
def func1(x):
print '1:', x

View File

@ -1,17 +1,13 @@
__all__ = ["Dtool_ObjectToDict", "Dtool_funcToMethod"]
import sys
def Dtool_ObjectToDict(cls, name, obj):
cls.DtoolClassDict[name] = obj
def Dtool_funcToMethod(func, cls, method_name=None):
"""Adds func to class so it is an accessible method; use method_name to specify the name to be used for calling the method.
The new method is accessible to any instance immediately."""
if sys.version_info < (3, 0):
func.im_class = cls
func.im_func = func
func.im_self = None
func.__func__ = func
func.__self__ = None
if not method_name:

View File

@ -12,7 +12,6 @@ from direct.showbase import ShowBaseGlobal
from . import DirectGuiGlobals as DGG
from .DirectFrame import *
from .OnscreenText import OnscreenText
import sys
# import this to make sure it gets pulled into the publish
import encodings.utf_8
from direct.showbase.DirectObject import DirectObject
@ -274,16 +273,9 @@ class DirectEntry(DirectFrame):
does not change the current cursor position. Also see
enterText(). """
if sys.version_info >= (3, 0):
assert not isinstance(text, bytes)
self.unicodeText = True
self.guiItem.setWtext(text)
else:
self.unicodeText = isinstance(text, unicode)
if self.unicodeText:
self.guiItem.setWtext(text)
else:
self.guiItem.setText(text)
assert not isinstance(text, bytes)
self.unicodeText = True
self.guiItem.setWtext(text)
def get(self, plain = False):
""" Returns the text currently showing in the typable region.

View File

@ -24,12 +24,6 @@ from .DirectGuiBase import *
from .OnscreenImage import OnscreenImage
from .OnscreenGeom import OnscreenGeom
from .OnscreenText import OnscreenText
import sys
if sys.version_info >= (3, 0):
stringType = str
else:
stringType = basestring
class DirectFrame(DirectGuiWidget):
@ -105,7 +99,7 @@ class DirectFrame(DirectGuiWidget):
self["text"] = text
text = self["text"]
if text is None or isinstance(text, stringType):
if text is None or isinstance(text, str):
text_list = (text,) * self['numStates']
else:
text_list = text
@ -126,7 +120,7 @@ class DirectFrame(DirectGuiWidget):
geom = self["geom"]
if geom is None or \
isinstance(geom, NodePath) or \
isinstance(geom, stringType):
isinstance(geom, str):
geom_list = (geom,) * self['numStates']
else:
geom_list = geom
@ -147,11 +141,11 @@ class DirectFrame(DirectGuiWidget):
if image is None or \
isinstance(image, NodePath) or \
isinstance(image, Texture) or \
isinstance(image, stringType) or \
isinstance(image, str) or \
isinstance(image, Filename) or \
(len(image) == 2 and \
isinstance(image[0], stringType) and \
isinstance(image[1], stringType)):
isinstance(image[0], str) and \
isinstance(image[1], str)):
image_list = (image,) * self['numStates']
else:
image_list = image

View File

@ -97,12 +97,6 @@ from .OnscreenImage import *
from direct.directtools.DirectUtil import ROUND_TO
from direct.showbase import DirectObject
from direct.task import Task
import sys
if sys.version_info >= (3, 0):
stringType = str
else:
stringType = basestring
guiObjectCollector = PStatCollector("Client::GuiObjects")
@ -960,7 +954,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
# Convert None, and string arguments
if relief == None:
relief = PGFrameStyle.TNone
elif isinstance(relief, stringType):
elif isinstance(relief, str):
# Convert string to frame style int
relief = DGG.FrameStyleDict[relief]
# Set style
@ -1001,14 +995,14 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
textures = self['frameTexture']
if textures == None or \
isinstance(textures, Texture) or \
isinstance(textures, stringType):
isinstance(textures, str):
textures = (textures,) * self['numStates']
for i in range(self['numStates']):
if i >= len(textures):
texture = textures[-1]
else:
texture = textures[i]
if isinstance(texture, stringType):
if isinstance(texture, str):
texture = loader.loadTexture(texture)
if texture:
self.frameStyle[i].setTexture(texture)

View File

@ -13,12 +13,6 @@ from direct.directnotify import DirectNotifyGlobal
from direct.task.Task import Task
from .DirectFrame import *
from .DirectButton import *
import sys
if sys.version_info >= (3,0):
stringType = str
else:
stringType = basestring
class DirectScrolledListItem(DirectButton):
@ -71,7 +65,7 @@ class DirectScrolledList(DirectFrame):
# so we can modify it without mangling the user's list
if 'items' in kw:
for item in kw['items']:
if not isinstance(item, stringType):
if not isinstance(item, str):
break
else:
# we get here if every item in 'items' is a string
@ -116,7 +110,7 @@ class DirectScrolledList(DirectFrame):
DirectFrame, (self,),
)
for item in self["items"]:
if not isinstance(item, stringType):
if not isinstance(item, str):
item.reparentTo(self.itemFrame)
self.initialiseoptions(DirectScrolledList)
@ -134,7 +128,7 @@ class DirectScrolledList(DirectFrame):
else:
self.maxHeight = 0.0
for item in self["items"]:
if not isinstance(item, stringType):
if not isinstance(item, str):
self.maxHeight = max(self.maxHeight, item.getHeight())
def setScrollSpeed(self):
@ -182,7 +176,7 @@ class DirectScrolledList(DirectFrame):
if len(self["items"]) == 0:
return 0
if isinstance(self["items"][0], stringType):
if isinstance(self["items"][0], str):
self.notify.warning("getItemIndexForItemID: cant find itemID for non-class list items!")
return 0
@ -248,7 +242,7 @@ class DirectScrolledList(DirectFrame):
# Hide them all
for item in self["items"]:
if not isinstance(item, stringType):
if not isinstance(item, str):
item.hide()
# Then show the ones in range, and stack their positions
@ -258,7 +252,7 @@ class DirectScrolledList(DirectFrame):
#print "stacking buttontext[", i,"]", self["items"][i]["text"]
# If the item is a 'str', then it has not been created (scrolled list is 'as needed')
# Therefore, use the the function given to make it or just make it a frame
if isinstance(item, stringType):
if isinstance(item, str):
if self['itemMakeFunction']:
# If there is a function to create the item
item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs'])
@ -290,7 +284,7 @@ class DirectScrolledList(DirectFrame):
# Therefore, use the the function given to make it or
# just make it a frame
#print "Making " + str(item)
if isinstance(item, stringType):
if isinstance(item, str):
if self['itemMakeFunction']:
# If there is a function to create the item
item = self['itemMakeFunction'](item, i, self['itemMakeExtraArgs'])
@ -355,16 +349,16 @@ class DirectScrolledList(DirectFrame):
Add this string and extraArg to the list
"""
assert self.notify.debugStateCall(self)
if not isinstance(item, stringType):
if not isinstance(item, str):
# cant add attribs to non-classes (like strings & ints)
item.itemID = self.nextItemID
self.nextItemID += 1
self['items'].append(item)
if not isinstance(item, stringType):
if not isinstance(item, str):
item.reparentTo(self.itemFrame)
if refresh:
self.refresh()
if not isinstance(item, stringType):
if not isinstance(item, str):
return item.itemID # to pass to scrollToItemID
def removeItem(self, item, refresh=1):
@ -379,7 +373,7 @@ class DirectScrolledList(DirectFrame):
if hasattr(self, "currentSelected") and self.currentSelected is item:
del self.currentSelected
self["items"].remove(item)
if not isinstance(item, stringType):
if not isinstance(item, str):
item.reparentTo(ShowBaseGlobal.hidden)
self.refresh()
return 1
@ -397,7 +391,7 @@ class DirectScrolledList(DirectFrame):
if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')):
item.destroy()
self["items"].remove(item)
if not isinstance(item, stringType):
if not isinstance(item, str):
item.reparentTo(ShowBaseGlobal.hidden)
self.refresh()
return 1
@ -419,7 +413,7 @@ class DirectScrolledList(DirectFrame):
if hasattr(self, "currentSelected") and self.currentSelected is item:
del self.currentSelected
self["items"].remove(item)
if not isinstance(item, stringType):
if not isinstance(item, str):
#RAU possible leak here, let's try to do the right thing
#item.reparentTo(ShowBaseGlobal.hidden)
item.removeNode()
@ -444,7 +438,7 @@ class DirectScrolledList(DirectFrame):
if (hasattr(item, 'destroy') and hasattr(item.destroy, '__call__')):
item.destroy()
self["items"].remove(item)
if not isinstance(item, stringType):
if not isinstance(item, str):
#RAU possible leak here, let's try to do the right thing
#item.reparentTo(ShowBaseGlobal.hidden)
item.removeNode()
@ -469,7 +463,7 @@ class DirectScrolledList(DirectFrame):
def getSelectedText(self):
assert self.notify.debugStateCall(self)
if isinstance(self['items'][self.index], stringType):
if isinstance(self['items'][self.index], str):
return self['items'][self.index]
else:
return self['items'][self.index]['text']

View File

@ -9,12 +9,6 @@ __all__ = ['DirectWaitBar']
from panda3d.core import *
from . import DirectGuiGlobals as DGG
from .DirectFrame import *
import sys
if sys.version_info >= (3, 0):
stringType = str
else:
stringType = basestring
"""
import DirectWaitBar
@ -102,7 +96,7 @@ class DirectWaitBar(DirectFrame):
"""Updates the bar texture, which you can set using bar['barTexture']."""
# this must be a single texture (or a string).
texture = self['barTexture']
if isinstance(texture, stringType):
if isinstance(texture, str):
texture = loader.loadTexture(texture)
if texture:
self.barStyle.setTexture(texture)

View File

@ -4,12 +4,7 @@ __all__ = ['OnscreenGeom']
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
import sys
if sys.version_info >= (3, 0):
stringType = str
else:
stringType = basestring
class OnscreenGeom(DirectObject, NodePath):
def __init__(self, geom = None,
@ -98,7 +93,7 @@ class OnscreenGeom(DirectObject, NodePath):
# Assign geometry
if isinstance(geom, NodePath):
self.assign(geom.copyTo(parent, sort))
elif isinstance(geom, stringType):
elif isinstance(geom, str):
self.assign(loader.loadModel(geom))
self.reparentTo(parent, sort)

View File

@ -8,12 +8,6 @@ __all__ = ['OnscreenImage']
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
import sys
if sys.version_info >= (3, 0):
stringType = str
else:
stringType = basestring
class OnscreenImage(DirectObject, NodePath):
@ -106,8 +100,7 @@ class OnscreenImage(DirectObject, NodePath):
# Assign geometry
if isinstance(image, NodePath):
self.assign(image.copyTo(parent, sort))
elif isinstance(image, stringType) or \
isinstance(image, Texture):
elif isinstance(image, str) or isinstance(image, Texture):
if isinstance(image, Texture):
# It's a Texture
tex = image

View File

@ -8,7 +8,6 @@ __all__ = ['OnscreenText', 'Plain', 'ScreenTitle', 'ScreenPrompt', 'NameConfirm'
from panda3d.core import *
from . import DirectGuiGlobals as DGG
import sys
## These are the styles of text we might commonly see. They set the
## overall appearance of the text according to one of a number of
@ -281,34 +280,15 @@ class OnscreenText(NodePath):
self.textNode.clearText()
def setText(self, text):
if sys.version_info >= (3, 0):
assert not isinstance(text, bytes)
self.unicodeText = True
else:
self.unicodeText = isinstance(text, unicode)
if self.unicodeText:
self.textNode.setWtext(text)
else:
self.textNode.setText(text)
assert not isinstance(text, bytes)
self.textNode.setWtext(text)
def appendText(self, text):
if sys.version_info >= (3, 0):
assert not isinstance(text, bytes)
self.unicodeText = True
else:
self.unicodeText = isinstance(text, unicode)
if self.unicodeText:
self.textNode.appendWtext(text)
else:
self.textNode.appendText(text)
assert not isinstance(text, bytes)
self.textNode.appendWtext(text)
def getText(self):
if self.unicodeText:
return self.textNode.getWtext()
else:
return self.textNode.getText()
return self.textNode.getWtext()
text = property(getText, setText)

View File

@ -454,12 +454,9 @@ class Interval(DirectObject):
"""
# Don't use a regular import, to prevent ModuleFinder from picking
# it up as a dependency when building a .p3d package.
import importlib, sys
import importlib
EntryScale = importlib.import_module('direct.tkwidgets.EntryScale')
if sys.version_info >= (3, 0):
tkinter = importlib.import_module('tkinter')
else:
tkinter = importlib.import_module('Tkinter')
tkinter = importlib.import_module('tkinter')
if tl == None:
tl = tkinter.Toplevel()

View File

@ -7,12 +7,6 @@ from . import Particles
from . import ForceGroup
from direct.directnotify import DirectNotifyGlobal
import sys
if sys.version_info < (3, 0):
FileNotFoundError = IOError
class ParticleEffect(NodePath):

View File

@ -3,27 +3,14 @@ from direct.showbase.PythonUtil import makeFlywheelGen
from direct.showbase.PythonUtil import itype, serialNum, safeRepr, fastRepr
from direct.showbase.Job import Job
import types, weakref, random, sys
import builtins
if sys.version_info >= (3, 0):
import builtins as __builtin__
intTypes = (int,)
deadEndTypes = (bool, types.BuiltinFunctionType,
types.BuiltinMethodType, complex,
float, int,
type(None), type(NotImplemented),
type, types.CodeType, types.FunctionType,
bytes, str, tuple)
else:
import __builtin__
intTypes = (int, long)
deadEndTypes = (types.BooleanType, types.BuiltinFunctionType,
types.BuiltinMethodType, types.ComplexType,
types.FloatType, types.IntType, types.LongType,
types.NoneType, types.NotImplementedType,
types.TypeType, types.CodeType, types.FunctionType,
types.StringType, types.UnicodeType, types.TupleType)
deadEndTypes = (bool, types.BuiltinFunctionType,
types.BuiltinMethodType, complex,
float, int,
type(None), type(NotImplemented),
type, types.CodeType, types.FunctionType,
bytes, str, tuple)
def _createContainerLeak():
@ -136,7 +123,7 @@ class Indirection:
def dereferenceDictKey(self, parentDict):
# look ourselves up in parentDict
key = self._getNonWeakDictKey()
# objects in __builtin__ will have parentDict==None
# objects in builtins will have parentDict==None
if parentDict is None:
return key
return parentDict[key]
@ -185,7 +172,7 @@ class ObjectRef:
# make sure we're not storing a reference to the actual object,
# that could cause a memory leak
assert type(objId) in intTypes
assert type(objId) is int
# prevent cycles (i.e. base.loader.base.loader)
assert not self.goesThrough(objId=objId)
@ -206,7 +193,7 @@ class ObjectRef:
def goesThroughGen(self, obj=None, objId=None):
if obj is None:
assert type(objId) in intTypes
assert type(objId) is int
else:
objId = id(obj)
o = None
@ -253,9 +240,9 @@ class ObjectRef:
# eval('curObj.foo.bar.someDict')
evalStr = 'curObj%s' % evalStr
else:
# this eval is not based off of curObj, use the global__builtin__ namespace
# put __builtin__ at the start if it's not already there
bis = '__builtin__'
# this eval is not based off of curObj, use the globalbuiltins namespace
# put builtins at the start if it's not already there
bis = 'builtins'
if evalStr[:len(bis)] != bis:
evalStr = '%s.%s' % (bis, evalStr)
try:
@ -369,17 +356,17 @@ class FindContainers(Job):
ContainerLeakDetector.addPrivateObj(self.__dict__)
# set up the base containers, the ones that hold most objects
ref = ObjectRef(Indirection(evalStr='__builtin__.__dict__'), id(__builtin__.__dict__))
self._id2baseStartRef[id(__builtin__.__dict__)] = ref
ref = ObjectRef(Indirection(evalStr='builtins.__dict__'), id(builtins.__dict__))
self._id2baseStartRef[id(builtins.__dict__)] = ref
# container for objects that want to make sure they are found by
# the object exploration algorithm, including objects that exist
# just to measure things such as C++ memory usage, scene graph size,
# framerate, etc. See LeakDetectors.py
if not hasattr(__builtin__, "leakDetectors"):
__builtin__.leakDetectors = {}
if not hasattr(builtins, "leakDetectors"):
builtins.leakDetectors = {}
ref = ObjectRef(Indirection(evalStr='leakDetectors'), id(leakDetectors))
self._id2baseStartRef[id(leakDetectors)] = ref
for i in self._addContainerGen(__builtin__.__dict__, ref):
for i in self._addContainerGen(builtins.__dict__, ref):
pass
try:
base
@ -457,7 +444,7 @@ class FindContainers(Job):
objId = id(obj)
if objId in self._id2discoveredStartRef:
existingRef = self._id2discoveredStartRef[objId]
if type(existingRef) not in intTypes:
if type(existingRef) is not int:
if (existingRef.getNumIndirections() >=
ref.getNumIndirections()):
# the ref that we already have is more concise than the new ref
@ -522,11 +509,11 @@ class FindContainers(Job):
startRefWorkingList.refGen = fw
if curObjRef is None:
# this ref set is empty, choose another
# the base set should never be empty (__builtin__ etc.)
# the base set should never be empty (builtins etc.)
continue
# do we need to go look up the object in _id2ref? sometimes we do that
# to avoid storing multiple redundant refs to a single item
if type(curObjRef) in intTypes:
if type(curObjRef) is int:
startId = curObjRef
curObjRef = None
try:
@ -605,7 +592,7 @@ class FindContainers(Job):
# don't yield, container might lose this element
pass
if not goesThrough:
if curObj is __builtin__.__dict__:
if curObj is builtins.__dict__:
objRef = ObjectRef(Indirection(evalStr='%s' % key),
id(curObj[key]))
else:

View File

@ -8,12 +8,9 @@ from direct.showbase.PythonUtil import AlphabetCounter
from direct.showbase.Job import Job
import gc
import types
import sys
GarbageCycleCountAnnounceEvent = 'announceGarbageCycleDesc2num'
if sys.version_info >= (3, 0):
xrange = range
class FakeObject:
pass
@ -23,7 +20,7 @@ class FakeDelObject:
pass
def _createGarbage(num=1):
for i in xrange(num):
for i in range(num):
a = FakeObject()
b = FakeObject()
a.other = b
@ -84,7 +81,7 @@ class GarbageReport(Job):
self.numGarbageInstances = len(garbageInstances)
# grab the ids of the garbage instances (objects with __del__)
self.garbageInstanceIds = set()
for i in xrange(len(garbageInstances)):
for i in range(len(garbageInstances)):
self.garbageInstanceIds.add(id(garbageInstances[i]))
if not (i % 20):
yield None
@ -144,7 +141,7 @@ class GarbageReport(Job):
self.cycleIds = set()
# make the id->index table to speed up the next steps
for i in xrange(self.numGarbage):
for i in range(self.numGarbage):
self._id2index[id(self.garbage[i])] = i
if not (i % 20):
yield None
@ -153,7 +150,7 @@ class GarbageReport(Job):
if self._args.fullReport and (self.numGarbage != 0):
if self._args.verbose:
self.notify.info('getting referrers...')
for i in xrange(self.numGarbage):
for i in range(self.numGarbage):
yield None
for result in self._getReferrers(self.garbage[i]):
yield None
@ -165,7 +162,7 @@ class GarbageReport(Job):
if self.numGarbage > 0:
if self._args.verbose:
self.notify.info('getting referents...')
for i in xrange(self.numGarbage):
for i in range(self.numGarbage):
yield None
for result in self._getReferents(self.garbage[i]):
yield None
@ -173,7 +170,7 @@ class GarbageReport(Job):
self.referentsByNumber[i] = byNum
self.referentsByReference[i] = byRef
for i in xrange(self.numGarbage):
for i in range(self.numGarbage):
if hasattr(self.garbage[i], '_garbageInfo') and callable(self.garbage[i]._garbageInfo):
try:
info = self.garbage[i]._garbageInfo()
@ -189,7 +186,7 @@ class GarbageReport(Job):
if self._args.findCycles and self.numGarbage > 0:
if self._args.verbose:
self.notify.info('calculating cycles...')
for i in xrange(self.numGarbage):
for i in range(self.numGarbage):
yield None
for newCycles in self._getCycles(i, self.uniqueCycleSets):
yield None
@ -219,7 +216,7 @@ class GarbageReport(Job):
startIndex -= 1
endIndex -= 1
for index in xrange(startIndex, endIndex):
for index in range(startIndex, endIndex):
if numToSkip:
numToSkip -= 1
continue
@ -259,7 +256,7 @@ class GarbageReport(Job):
# get object being referenced by container
nextObj = objs[index+1]
cycleBySyntax += brackets[0]
for index in xrange(len(obj)):
for index in range(len(obj)):
if obj[index] is nextObj:
index = str(index)
break
@ -313,7 +310,7 @@ class GarbageReport(Job):
digits = digits
format = '%0' + '%s' % digits + 'i:%s \t%s'
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
idx = garbageIndices[i]
if self._args.safeMode:
@ -329,7 +326,7 @@ class GarbageReport(Job):
# also log the types of the objects
s.append('===== Garbage Item Types %s=====' % abbrev)
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
idx = garbageIndices[i]
objStr = str(deeptype(self.garbage[idx]))
@ -342,21 +339,21 @@ class GarbageReport(Job):
if self._args.findCycles:
s.append('===== Garbage Cycles (Garbage Item Numbers) =====')
ac = AlphabetCounter()
for i in xrange(self.numCycles):
for i in range(self.numCycles):
yield None
s.append('%s:%s' % (ac.next(), self.cycles[i]))
if self._args.findCycles:
s.append('===== Garbage Cycles (Python Syntax) =====')
ac = AlphabetCounter()
for i in xrange(len(self.cyclesBySyntax)):
for i in range(len(self.cyclesBySyntax)):
yield None
s.append('%s:%s' % (ac.next(), self.cyclesBySyntax[i]))
if len(self._id2garbageInfo):
s.append('===== Garbage Custom Info =====')
ac = AlphabetCounter()
for i in xrange(len(self.cyclesBySyntax)):
for i in range(len(self.cyclesBySyntax)):
yield None
counter = ac.next()
_id = id(self.garbage[i])
@ -366,19 +363,19 @@ class GarbageReport(Job):
if self._args.fullReport:
format = '%0' + '%s' % digits + 'i:%s'
s.append('===== Referrers By Number (what is referring to garbage item?) =====')
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
s.append(format % (i, self.referrersByNumber[i]))
s.append('===== Referents By Number (what is garbage item referring to?) =====')
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
s.append(format % (i, self.referentsByNumber[i]))
s.append('===== Referrers (what is referring to garbage item?) =====')
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
s.append(format % (i, self.referrersByReference[i]))
s.append('===== Referents (what is garbage item referring to?) =====')
for i in xrange(numGarbage):
for i in range(numGarbage):
yield None
s.append(format % (i, self.referentsByReference[i]))
@ -386,7 +383,7 @@ class GarbageReport(Job):
if self._args.log:
self.printingBegin()
for i in xrange(len(self._report)):
for i in range(len(self._report)):
if self.numGarbage > 0:
yield None
self.notify.info(self._report[i])
@ -450,7 +447,7 @@ class GarbageReport(Job):
yield None
# look to see if each referrer is another garbage item
byNum = []
for i in xrange(len(byRef)):
for i in range(len(byRef)):
if not (i % 20):
yield None
referrer = byRef[i]
@ -467,7 +464,7 @@ class GarbageReport(Job):
yield None
# look to see if each referent is another garbage item
byNum = []
for i in xrange(len(byRef)):
for i in range(len(byRef)):
if not (i % 20):
yield None
referent = byRef[i]
@ -484,7 +481,7 @@ class GarbageReport(Job):
return cycle
min = 1<<30
minIndex = None
for i in xrange(len(cycle)):
for i in range(len(cycle)):
elem = cycle[i]
if elem < min:
min = elem
@ -517,7 +514,7 @@ class GarbageReport(Job):
else:
print('restart: %s root=%s cur=%s resume=%s' % (
candidateCycle, rootId, curId, resumeIndex))
for index in xrange(resumeIndex, len(self.referentsByNumber[curId])):
for index in range(resumeIndex, len(self.referentsByNumber[curId])):
yield None
refId = self.referentsByNumber[curId][index]
if self.notify.getDebug():

View File

@ -5,12 +5,8 @@ ContainerLeakDetector.
from panda3d.core import *
from direct.showbase.DirectObject import DirectObject
from direct.showbase.Job import Job
import gc, sys
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
import gc
import builtins
class LeakDetector:

View File

@ -1,12 +1,8 @@
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.showbase.DirectObject import DirectObject
from direct.showbase.Job import Job
import gc, sys
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
import gc
import builtins
class MessengerLeakObject(DirectObject):

View File

@ -16,11 +16,8 @@ from direct.showbase import DirectObject, ObjectPool, GarbageReport
from direct.showbase.PythonUtil import makeList, Sync
import gc
import sys
import builtins
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
class ExclusiveObjectPool(DirectObject.DirectObject):
# ObjectPool specialization that excludes particular objects

View File

@ -6,12 +6,7 @@ from direct.showbase.PythonUtil import (
_getProfileResultFileInfo, _setProfileResultsFileInfo)
import profile
import pstats
import sys
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
import builtins
class PercentStats(pstats.Stats):

View File

@ -37,17 +37,13 @@ import os
import sys
import random
import time
import builtins
import importlib
__report_indent = 3
from panda3d.core import ConfigVariableBool
if sys.version_info >= (3, 0):
import builtins
xrange = range
else:
import __builtin__ as builtins
"""
# with one integer positional arg, this uses about 4/5 of the memory of the Functor class below
@ -59,41 +55,6 @@ def Functor(function, *args, **kArgs):
return functor
"""
try:
import importlib
except ImportError:
# Backward compatibility for Python 2.6.
def _resolve_name(name, package, level):
if not hasattr(package, 'rindex'):
raise ValueError("'package' not set to a string")
dot = len(package)
for x in xrange(level, 1, -1):
try:
dot = package.rindex('.', 0, dot)
except ValueError:
raise ValueError("attempted relative import beyond top-level "
"package")
return "%s.%s" % (package[:dot], name)
def import_module(name, package=None):
if name.startswith('.'):
if not package:
raise TypeError("relative imports require the 'package' argument")
level = 0
for character in name:
if character != '.':
break
level += 1
name = _resolve_name(name[level:], package, level)
__import__(name)
return sys.modules[name]
imp = import_module('imp')
importlib = imp.new_module("importlib")
importlib._resolve_name = _resolve_name
importlib.import_module = import_module
sys.modules['importlib'] = importlib
class Functor:
def __init__(self, function, *args, **kargs):
@ -506,7 +467,7 @@ def replace(list, old, new, all=0):
return 1
else:
numReplaced = 0
for i in xrange(len(list)):
for i in range(len(list)):
if list[i] == old:
numReplaced += 1
list[i] = new
@ -1659,16 +1620,13 @@ def itype(obj):
# version of type that gives more complete information about instance types
global dtoolSuperBase
t = type(obj)
if sys.version_info < (3, 0) and t is types.InstanceType:
return "<type 'instance' of <class %s>>" % (obj.__class__)
else:
# C++ object instances appear to be types via type()
# check if this is a C++ object
if dtoolSuperBase is None:
_getDtoolSuperBase()
if isinstance(obj, dtoolSuperBase):
return "<type 'instance' of %s>" % (obj.__class__)
return t
# C++ object instances appear to be types via type()
# check if this is a C++ object
if dtoolSuperBase is None:
_getDtoolSuperBase()
if isinstance(obj, dtoolSuperBase):
return "<type 'instance' of %s>" % (obj.__class__)
return t
def deeptype(obj, maxLen=100, _visitedIds=None):
if _visitedIds is None:
@ -1728,7 +1686,7 @@ def getNumberedTypedString(items, maxLen=5000, numPrefix=''):
first = True
s = ''
snip = '<SNIP>'
for i in xrange(len(items)):
for i in range(len(items)):
if not first:
s += '\n'
first = False
@ -1759,7 +1717,7 @@ def getNumberedTypedSortedString(items, maxLen=5000, numPrefix=''):
first = True
s = ''
strs.sort()
for i in xrange(len(strs)):
for i in range(len(strs)):
if not first:
s += '\n'
first = False
@ -1777,7 +1735,7 @@ def printNumberedTyped(items, maxLen=5000):
n //= 10
digits = digits
format = '%0' + '%s' % digits + 'i:%s \t%s'
for i in xrange(len(items)):
for i in range(len(items)):
objStr = fastRepr(items[i])
if len(objStr) > maxLen:
snip = '<SNIP>'
@ -1792,7 +1750,7 @@ def printNumberedTypesGen(items, maxLen=5000):
n //= 10
digits = digits
format = '%0' + '%s' % digits + 'i:%s'
for i in xrange(len(items)):
for i in range(len(items)):
print(format % (i, itype(items[i])))
yield None
@ -2287,14 +2245,14 @@ def makeFlywheelGen(objects, countList=None, countFunc=None, scale=None):
countList.append(countFunc(object))
if scale is not None:
# scale the counts if we've got a scale factor
for i in xrange(len(countList)):
for i in range(len(countList)):
yield None
if countList[i] > 0:
countList[i] = max(1, int(countList[i] * scale))
# create a dict for the flywheel to use during its iteration to efficiently select
# the objects for the sequence
index2objectAndCount = {}
for i in xrange(len(countList)):
for i in range(len(countList)):
yield None
index2objectAndCount[i] = [objects[i], countList[i]]
# create the flywheel generator
@ -2540,7 +2498,7 @@ if __debug__ and __name__ == '__main__':
def testAlphabetCounter():
tempList = []
ac = AlphabetCounter()
for i in xrange(26*3):
for i in range(26*3):
tempList.append(ac.next())
assert tempList == [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ',
@ -2551,7 +2509,7 @@ if __debug__ and __name__ == '__main__':
num += 26 # AAZ
num += 1 # ABA
num += 2 # ABC
for i in xrange(num):
for i in range(num):
x = ac.next()
assert x == 'ABC'
testAlphabetCounter()

View File

@ -46,10 +46,7 @@ from direct.extensions_native import NodePath_extensions
# This needs to be available early for DirectGUI imports
import sys
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
import builtins
builtins.config = DConfig
from direct.directnotify.DirectNotifyGlobal import directNotify, giveNotify

View File

@ -72,13 +72,8 @@ def inspect(anObject):
return Inspector.inspect(anObject)
import sys
if sys.version_info >= (3, 0):
import builtins
else:
import __builtin__ as builtins
import builtins
builtins.inspect = inspect
del sys
# this also appears in AIBaseGlobal
if (not __debug__) and __dev__:

View File

@ -1,11 +1,8 @@
""" This module is now vestigial. """
import sys, Pmw
from tkinter import *
if sys.version_info >= (3, 0):
from tkinter import *
else:
from Tkinter import *
# This is required by the ihooks.py module used by Squeeze (used by
# pandaSqueezer.py) so that Pmw initializes properly

View File

@ -230,10 +230,7 @@ class VFSLoader:
#print >>sys.stderr, "importing frozen %s" % (fullname)
module = imp.load_module(fullname, None, fullname,
('', '', imp.PY_FROZEN))
# Workaround for bug in Python 2.
if getattr(module, '__path__', None) == fullname:
module.__path__ = []
module.__path__ = []
return module
def _read_code(self):
@ -288,13 +285,8 @@ class VFSLoader:
if data[:4] != imp.get_magic():
raise ValueError("Bad magic number in %s" % (vfile))
if sys.version_info >= (3, 0):
t = int.from_bytes(data[4:8], 'little')
data = data[12:]
else:
t = ord(data[4]) + (ord(data[5]) << 8) + \
(ord(data[6]) << 16) + (ord(data[7]) << 24)
data = data[8:]
t = int.from_bytes(data[4:8], 'little')
data = data[12:]
if not timestamp or t == timestamp:
return marshal.loads(data)
@ -320,14 +312,8 @@ class VFSLoader:
pass
else:
f.write(imp.get_magic())
if sys.version_info >= (3, 0):
f.write((self.timestamp & 0xffffffff).to_bytes(4, 'little'))
f.write(b'\0\0\0\0')
else:
f.write(chr(self.timestamp & 0xff) +
chr((self.timestamp >> 8) & 0xff) +
chr((self.timestamp >> 16) & 0xff) +
chr((self.timestamp >> 24) & 0xff))
f.write((self.timestamp & 0xffffffff).to_bytes(4, 'little'))
f.write(b'\0\0\0\0')
f.write(marshal.dumps(code))
f.close()

View File

@ -11,7 +11,6 @@ __all__ = [
]
from panda3d import core
import sys
import os
import io
import encodings
@ -19,19 +18,6 @@ from posixpath import join
_vfs = core.VirtualFileSystem.getGlobalPtr()
if sys.version_info < (3, 0):
# Python 3 defines these subtypes of IOError, but Python 2 doesn't.
FileNotFoundError = IOError
IsADirectoryError = IOError
FileExistsError = IOError
PermissionError = IOError
unicodeType = unicode
strType = str
else:
unicodeType = str
strType = ()
def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True):
"""This function emulates the built-in Python open() function, additionally
@ -39,12 +25,9 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
arguments as Python's built-in open() function.
"""
if sys.version_info >= (3, 0):
# Python 3 is much stricter than Python 2, which lets
# unknown flags fall through.
for ch in mode:
if ch not in 'rwxabt+U':
raise ValueError("invalid mode: '%s'" % (mode))
for ch in mode:
if ch not in 'rwxabt+U':
raise ValueError("invalid mode: '%s'" % (mode))
creating = 'x' in mode
writing = 'w' in mode
@ -81,21 +64,16 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
# We can also "open" a VirtualFile object for reading.
vfile = file
filename = vfile.getFilename()
elif isinstance(file, unicodeType):
elif isinstance(file, str):
# If a raw string is given, assume it's an os-specific
# filename.
filename = core.Filename.fromOsSpecificW(file)
elif isinstance(file, strType):
filename = core.Filename.fromOsSpecific(file)
else:
# It's either a Filename object or an os.PathLike.
# If a Filename is given, make a writable copy anyway.
filename = core.Filename(file)
if binary or sys.version_info >= (3, 0):
filename.setBinary()
else:
filename.setText()
filename.setBinary()
if not vfile:
vfile = _vfs.getFile(filename)
@ -156,10 +134,6 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
if binary:
return raw
# If we're in Python 2, we don't decode unicode strings by default.
if not encoding and sys.version_info < (3, 0):
return raw
line_buffering = False
if buffering == 1:
line_buffering = True
@ -172,12 +146,6 @@ def open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
return wrapper
if sys.version_info < (3, 0):
# Python 2 had an alias for open() called file().
__all__.append('file')
file = open
class StreamIOWrapper(io.IOBase):
""" This is a file-like object that wraps around a C++ istream and/or
ostream object. It only deals with binary data; to work with text I/O,
@ -197,13 +165,7 @@ class StreamIOWrapper(io.IOBase):
if isinstance(stream, core.Ostream):
self.__writer = core.StreamWriter(stream, False)
self.__lastWrite = True
if sys.version_info >= (3, 0):
# In Python 3, we use appendData, which only accepts bytes.
self.__write = self.__writer.appendData
else:
# In Python 2.7, we also accept unicode objects, which are
# implicitly converted to C++ strings.
self.__write = self.__writer.write
self.__write = self.__writer.appendData
def __repr__(self):
s = "<direct.stdpy.file.StreamIOWrapper"

View File

@ -2,7 +2,6 @@
vfs constructs. This enables Python to interface more easily with Panda's
virtual file system. """
import sys
import os
import fnmatch
@ -52,9 +51,6 @@ def iglob(pathname):
def glob1(dirname, pattern):
if not dirname:
dirname = os.curdir
if sys.version_info < (3, 0) and isinstance(pattern, unicode) and not isinstance(dirname, unicode):
dirname = unicode(dirname, sys.getfilesystemencoding() or
sys.getdefaultencoding())
try:
names = os.listdir(dirname)
except os.error:
@ -81,9 +77,10 @@ def has_magic(s):
else:
return '*' in s or '?' in s or '[' in s
def escape(pathname):
drive, pathname = os.path.splitdrive(pathname)
if sys.version_info >= (3, 0) and isinstance(pathname, bytes):
if isinstance(pathname, bytes):
newpath = bytearray(drive)
for c in pathname:
if c == 42 or c == 63 or c == 91:

View File

@ -23,11 +23,8 @@ support extensions of this nature. """
import sys
from panda3d.core import BamWriter, BamReader
from copyreg import dispatch_table
if sys.version_info >= (3, 0):
from copyreg import dispatch_table
else:
from copy_reg import dispatch_table
# A funny replacement for "import pickle" so we don't get confused
# with the local pickle.py.

View File

@ -31,12 +31,8 @@ consider_yield = core.Thread.consider_yield
forceYield = force_yield
considerYield = consider_yield
error = RuntimeError
if sys.version_info >= (3, 3):
error = RuntimeError
else:
class error(Exception):
pass
class LockType:
""" Implements a mutex lock. Instead of directly subclassing

View File

@ -17,19 +17,16 @@ from direct.showbase.MessengerGlobal import messenger
import types
import random
import importlib
import sys
try:
if sys.version_info >= (3, 0):
import _signal as signal
else:
import signal
import _signal as signal
except ImportError:
signal = None
from panda3d.core import *
from direct.extensions_native import HTTPChannel_extensions
def print_exc_plus():
"""
Print the usual traceback information, followed by a listing of all the

View File

@ -9,16 +9,11 @@ __all__ = ['AnimPanel', 'ActorControl']
# Import Tkinter, Pmw, and the floater code from this directory tree.
from direct.tkwidgets.AppShell import *
from direct.showbase.TkGlobal import *
import Pmw, sys, os
import Pmw, os
from direct.task import Task
from panda3d.core import Filename, getModelPath
if sys.version_info >= (3, 0):
from tkinter.simpledialog import askfloat
from tkinter.filedialog import askopenfilename
else:
from tkSimpleDialog import askfloat
from tkFileDialog import askopenfilename
from tkinter.simpledialog import askfloat
from tkinter.filedialog import askopenfilename
FRAMES = 0

View File

@ -106,12 +106,8 @@ __all__ = ['FSMInspector', 'StateInspector']
from direct.tkwidgets.AppShell import *
from direct.showbase.TkGlobal import *
import Pmw, math, operator, sys
if sys.version_info >= (3, 0):
from tkinter.simpledialog import askstring
else:
from tkSimpleDialog import askstring
import Pmw, math, operator
from tkinter.simpledialog import askstring
DELTA = (5.0 / 360.) * 2.0 * math.pi

View File

@ -12,17 +12,13 @@ from direct.directtools.DirectGlobals import *
from direct.directtools.DirectUtil import *
from direct.directtools.DirectGeometry import *
from direct.directtools.DirectSelection import *
import Pmw, os, sys
import Pmw, os
from direct.tkwidgets import Dial
from direct.tkwidgets import Floater
from direct.tkwidgets import Slider
from direct.tkwidgets import EntryScale
from direct.tkwidgets import VectorWidgets
if sys.version_info >= (3, 0):
from tkinter.filedialog import *
else:
from tkFileDialog import *
from tkinter.filedialog import *
PRF_UTILITIES = [

View File

@ -13,15 +13,9 @@ from direct.tkpanels import Placer
from direct.particles import ForceGroup
from direct.particles import Particles
from direct.particles import ParticleEffect
import Pmw, os, sys
if sys.version_info >= (3, 0):
from tkinter.filedialog import *
from tkinter.simpledialog import askstring
else:
from tkFileDialog import *
from tkSimpleDialog import askstring
import Pmw, os
from tkinter.filedialog import *
from tkinter.simpledialog import askstring
from panda3d.core import *
from panda3d.physics import *
from panda3d.direct import getParticlePath

View File

@ -4,14 +4,9 @@ __all__ = ['TaskManagerPanel', 'TaskManagerWidget']
from direct.tkwidgets.AppShell import *
from direct.showbase.DirectObject import DirectObject
import Pmw, sys
if sys.version_info >= (3, 0):
from tkinter import *
from tkinter.messagebox import askokcancel
else:
from Tkinter import *
from tkMessageBox import askokcancel
import Pmw
from tkinter import *
from tkinter.messagebox import askokcancel
class TaskManagerPanel(AppShell):

View File

@ -16,11 +16,7 @@ from . import Slider
from . import EntryScale
from . import VectorWidgets
from . import ProgressBar
if sys.version_info >= (3, 0):
from tkinter.filedialog import *
else:
from tkFileDialog import *
from tkinter.filedialog import *
"""

View File

@ -5,14 +5,9 @@ EntryScale Class: Scale with a label, and a linked and validated entry
__all__ = ['EntryScale', 'EntryScaleGroup']
from direct.showbase.TkGlobal import *
import Pmw, sys
if sys.version_info >= (3, 0):
from tkinter.simpledialog import *
from tkinter.colorchooser import askcolor
else:
from tkSimpleDialog import *
from tkColorChooser import askcolor
import Pmw
from tkinter.simpledialog import *
from tkinter.colorchooser import askcolor
"""
Change Min/Max buttons to labels, add highlight binding

View File

@ -24,10 +24,6 @@ from direct.showbase.TkGlobal import *
from panda3d.core import *
if sys.version_info < (3, 0):
FileNotFoundError = IOError
class TreeNode:
def __init__(self, canvas, parent, item, menuList = []):

View File

@ -8,12 +8,7 @@ from . import WidgetPropertiesDialog
import Pmw
from direct.directtools.DirectUtil import getTkColorString
from panda3d.core import Vec4
import sys
if sys.version_info >= (3, 0):
from tkinter.colorchooser import askcolor
else:
from tkColorChooser import askcolor
from tkinter.colorchooser import askcolor
VALUATOR_MINI = 'mini'
VALUATOR_FULL = 'full'

View File

@ -5,12 +5,7 @@ __all__ = ['VectorEntry', 'Vector2Entry', 'Vector3Entry', 'Vector4Entry', 'Color
from direct.showbase.TkGlobal import *
from . import Valuator
import Pmw
import sys
if sys.version_info >= (3, 0):
from tkinter.colorchooser import askcolor
else:
from tkColorChooser import askcolor
from tkinter.colorchooser import askcolor
class VectorEntry(Pmw.MegaWidget):

View File

@ -3,7 +3,7 @@
__all__ = ['WidgetPropertiesDialog']
from direct.showbase.TkGlobal import *
import Pmw, sys
import Pmw
"""
TODO:
@ -31,12 +31,8 @@ class WidgetPropertiesDialog(Toplevel):
self.propertyList.sort()
# Use default parent if none specified
if not parent:
if sys.version_info >= (3, 0):
import tkinter
parent = tkinter._default_root
else:
import Tkinter
parent = Tkinter._default_root
import tkinter
parent = tkinter._default_root
# Create toplevel window
Toplevel.__init__(self, parent)
self.transient(parent)

View File

@ -3,13 +3,9 @@ from wx.lib.agw import fourwaysplitter as FWS
from panda3d.core import *
from direct.showbase.ShowBase import *
from direct.showbase import ShowBaseGlobal
from direct.directtools.DirectGlobals import *
try:
base
except NameError:
base = ShowBase(False, windowType = 'none')
from .WxAppShell import *
from .ViewPort import *
@ -19,6 +15,7 @@ ID_FRONT_VIEW = 403
ID_LEFT_VIEW = 404
ID_PERSP_VIEW = 405
class WxPandaShell(WxAppShell):
""" Class for Panda3D LevelEditor """
frameWidth = 800
@ -37,6 +34,10 @@ class WxPandaShell(WxAppShell):
}
def __init__(self, fStartDirect = False):
base = getattr(ShowBaseGlobal, 'base', None)
if not base:
base = ShowBase(False, windowType='none')
fDirect = (base.config.GetBool('want-directtools', 0) or
(base.config.GetString("cluster-mode", '') != ''))
@ -237,5 +238,3 @@ class WxPandaShell(WxAppShell):
self.currentView = self.perspView
return self.currentView

View File

@ -22,7 +22,16 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(IS_FREEBSD 1)
endif()
set(PER_CONFIG_OPTIONS)
# Define the type of build we are setting up.
set(_configs Standard Release RelWithDebInfo Debug MinSizeRel)
if(DEFINED CMAKE_CXX_FLAGS_COVERAGE)
list(APPEND _configs Coverage)
endif()
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES ${_configs})
endif()
# Are we building with static or dynamic linking?
option(BUILD_SHARED_LIBS
@ -134,7 +143,7 @@ identified by PRC_ENCRYPTED_PATTERNS.")
# that case, config will execute the file if it appears to be
# executable; otherwise, it will simply read it.
set(PRC_EXECUTABLE_PATTERNS "" CACHE STRING
set(PRC_EXECUTABLE_PATTERNS "" CACHE STRING
"The filename(s) to search for, and execute, in the above paths.
Normally this is empty.")
@ -193,10 +202,9 @@ set(PRC_INC_TRUST_LEVEL "0" CACHE STRING
# Similarly, the descriptions are normally saved only in a
# development build, not in a release build. Set this value true to
# explicitly save them anyway.
#XXX only for release-release builds
option(PRC_SAVE_DESCRIPTIONS
per_config_option(PRC_SAVE_DESCRIPTIONS
"Define if you want to save the descriptions for ConfigVariables."
ON)
Debug Standard)
mark_as_advanced(DEFAULT_PRC_DIR PRC_DIR_ENVVARS PRC_PATH_ENVVARS
PRC_PATTERNS PRC_ENCRYPTED_PATTERNS PRC_ENCRYPTION_KEY
@ -243,49 +251,46 @@ debugging information." OFF)
mark_as_advanced(INTERROGATE_OPTIONS)
#
# The following options have to do with the memory allocation system
# that will be used by Panda3D.
# The following options have to do with optional debugging features.
#
option(DO_MEMORY_USAGE
per_config_option(DO_MEMORY_USAGE
"Do you want to compile in support for tracking memory usage? This
enables you to define the variable 'track-memory-usage' at runtime
to help track memory leaks, and also report total memory usage on
PStats. There is some small overhead for having this ability
available, even if it is unused." OFF)
list(APPEND PER_CONFIG_OPTIONS DO_MEMORY_USAGE)
set(DO_MEMORY_USAGE_Debug ON CACHE BOOL "")
available, even if it is unused." Debug Standard)
option(SIMULATE_NETWORK_DELAY
per_config_option(DO_COLLISION_RECORDING
"Do you want to enable debugging features for the collision system?"
Debug Standard)
per_config_option(DO_PSTATS
"Enable support for performance profiling using PStats?"
Debug Standard)
per_config_option(DO_DCAST
"Add safe typecast checking? This adds significant overhead."
Debug Standard)
per_config_option(SIMULATE_NETWORK_DELAY
"This option compiles in support for simulating network delay via
the min-lag and max-lag prc variables. It adds a tiny bit of
overhead even when it is not activated, so it is typically enabled
only in a development build." OFF)
list(APPEND PER_CONFIG_OPTIONS SIMULATE_NETWORK_DELAY)
set(SIMULATE_NETWORK_DELAY_Debug ON CACHE BOOL "")
only in a development build."
Debug)
option(SUPPORT_IMMEDIATE_MODE
"This option compiles in support for immediate-mode OpenGL
rendering. Since this is normally useful only for researching
buggy drivers, and since there is a tiny bit of per-primitive
overhead to have this option available even if it is unused, it is
by default enabled only in a development build. This has no effect
on DirectX rendering." OFF)
list(APPEND PER_CONFIG_OPTIONS SUPPORT_IMMEDIATE_MODE)
set(SUPPORT_IMMEDIATE_MODE_Debug ON CACHE BOOL "")
option(NOTIFY_DEBUG
per_config_option(NOTIFY_DEBUG
"Do you want to include the 'debug' and 'spam' Notify messages?
Normally, these are stripped out when we build for release, but sometimes it's
useful to keep them around. Turn this setting on to achieve that." OFF)
list(APPEND PER_CONFIG_OPTIONS NOTIFY_DEBUG)
set(NOTIFY_DEBUG_Debug ON CACHE BOOL "")
set(NOTIFY_DEBUG_Standard ON CACHE BOOL "")
useful to keep them around. Turn this setting on to achieve that."
Debug Standard)
option(SUPPORT_FIXED_FUNCTION
"This option compiles in support for the fixed-function OpenGL
pipeline. It is only really useful to turn this off if you are targeting
an OpenGL ES 2 system." ON)
mark_as_advanced(SIMULATE_NETWORK_DELAY DO_MEMORY_USAGE DO_DCAST)
#
# The following options have to do with the memory allocation system.
#
option(USE_MEMORY_DLMALLOC
"This is an optional alternative memory-allocation scheme
@ -313,8 +318,7 @@ calls to malloc() and free() for frequently-created and -deleted
objects. There's usually no reason to set this false, unless you
suspect a bug in Panda's memory management code." ON)
mark_as_advanced(DO_MEMORY_USAGE SIMULATE_NETWORK_DELAY
SUPPORT_IMMEDIATE_MODE USE_MEMORY_DLMALLOC USE_MEMORY_PTMALLOC2
mark_as_advanced(USE_MEMORY_DLMALLOC USE_MEMORY_PTMALLOC2
MEMORY_HOOK_DO_ALIGN USE_DELETED_CHAIN)
@ -368,11 +372,11 @@ mark_as_advanced(ANDROID_NDK_HOME ANDROID_ABI ANDROID_STL
# By default, we'll assume the user only wants to run with Debug
# python if he has to--that is, on Windows when building a debug build.
set(USE_DEBUG_PYTHON OFF)
if(WIN32)
set(USE_DEBUG_PYTHON_Debug ON)
per_config_option(USE_DEBUG_PYTHON "" Debug)
else()
option(USE_DEBUG_PYTHON "" OFF)
endif()
list(APPEND PER_CONFIG_OPTIONS USE_DEBUG_PYTHON)
cmake_dependent_option(HAVE_VIDEO4LINUX
"Set this to enable webcam support on Linux." ON
@ -394,15 +398,27 @@ version and below, which may reduce runtime portability to other
systems, but it will avoid issues with getting extension function
pointers.")
option(SUPPORT_FIXED_FUNCTION
"This option compiles in support for the fixed-function OpenGL pipeline.
It is only really useful to turn this off to save space if you are building
an application that only needs to use an OpenGL 3.2+ context and only uses
custom GLSL shaders." ON)
option(SUPPORT_IMMEDIATE_MODE
"This option compiles in support for immediate-mode OpenGL
rendering. Since this is normally useful only for researching
buggy drivers, and since there is a tiny bit of per-primitive
overhead to have this option available even if it is unused, it is
by default enabled only in a development build. This has no effect
on DirectX rendering." OFF)
mark_as_advanced(SUPPORT_FIXED_FUNCTION)
# Should build tinydisplay?
#option(HAVE_TINYDISPLAY
# "Builds TinyDisplay, a light software renderer based on TinyGL,
#that is built into Panda. TinyDisplay is not as full-featured as Mesa
#but is many times faster." ON)
#option(HAVE_TINYDISPLAY_MinSizeRel "" OFF)
#list(APPEND PER_CONFIG_OPTIONS HAVE_TINYDISPLAY)
# Is SDL installed, and where?
set(Threads_FIND_QUIETLY TRUE) # Fix for builtin FindSDL
@ -466,9 +482,6 @@ build (such as, for instance, for the iPhone)." ON)
option(HAVE_AUDIO
"Do you want to build the audio interface?" ON)
option(DO_PSTATS
"Enable the pstats client?" ON)
option(USE_PANDAFILESTREAM
"Enable the PandaFileStream implementation of pfstream etc.?" ON)
@ -481,16 +494,12 @@ option(HAVE_IMG "Enable support for loading IMG images." ON)
option(HAVE_SOFTIMAGE_PIC "Enable support for loading SOFTIMAGE PIC images." ON)
option(HAVE_BMP "Enable support for loading BMP images." ON)
option(HAVE_PNM "Enable support for loading PNM images." ON)
foreach(adv_image_format
HAVE_SGI_RGB HAVE_TGA HAVE_IMG HAVE_SOFTIMAGE_PIC HAVE_BMP HAVE_PNM)
option(${adv_image_format}_MinSizeRel "" OFF)
list(APPEND PER_CONFIG_OPTIONS ${adv_image_format})
mark_as_advanced(${adv_image_format} ${adv_image_format}_MinSizeRel)
endforeach(adv_image_format)
option(HAVE_SGI_RGB "" ON)
option(HAVE_TGA "" ON)
option(HAVE_IMG "" ON)
option(HAVE_SOFTIMAGE_PIC "" ON)
option(HAVE_BMP "" ON)
option(HAVE_PNM "" ON)
# How to invoke bison and flex. Panda takes advantage of some
# bison/flex features, and therefore specifically requires bison and
@ -528,9 +537,9 @@ slightly slow down Panda for the single CPU case."
IMPORTED_AS Threads::Threads)
# Configure debug threads
option(DEBUG_THREADS "If on, enables debugging of thread and sync operations (i.e. mutexes, deadlocks)" OFF)
list(APPEND PER_CONFIG_OPTIONS DEBUG_THREADS)
set(DEBUG_THREADS_Debug ON CACHE BOOL "")
option(DEBUG_THREADS
"If on, enables debugging of thread and sync operations (i.e. mutexes,
deadlocks). Very slow, disabled by default." OFF)
option(SIMPLE_THREADS
"If on, compile with simulated threads. Threads, by default, use
@ -540,7 +549,6 @@ On the other hand, compiling in this full OS-provided support can
impose some substantial runtime overhead, making the application
run slower on a single-CPU machine. This settings avoid the overhead,
but still gain some of the basic functionality of threads." OFF)
list(APPEND PER_CONFIG_OPTIONS SIMPLE_THREADS)
option(OS_SIMPLE_THREADS
"If on, OS threading constructs will be used to perform context switches.
@ -549,7 +557,6 @@ normal SIMPLE_THREADS optimizations still apply, and the normal
SIMPLE_THREADS scheduler is used to switch between threads (instead
of the OS scheduler). This may be more portable and more reliable,
but it is a hybrid between user-space threads and os-provided threads." ON)
list(APPEND PER_CONFIG_OPTIONS OS_SIMPLE_THREADS)
### Configure pipelining ###
option(DO_PIPELINING "If on, compile with pipelined rendering." ON)
@ -559,8 +566,6 @@ option(COMPILE_IN_DEFAULT_FONT
"If on, compiles in a default font, so that every TextNode will always
have a font available without requiring the user to specify one.
When turned off, the generated library will save a few kilobytes." ON)
list(APPEND PER_CONFIG_OPTIONS COMPILE_IN_DEFAULT_FONT)
set(COMPILE_IN_DEFAULT_FONT_MinSizeRel OFF CACHE BOOL "")
option(STDFLOAT_DOUBLE
"Define this true to compile a special version of Panda to use a

View File

@ -186,11 +186,14 @@ message("")
# Generate dtool_config.h
if(IS_MULTICONFIG)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
foreach(option ${PER_CONFIG_OPTIONS})
string(TOUPPER "${config}" config_upper)
foreach(option ${_PER_CONFIG_OPTIONS})
# Check for the presence of a config-specific option, and override what's
# in the cache if there is.
if(DEFINED ${option}_${config})
set(${option} ${${option}_${config}})
if(DEFINED "${option}_${config_upper}")
set(${option} ${${option}_${config_upper}})
else()
message(FATAL_ERROR "${option}_${config_upper} is not defined")
endif()
endforeach(option)
@ -199,7 +202,7 @@ if(IS_MULTICONFIG)
# unset() does not unset CACHE variables by default, just normal variables.
# By doing this we're reverting back to what was in the cache.
foreach(option ${PER_CONFIG_OPTIONS})
foreach(option ${_PER_CONFIG_OPTIONS})
unset(${option})
endforeach(option)
endforeach(config)

View File

@ -369,7 +369,7 @@ package_option(TIFF "Enable support for loading .tif images.")
package_status(TIFF "libtiff")
# OpenEXR
find_package(OpenEXR QUIET)
find_package(OpenEXR QUIET MODULE)
package_option(OpenEXR "Enable support for loading .exr images.")

View File

@ -24,37 +24,7 @@ particular license. Some packages don't have a listed license because
they are almost always required/used, or because they are only used in
plugins that can be easily removed (eg. directx, ffmpeg, fmod, ...).")
set(PANDA_PACKAGE_VERSION CACHE STRING
"This string is used to describe the Panda3D \"package\" associated
with this current build of Panda. It should increment with major
and minor version changes, but not sequence (or \"bugfix\") changes.
It should be unique for each unique distributor. The default is
the empty string, which means this build does not precisely match
any distributable Panda3D packages. If you are making a Panda3D
build which you will be using to produce a distributable Panda3D
package, you should set this string appropriately.")
set(P3D_PLUGIN_VERSION "1.0.4" CACHE STRING
"We also define a version for the Panda3D plugin/runtime,
i.e. nppanda3d.dll, p3dactivex.ocx, and panda3d.exe. This is an
independent version number from PANDA_VERSION or
PANDA_PACKAGE_VERSION, because it is anticipated that this plugin
code, once settled, will need to be updated much less frequently
than Panda itself.")
set(P3D_COREAPI_VERSION "${P3D_PLUGIN_VERSION}.1" CACHE STRING
"Finally, there's a separate version number for the Core API. At
first, we didn't believe we needed a Core API version number, but
in this belief we were naive. This version number is a little less
strict in its format requirements than P3D_PLUGIN_VERSION, above,
and it doesn't necessarily consist of a specific number of
integers, but by convention it will consist of four integers, with
the first three matching the plugin version, and the fourth integer
being incremented with each new Core API revision.")
mark_as_advanced(PANDA_VERSION PANDA_OFFICIAL_VERSION
PANDA_PACKAGE_VERSION P3D_PLUGIN_VERSION P3D_COREAPI_VERSION
PANDA_DIST_USE_LICENSES)
mark_as_advanced(PANDA_VERSION PANDA_OFFICIAL_VERSION PANDA_DIST_USE_LICENSES)
# The version gets a "c" at the end if it's not an official one.
if(PANDA_OFFICIAL_VERSION)
@ -82,22 +52,3 @@ if(GIT_EXECUTABLE)
OUTPUT_VARIABLE PANDA_GIT_COMMIT_STR
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Separate the plugin version into its three components.
string(REPLACE "." ";" P3D_PLUGIN_VERSION_LIST "${P3D_PLUGIN_VERSION}")
list(GET P3D_PLUGIN_VERSION_LIST 0 P3D_PLUGIN_MAJOR_VERSION)
list(GET P3D_PLUGIN_VERSION_LIST 1 P3D_PLUGIN_MINOR_VERSION)
list(GET P3D_PLUGIN_VERSION_LIST 2 P3D_PLUGIN_SEQUENCE_VERSION)
set(P3D_PLUGIN_VERSION_STR "${P3D_PLUGIN_VERSION}${VERSION_SUFFIX}")
# The plugin version as dot-delimited integer quad, according to MS
# conventions for DLL version numbers.
if(PANDA_OFFICIAL_VERSION)
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION}.1000")
else()
set(P3D_PLUGIN_DLL_DOT_VERSION "${P3D_PLUGIN_VERSION}.0")
endif()
# The same thing as a comma-delimited quad.
string(REPLACE "." "," P3D_PLUGIN_DLL_COMMA_VERSION "${P3D_PLUGIN_DLL_DOT_VERSION}")

View File

@ -127,9 +127,7 @@ CPPManifest(const string &macro, const string &definition) :
*/
CPPManifest::
~CPPManifest() {
if (_expr != nullptr) {
delete _expr;
}
delete _expr;
}
/**

View File

@ -85,7 +85,9 @@ public:
return ptr; \
} \
inline void operator delete(void *ptr) { \
StaticDeletedChain< Type >::deallocate((Type *)ptr, get_type_handle(Type)); \
if (ptr != nullptr) { \
StaticDeletedChain< Type >::deallocate((Type *)ptr, get_type_handle(Type)); \
} \
} \
inline void operator delete(void *, void *) { \
} \
@ -104,7 +106,9 @@ public:
return ptr; \
} \
inline void operator delete(void *ptr) { \
_deleted_chain.deallocate((Type *)ptr, get_type_handle(Type)); \
if (ptr != nullptr) { \
_deleted_chain.deallocate((Type *)ptr, get_type_handle(Type)); \
} \
} \
inline void operator delete(void *, void *) { \
} \

View File

@ -32,7 +32,9 @@
return ptr; \
} \
inline void operator delete(void *ptr) { \
PANDA_FREE_SINGLE(ptr); \
if (ptr != nullptr) { \
PANDA_FREE_SINGLE(ptr); \
} \
} \
inline void operator delete(void *, void *) { \
} \
@ -44,7 +46,9 @@
return ptr; \
} \
inline void operator delete[](void *ptr) { \
PANDA_FREE_ARRAY(ptr); \
if (ptr != nullptr) { \
PANDA_FREE_ARRAY(ptr); \
} \
} \
inline void operator delete[](void *, void *) { \
}

View File

@ -61,13 +61,3 @@
/* This is a string indicating who has provided this distribution. */
#define PANDA_DISTRIBUTOR "@PANDA_DISTRIBUTOR@"
/* The string indicating the version number of the associated Panda3D
distributable package, or empty string if there is no associated
package. */
#define PANDA_PACKAGE_VERSION_STR "@PANDA_PACKAGE_VERSION@"
/* The string indicating the URL from which the associated Panda3D
distributable package may be downloaded, or empty string if there
is no associated package. */
#define PANDA_PACKAGE_HOST_URL "@PANDA_PACKAGE_HOST_URL@"

View File

@ -805,21 +805,25 @@ read_args() {
#elif defined(IS_FREEBSD)
// In FreeBSD, we can use sysctl to determine the command-line arguments.
size_t bufsize = 4096;
char buffer[4096];
size_t bufsize = 0;
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ARGS, 0};
mib[3] = getpid();
if (sysctl(mib, 4, (void*) buffer, &bufsize, nullptr, 0) == -1) {
if (sysctl(mib, 4, nullptr, &bufsize, nullptr, 0) == -1) {
perror("sysctl");
} else {
if (_binary_name.empty()) {
_binary_name = buffer;
}
size_t idx = strlen(buffer) + 1;
while (idx < bufsize) {
_args.push_back((char*)(buffer + idx));
size_t newidx = strlen(buffer + idx);
idx += newidx + 1;
char *buffer = (char *)alloca(bufsize);
if (sysctl(mib, 4, buffer, &bufsize, nullptr, 0) == -1) {
perror("sysctl");
} else {
if (_binary_name.empty()) {
_binary_name = buffer;
}
size_t idx = strlen(buffer) + 1;
while (idx < bufsize) {
_args.push_back((char*)(buffer + idx));
size_t newidx = strlen(buffer + idx);
idx += newidx + 1;
}
}
}

View File

@ -34,18 +34,9 @@ __init__(PyObject *path) {
if (PyUnicode_CheckExact(path)) {
wchar_t *data;
#if PY_VERSION_HEX >= 0x03020000
data = PyUnicode_AsWideCharString(path, &length);
#else
length = PyUnicode_GET_SIZE(path);
data = (wchar_t *)alloca(sizeof(wchar_t) * (length + 1));
PyUnicode_AsWideChar((PyUnicodeObject *)path, data, length);
#endif
(*_this) = wstring(data, length);
#if PY_VERSION_HEX >= 0x03020000
PyMem_Free(data);
#endif
return;
}
@ -81,13 +72,7 @@ __init__(PyObject *path) {
if (PyObject_HasAttrString(path, "_format_parsed_parts")) {
path_str = PyObject_Str(path);
} else {
#if PY_VERSION_HEX >= 0x03040000
PyErr_Format(PyExc_TypeError, "expected str, bytes, Path or Filename object, not %s", Py_TYPE(path)->tp_name);
#elif PY_MAJOR_VERSION >= 3
PyErr_Format(PyExc_TypeError, "expected str, bytes or Filename object, not %s", Py_TYPE(path)->tp_name);
#else
PyErr_Format(PyExc_TypeError, "expected str or unicode object, not %s", Py_TYPE(path)->tp_name);
#endif
return;
}
#endif
@ -98,18 +83,9 @@ __init__(PyObject *path) {
if (PyUnicode_CheckExact(path_str)) {
wchar_t *data;
#if PY_VERSION_HEX >= 0x03020000
data = PyUnicode_AsWideCharString(path_str, &length);
#else
length = PyUnicode_GET_SIZE(path_str);
data = (wchar_t *)alloca(sizeof(wchar_t) * (length + 1));
PyUnicode_AsWideChar((PyUnicodeObject *)path_str, data, length);
#endif
(*_this) = Filename::from_os_specific_w(wstring(data, length));
#if PY_VERSION_HEX >= 0x03020000
PyMem_Free(data);
#endif
} else if (PyBytes_CheckExact(path_str)) {
char *data;
@ -117,11 +93,7 @@ __init__(PyObject *path) {
(*_this) = Filename::from_os_specific(string(data, length));
} else {
#if PY_MAJOR_VERSION >= 3
PyErr_Format(PyExc_TypeError, "expected str or bytes object, not %s", Py_TYPE(path_str)->tp_name);
#else
PyErr_Format(PyExc_TypeError, "expected str or unicode object, not %s", Py_TYPE(path_str)->tp_name);
#endif
}
Py_DECREF(path_str);
}
@ -150,25 +122,10 @@ __reduce__(PyObject *self) const {
*/
PyObject *Extension<Filename>::
__repr__() const {
#if PY_MAJOR_VERSION >= 3
// Python 3 case: return a unicode object.
wstring filename = _this->get_fullpath_w();
PyObject *str = PyUnicode_FromWideChar(filename.data(), (Py_ssize_t)filename.size());
#if PY_VERSION_HEX >= 0x03040000
PyObject *result = PyUnicode_FromFormat("Filename(%R)", str);
#else
static PyObject *format = PyUnicode_FromString("Filename(%r)");
PyObject *result = PyUnicode_Format(format, str);
#endif
#else
// Python 2 case: return a regular string.
string filename = _this->get_fullpath();
PyObject *str = PyString_FromStringAndSize(filename.data(), (Py_ssize_t)filename.size());
static PyObject *format = PyString_FromString("Filename(%r)");
PyObject *result = PyString_Format(format, str);
#endif
Py_DECREF(str);
return result;
@ -199,12 +156,8 @@ scan_directory() const {
PyObject *result = PyList_New(contents.size());
for (size_t i = 0; i < contents.size(); ++i) {
const string &filename = contents[i];
#if PY_MAJOR_VERSION >= 3
// This function expects UTF-8.
PyObject *str = PyUnicode_FromStringAndSize(filename.data(), filename.size());
#else
PyObject *str = PyString_FromStringAndSize(filename.data(), filename.size());
#endif
PyList_SET_ITEM(result, i, str);
}

View File

@ -49,11 +49,7 @@ read(Py_ssize_t size) {
#endif
}
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize(buffer, read_bytes);
#else
return PyString_FromStringAndSize(buffer, read_bytes);
#endif
}
/**
@ -92,11 +88,7 @@ read1(Py_ssize_t size) {
Py_BLOCK_THREADS
#endif
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize(buffer, read_bytes);
#else
return PyString_FromStringAndSize(buffer, read_bytes);
#endif
}
/**
@ -128,11 +120,7 @@ readall() {
Py_BLOCK_THREADS
#endif
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)result.data(), result.size());
#else
return PyString_FromStringAndSize((char *)result.data(), result.size());
#endif
}
/**
@ -195,11 +183,7 @@ readline(Py_ssize_t size) {
Py_BLOCK_THREADS
#endif
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize(line.data(), line.size());
#else
return PyString_FromStringAndSize(line.data(), line.size());
#endif
}
/**

View File

@ -31,11 +31,6 @@ PandaSystem() :
{
_system_names_dirty = false;
// These are settable via Config.prc, but only in development (!NDEBUG)
// mode, and only if they are not already defined.
_package_version_string = "";
_package_host_url = "";
#ifdef STDFLOAT_DOUBLE
add_system("stdfloat-double");
#endif
@ -86,75 +81,6 @@ get_version_string() {
return PANDA_VERSION_STR;
}
/**
* Returns the version of the Panda3D distributable package that provides this
* build of Panda.
*
* When the currently-executing version of Panda was loaded from a
* distributable package, such as via the browser plugin, then this string
* will be nonempty and will contain the corresponding version string. You
* can build applications that use this particular version of Panda by
* requesting it in the pdef file, using "panda3d", this version string, and
* the download host provided by get_package_host_url().
*
* If this string is empty, then the currently-executing Panda was built
* independently, and is not part of a distributable package.
*
* @deprecated Runtime/plugin environment has been removed, this now always
* returns an empty string.
*/
string PandaSystem::
get_package_version_string() {
#ifdef NDEBUG
return "";
#else
return get_global_ptr()->_package_version_string;
#endif
}
/**
* Returns the URL of the download server that provides the Panda3D
* distributable package currently running. This can be used, along with the
* get_package_version_string(), to uniquely identify the running version of
* Panda among distributable Panda versions.
*
* See get_package_version_string() for more information.
*
* This string is set explicitly at compilation time. Normally, it should be
* set to a nonempty string only when building a Panda3D package for
* distribution.
*
* @deprecated Runtime/plugin environment has been removed, this now always
* returns an empty string.
*/
string PandaSystem::
get_package_host_url() {
#ifdef NDEBUG
return "";
#else
return get_global_ptr()->_package_host_url;
#endif
}
/**
* Returns the current version of Panda's Core API, expressed as a string of
* dot-delimited integers. There are usually four integers in this version,
* but this is not guaranteed.
*
* The Core API is used during the runtime (plugin) environment only. This
* may be the empty string if the current version of Panda is not built to
* provide a particular Core API, which will be the normal case in a
* development SDK. However, you should not use this method to determine
* whether you are running in a runtime environment or not.
*
* @deprecated Runtime/plugin environment has been removed, this now always
* returns an empty string.
*/
string PandaSystem::
get_p3d_coreapi_version_string() {
return "";
}
/**
* Returns the major version number of the current version of Panda. This is
* the first number of the dotted triple returned by get_version_string(). It
@ -465,33 +391,3 @@ reset_system_names() {
_system_names_dirty = false;
}
/**
* Loads the value returned by get_package_version_string(). This is intended
* to be called by ConfigPageManager to preload the value from the panda-
* package-version config variable, for developer's convenience. This has no
* effect if the PANDA_PACKAGE_VERSION_STR configure variable is defined at
* compilation time. This also has no effect in NDEBUG mode.
*/
void PandaSystem::
set_package_version_string(const string &package_version_string) {
_package_version_string = "";
if (_package_version_string.empty()) {
_package_version_string = package_version_string;
}
}
/**
* Loads the value returned by get_package_host_url(). This is intended to be
* called by ConfigPageManager to preload the value from the panda-package-
* host-url config variable, for developer's convenience. This has no effect
* if the PANDA_PACKAGE_HOST_URL configure variable is defined at compilation
* time. This also has no effect in NDEBUG mode.
*/
void PandaSystem::
set_package_host_url(const string &package_host_url) {
_package_host_url = "";
if (_package_host_url.empty()) {
_package_host_url = package_host_url;
}
}

View File

@ -30,9 +30,6 @@ protected:
PUBLISHED:
static std::string get_version_string();
static std::string get_package_version_string();
static std::string get_package_host_url();
static std::string get_p3d_coreapi_version_string();
static int get_major_version();
static int get_minor_version();
@ -85,9 +82,6 @@ PUBLISHED:
private:
void reset_system_names();
void set_package_version_string(const std::string &package_version_string);
void set_package_host_url(const std::string &package_host_url);
typedef pmap<std::string, std::string> SystemTags;
typedef pmap<std::string, SystemTags> Systems;
typedef pvector<std::string> SystemNames;
@ -96,9 +90,6 @@ private:
SystemNames _system_names;
bool _system_names_dirty;
std::string _package_version_string;
std::string _package_host_url;
static PandaSystem *_global_ptr;
public:

View File

@ -22,26 +22,11 @@
void Extension<TextEncoder>::
set_text(PyObject *text) {
if (PyUnicode_Check(text)) {
#if PY_VERSION_HEX >= 0x03030000
Py_ssize_t len;
const char *str = PyUnicode_AsUTF8AndSize(text, &len);
_this->set_text(std::string(str, len), TextEncoder::E_utf8);
#else
Py_ssize_t len = PyUnicode_GET_SIZE(text);
wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1));
PyUnicode_AsWideChar((PyUnicodeObject *)text, str, len);
_this->set_wtext(std::wstring(str, len));
#endif
} else {
#if PY_MAJOR_VERSION >= 3
Dtool_Raise_TypeError("expected string");
#else
char *str;
Py_ssize_t len;
if (PyString_AsStringAndSize(text, (char **)&str, &len) != -1) {
_this->set_text(std::string(str, len));
}
#endif
}
}
@ -63,13 +48,8 @@ set_text(PyObject *text, TextEncoder::Encoding encoding) {
*/
PyObject *Extension<TextEncoder>::
get_text() const {
#if PY_MAJOR_VERSION >= 3
std::wstring text = _this->get_wtext();
return PyUnicode_FromWideChar(text.data(), (Py_ssize_t)text.size());
#else
std::string text = _this->get_text();
return PyString_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size());
#endif
}
/**
@ -78,11 +58,7 @@ get_text() const {
PyObject *Extension<TextEncoder>::
get_text(TextEncoder::Encoding encoding) const {
std::string text = _this->get_text(encoding);
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size());
#else
return PyString_FromStringAndSize((char *)text.data(), (Py_ssize_t)text.size());
#endif
}
/**
@ -91,7 +67,6 @@ get_text(TextEncoder::Encoding encoding) const {
void Extension<TextEncoder>::
append_text(PyObject *text) {
if (PyUnicode_Check(text)) {
#if PY_VERSION_HEX >= 0x03030000
Py_ssize_t len;
const char *str = PyUnicode_AsUTF8AndSize(text, &len);
std::string text_str(str, len);
@ -100,22 +75,8 @@ append_text(PyObject *text) {
} else {
_this->append_wtext(TextEncoder::decode_text(text_str, TextEncoder::E_utf8));
}
#else
Py_ssize_t len = PyUnicode_GET_SIZE(text);
wchar_t *str = (wchar_t *)alloca(sizeof(wchar_t) * (len + 1));
PyUnicode_AsWideChar((PyUnicodeObject *)text, str, len);
_this->append_wtext(std::wstring(str, len));
#endif
} else {
#if PY_MAJOR_VERSION >= 3
Dtool_Raise_TypeError("expected string");
#else
char *str;
Py_ssize_t len;
if (PyString_AsStringAndSize(text, (char **)&str, &len) != -1) {
_this->append_text(std::string(str, len));
}
#endif
}
}
@ -125,11 +86,7 @@ append_text(PyObject *text) {
PyObject *Extension<TextEncoder>::
encode_wchar(char32_t ch, TextEncoder::Encoding encoding) {
std::string value = TextEncoder::encode_wchar(ch, encoding);
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#else
return PyString_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#endif
}
/**
@ -139,11 +96,7 @@ encode_wchar(char32_t ch, TextEncoder::Encoding encoding) {
PyObject *Extension<TextEncoder>::
encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) {
std::string value = TextEncoder::encode_wtext(wtext, encoding);
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#else
return PyString_FromStringAndSize((char *)value.data(), (Py_ssize_t)value.size());
#endif
}
/**

View File

@ -722,27 +722,6 @@ void ConfigPageManager::
config_initialized() {
Notify::config_initialized();
#ifndef NDEBUG
ConfigVariableString panda_package_version
("panda-package-version", "local_dev",
PRC_DESC("This can be used to specify the value returned by "
"PandaSystem::get_package_version_str(), in development mode only, "
"and only if another value has not already been compiled in. This "
"is intended for developer convenience, to masquerade a development "
"build of Panda as a different runtime version. Use with caution."));
ConfigVariableString panda_package_host_url
("panda-package-host-url", "",
PRC_DESC("This can be used to specify the value returned by "
"PandaSystem::get_package_host_url(), in development mode only, "
"and only if another value has not already been compiled in. This "
"is intended for developer convenience, to masquerade a development "
"build of Panda as a different runtime version. Use with caution."));
PandaSystem *panda_sys = PandaSystem::get_global_ptr();
panda_sys->set_package_version_string(panda_package_version);
panda_sys->set_package_host_url(panda_package_host_url);
#endif // NDEBUG
// Also set up some other low-level things.
ConfigVariableEnum<TextEncoder::Encoding> text_encoding
("text-encoding", TextEncoder::E_utf8,

View File

@ -60,11 +60,7 @@ readline() {
ch = in->get();
}
#if PY_MAJOR_VERSION >= 3
return PyBytes_FromStringAndSize(line.data(), line.size());
#else
return PyString_FromStringAndSize(line.data(), line.size());
#endif
}
/**
@ -80,11 +76,7 @@ readlines() {
PyObject *py_line = readline();
#if PY_MAJOR_VERSION >= 3
while (PyBytes_GET_SIZE(py_line) > 0) {
#else
while (PyString_GET_SIZE(py_line) > 0) {
#endif
PyList_Append(lst, py_line);
Py_DECREF(py_line);

View File

@ -16,9 +16,6 @@
*/
INLINE StreamWriter::
StreamWriter(std::ostream &out) :
#ifdef HAVE_PYTHON
softspace(0),
#endif
_out(&out),
_owns_stream(false)
{
@ -29,9 +26,6 @@ StreamWriter(std::ostream &out) :
*/
INLINE StreamWriter::
StreamWriter(std::ostream *out, bool owns_stream) :
#ifdef HAVE_PYTHON
softspace(0),
#endif
_out(out),
_owns_stream(owns_stream)
{
@ -42,9 +36,6 @@ StreamWriter(std::ostream *out, bool owns_stream) :
*/
INLINE StreamWriter::
StreamWriter(const StreamWriter &copy) :
#ifdef HAVE_PYTHON
softspace(0),
#endif
_out(copy._out),
_owns_stream(false)
{
@ -55,9 +46,6 @@ StreamWriter(const StreamWriter &copy) :
*/
INLINE StreamWriter::
StreamWriter(StreamWriter &&from) noexcept :
#ifdef HAVE_PYTHON
softspace(0),
#endif
_out(from._out),
_owns_stream(from._owns_stream)
{

View File

@ -83,12 +83,6 @@ public:
private:
std::ostream *_out;
bool _owns_stream;
#ifdef HAVE_PYTHON
PUBLISHED:
// Python 2 needs this for printing to work correctly.
int softspace;
#endif
};
#include "streamWriter.I"

View File

@ -14,7 +14,7 @@
;
; BUILT - location of panda install tree.
; SOURCE - location of the panda source-tree if available, OR location of panda install tree.
; INCLUDE_PYVER - version of Python that Panda was built with (eg. "2.7", "3.5-32")
; INCLUDE_PYVER - version of Python that Panda was built with (eg. "3.8", "3.7-32")
; REGVIEW - either 32 or 64, depending on the build architecture.
;
@ -367,7 +367,6 @@ SectionGroup "Python modules" SecGroupPython
File /r "${BUILT}\panda3d\*.py"
SectionEnd
!insertmacro PyBindingSection 2.7 .pyd
!if "${REGVIEW}" == "32"
!insertmacro PyBindingSection 3.5-32 .cp35-win32.pyd
!insertmacro PyBindingSection 3.6-32 .cp36-win32.pyd
@ -479,7 +478,6 @@ Function .onInit
SetRegView ${REGVIEW}
!endif
; We never check for 2.7; it is always disabled in Auto mode
!if "${REGVIEW}" == "32"
!insertmacro MaybeEnablePyBindingSection 3.5-32
!insertmacro MaybeEnablePyBindingSection 3.6-32
@ -872,7 +870,6 @@ SectionEnd
!insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
!insertmacro MUI_DESCRIPTION_TEXT ${SecGroupPython} $(DESC_SecGroupPython)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPyShared} $(DESC_SecPyShared)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings2.7} $(DESC_SecPyBindings2.7)
!if "${REGVIEW}" == "32"
!insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.5-32} $(DESC_SecPyBindings3.5-32)
!insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.6-32} $(DESC_SecPyBindings3.6-32)

View File

@ -209,8 +209,7 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1,
python_versions=[], **kwargs):
outputdir = GetOutputDir()
# We pack Python 2 and Python 3, if we built with support for it.
python2_ver = None
# We pack the default Python 3 version that ships with Ubuntu.
python3_ver = None
install_python_versions = []
@ -218,12 +217,9 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1,
oscmd('python3 -V > "%s/tmp/python3_version.txt"' % (outputdir))
sys_python3_ver = '.'.join(ReadFile(outputdir + "/tmp/python3_version.txt").strip().split(' ')[1].split('.')[:2])
# Check that we built with support for these.
# Check that we built with support for it.
for version_info in python_versions:
if version_info["version"] == "2.7":
python2_ver = "2.7"
install_python_versions.append(version_info)
elif version_info["version"] == sys_python3_ver:
if version_info["version"] == sys_python3_ver:
python3_ver = sys_python3_ver
install_python_versions.append(version_info)
@ -301,18 +297,9 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1,
recommends = ReadFile("targetroot/debian/substvars_rec").replace("shlibs:Depends=", "").strip()
provides = "panda3d"
if python2_ver or python3_ver:
recommends += ", python-pmw"
if python2_ver:
depends += ", python%s" % (python2_ver)
recommends += ", python-wxversion"
recommends += ", python-tk (>= %s)" % (python2_ver)
provides += ", python2-panda3d"
if python3_ver:
depends += ", python%s" % (python3_ver)
recommends += ", python3-tk (>= %s)" % (python3_ver)
recommends += ", python-pmw, python3-tk (>= %s)" % (python3_ver)
provides += ", python3-panda3d"
if not PkgSkip("NVIDIACG"):
@ -654,11 +641,7 @@ def MakeInstallerOSX(version, python_versions=[], installdir=None, **kwargs):
for version_info in python_versions:
pyver = version_info["version"]
if pyver in ("2.7", "3.4"):
# Don't install these EOL versions of Python by default.
cond = "false"
else:
cond = "isPythonVersionInstalled('%s')" % (pyver)
cond = "isPythonVersionInstalled('%s')" % (pyver)
dist.write(' <choice id="pybindings%s" start_selected="%s" title="Python %s Bindings" tooltip="Python bindings for the Panda3D libraries" description="Support for Python %s.">\n' % (pyver, cond, pyver, pyver))
dist.write(' <pkg-ref id="org.panda3d.panda3d.pybindings%s.pkg"/>\n' % (pyver))
dist.write(' </choice>\n')

View File

@ -7,14 +7,16 @@
# panda3d.
#
########################################################################
import sys
if sys.version_info < (3, 5):
print("This version of Python is not supported, use version 3.5 or higher.")
exit(1)
try:
import sys, os, platform, time, stat, re, getopt, threading, signal, shutil
if sys.platform == "darwin" or sys.version_info >= (2, 6):
import plistlib
if sys.version_info >= (3, 0):
import queue
else:
import Queue as queue
import os, platform, time, stat, re, getopt, threading, signal, shutil
import plistlib
import queue
except KeyboardInterrupt:
raise
except:
@ -484,15 +486,13 @@ SdkAutoDisableMax()
SdkAutoDisableSpeedTree()
if not PkgSkip("PYTHON") and SDK["PYTHONVERSION"] == "python2.7":
warn_prefix = "%sWARNING:%s " % (GetColor("red"), GetColor())
print("==========================================================================")
print(warn_prefix + "Python 2.7 has reached EOL as of January 1, 2020 and is no longer")
print(warn_prefix + "maintained. Panda3D will soon cease to work with this version.")
print(warn_prefix + "Please upgrade to Python 3 now.")
print("==========================================================================")
pref = "%sERROR:%s " % (GetColor("red"), GetColor())
print("========================================================================")
print(pref + "Python 2.7 has reached EOL as of January 1, 2020 and is no longer")
print(pref + "supported. Please upgrade to Python 3.5 or later.")
print("========================================================================")
sys.stdout.flush()
# Give the user some time to contemplate their sins
time.sleep(6.0)
sys.exit(1)
########################################################################
##
@ -1969,8 +1969,7 @@ def FreezePy(target, inputs, opts):
assert len(inputs) > 0
cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"].replace('\\', '/')) + " "
if sys.version_info >= (2, 6):
cmdstr += "-B "
cmdstr += "-B "
cmdstr += os.path.join(GetOutputDir(), "direct", "dist", "pfreeze.py")
@ -2584,12 +2583,8 @@ 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 has reached EOL as of January 1, 2020.\\n")
sys.stderr.write("To suppress this warning, upgrade to Python 3.\\n")
sys.stderr.flush()
del sys
if 1 / 2 == 0:
raise ImportError("Python 2 is not supported.")
""" % (WHLVERSION)
if GetTarget() == 'windows':
@ -6034,9 +6029,7 @@ finally:
# Run the test suite.
if RUNTESTS:
cmdstr = BracketNameWithQuotes(SDK["PYTHONEXEC"].replace('\\', '/'))
if sys.version_info >= (2, 6):
cmdstr += " -B"
cmdstr += " -m pytest tests"
cmdstr += " -B -m pytest tests"
if GetVerbose():
cmdstr += " --verbose"
oscmd(cmdstr)

View File

@ -8,15 +8,9 @@
import sys,os,time,stat,string,re,getopt,fnmatch,threading,signal,shutil,platform,glob,getpass,signal
import subprocess
from distutils import sysconfig
if sys.version_info >= (3, 0):
import pickle
import _thread as thread
import configparser
else:
import cPickle as pickle
import thread
import ConfigParser as configparser
import pickle
import _thread as thread
import configparser
SUFFIX_INC = [".cxx",".cpp",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
@ -49,10 +43,7 @@ if sys.platform == 'darwin':
# On OSX, platform.architecture reports '64bit' even if it is
# currently running in 32-bit mode. But sys.maxint is a reliable
# indicator.
if sys.version_info >= (3, 0):
host_64 = (sys.maxsize > 0x100000000)
else:
host_64 = (sys.maxint > 0x100000000)
host_64 = (sys.maxsize > 0x100000000)
else:
# On Windows (and Linux?) sys.maxint reports 0x7fffffff even on a
# 64-bit build. So we stick with platform.architecture in that
@ -215,10 +206,7 @@ def GetColor(color = None):
else:
token = curses.tparm(curses.tigetstr("sgr0"))
if sys.version_info >= (3, 0):
return token.decode('ascii')
else:
return token
return token.decode('ascii')
def ColorText(color, text, reset=True):
if reset is True:
@ -1000,10 +988,7 @@ def JavaCalcDependencies(srcfile, clspath):
if sys.platform == "win32":
# Note: not supported on cygwin.
if sys.version_info >= (3, 0):
import winreg
else:
import _winreg as winreg
import winreg
def TryRegistryKey(path):
try:
@ -1148,10 +1133,7 @@ def WriteFile(wfile, data, newline=None):
data = data.replace('\n', newline)
try:
if sys.version_info >= (3, 0):
dsthandle = open(wfile, "w", newline='')
else:
dsthandle = open(wfile, "w")
dsthandle = open(wfile, "w", newline='')
dsthandle.write(data)
dsthandle.close()
except:
@ -2057,10 +2039,7 @@ def SdkLocatePython(prefer_thirdparty_python=False):
if GetTarget() == 'windows':
sdkdir = GetThirdpartyBase() + "/win-python"
if sys.version_info >= (3, 0):
# Python 3 build...
sdkdir += "%d.%d" % sys.version_info[:2]
sdkdir += "%d.%d" % sys.version_info[:2]
if GetOptimize() <= 2:
sdkdir += "-dbg"
@ -3239,15 +3218,8 @@ def SetOrigExt(x, v):
ORIG_EXT[x] = v
def GetExtensionSuffix():
if sys.version_info >= (3, 0):
import _imp
return _imp.extension_suffixes()[0]
target = GetTarget()
if target == 'windows':
return '.pyd'
else:
return '.so'
import _imp
return _imp.extension_suffixes()[0]
def GetPythonABI():
soabi = sysconfig.get_config_var('SOABI')
@ -3267,11 +3239,6 @@ def GetPythonABI():
if malloc_flag is None or malloc_flag:
soabi += 'm'
if sys.version_info < (3, 3):
usize = sysconfig.get_config_var('Py_UNICODE_SIZE')
if (usize is None and sys.maxunicode == 0x10ffff) or usize == 4:
soabi += 'u'
return soabi
def CalcLocation(fn, ipath):
@ -3406,12 +3373,14 @@ def UpdatePythonVersionInfoFile(new_info):
json_data = []
# Prune the list by removing the entries that conflict with our build,
# plus the entries that no longer exist
# plus the entries that no longer exist, and the EOL Python versions
for version_info in json_data[:]:
core_pyd = os.path.join(GetOutputDir(), "panda3d", "core" + version_info["ext_suffix"])
if version_info["ext_suffix"] == new_info["ext_suffix"] or \
version_info["soabi"] == new_info["soabi"] or \
not os.path.isfile(core_pyd):
not os.path.isfile(core_pyd) or \
version_info["version"].split(".", 1)[0] == "2" or \
version_info["version"] in ("3.0", "3.1", "3.2", "3.3", "3.4"):
json_data.remove(version_info)
if not PkgSkip("PYTHON"):
@ -3428,10 +3397,17 @@ def ReadPythonVersionInfoFile():
json_file = os.path.join(GetOutputDir(), "tmp", "python_versions.json")
if os.path.isfile(json_file):
try:
return json.load(open(json_file, 'r'))
json_data = json.load(open(json_file, 'r'))
except:
pass
# Don't include unsupported versions of Python.
for version_info in json_data[:]:
if version_info["version"] in ("2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"):
json_data.remove(version_info)
return json_data
return []

View File

@ -20,12 +20,11 @@ from base64 import urlsafe_b64encode
def get_abi_tag():
if sys.version_info >= (3, 0):
soabi = get_config_var('SOABI')
if soabi and soabi.startswith('cpython-'):
return 'cp' + soabi.split('-')[1]
elif soabi:
return soabi.replace('.', '_').replace('-', '_')
soabi = get_config_var('SOABI')
if soabi and soabi.startswith('cpython-'):
return 'cp' + soabi.split('-')[1]
elif soabi:
return soabi.replace('.', '_').replace('-', '_')
soabi = 'cp%d%d' % (sys.version_info[:2])
@ -40,11 +39,6 @@ def get_abi_tag():
if malloc_flag is None or malloc_flag:
soabi += 'm'
if sys.version_info < (3, 3):
usize = get_config_var('Py_UNICODE_SIZE')
if (usize is None and sys.maxunicode == 0x10ffff) or usize == 4:
soabi += 'u'
return soabi
@ -424,6 +418,15 @@ class WheelFile(object):
continue
new_dep = os.path.join(deps_path, os.path.relpath(target_dep, os.path.dirname(target_path)))
elif '@rpath' in dep:
# Unlike makepanda, CMake uses @rpath instead of
# @loader_path. This means we can just search for the
# dependencies like normal.
dep_path = dep.replace('@rpath', '.')
target_dep = os.path.dirname(target_path) + '/' + os.path.basename(dep)
self.consider_add_dependency(target_dep, dep_path)
continue
elif dep.startswith('/Library/Frameworks/Python.framework/'):
# Add this dependency if it's in the Python directory.
target_dep = os.path.dirname(target_path) + '/' + os.path.basename(dep)
@ -528,6 +531,9 @@ def makewheel(version, output_dir, platform=None):
if not LocateBinary("patchelf"):
raise Exception("patchelf is required when building a Linux wheel.")
if sys.version_info < (3, 5):
raise Exception("Python 3.5 is required to produce a wheel.")
if platform is None:
# Determine the platform from the build.
platform_dat = os.path.join(output_dir, 'tmp', 'platform.dat')
@ -616,12 +622,8 @@ __version__ = '{0}'
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
if 1 / 2 == 0:
raise ImportError(\"Python 2 is not supported.\")
"""
whl.write_file_data('panda3d/__init__.py', p3d_init)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
import os
import re

View File

@ -118,14 +118,8 @@ if(INTERROGATE_PYTHON_INTERFACE)
__version__ = '${PROJECT_VERSION}'
if __debug__:
import sys
if sys.version_info < (3, 0):
sys.stderr.write('''\\
WARNING: Python 2.7 has reached EOL as of January 1, 2020.
To suppress this warning, upgrade to Python 3.
''')
sys.stdout.flush()
del sys
if 1 / 2 == 0:
raise ImportError(\"Python 2 is not supported.\")
${win32_init}")
@ -151,6 +145,16 @@ from .interrogatedb import *
file(WRITE "${PROJECT_BINARY_DIR}/panda3d/dtoolconfig.py" ${dtoolconfig_file})
endif()
# Also generate a panda3d.dist-info directory.
set(entry_points_file "[distutils.commands]
build_apps = direct.dist.commands:build_apps
bdist_apps = direct.dist.commands:bdist_apps
")
configure_file("${PROJECT_SOURCE_DIR}/cmake/templates/METADATA.in"
"${PROJECT_BINARY_DIR}/panda3d.dist-info/METADATA")
file(WRITE "${PROJECT_BINARY_DIR}/panda3d.dist-info/entry_points.txt" ${entry_points_file})
if(HAVE_BULLET)
add_python_module(panda3d.bullet p3bullet IMPORT panda3d.core COMPONENT BulletPython)

View File

@ -18,9 +18,7 @@
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include <Python.h>
#if PY_MAJOR_VERSION >= 3
#include <wchar.h>
#endif
#include <dlfcn.h>

View File

@ -4,10 +4,7 @@ import os
from importlib.abc import Loader, MetaPathFinder
from importlib.machinery import ModuleSpec
if sys.version_info >= (3, 5):
from importlib import _bootstrap_external
else:
from importlib import _bootstrap as _bootstrap_external
from importlib import _bootstrap_external
sys.platform = "android"

View File

@ -484,6 +484,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
}
LPoint2 p = to_2d(from_center - dist * get_normal());
LPoint2 edge_p;
PN_stdfloat edge_dist = 0.0f;
const ClipPlaneAttrib *cpa = entry.get_into_clip_planes();
@ -492,7 +493,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
Points new_points;
if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) {
// All points are behind the clip plane; just do the default test.
edge_dist = dist_to_polygon(p, _points);
edge_dist = dist_to_polygon(p, edge_p, _points);
} else if (new_points.empty()) {
// The polygon is completely clipped.
@ -500,12 +501,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
} else {
// Test against the clipped polygon.
edge_dist = dist_to_polygon(p, new_points);
edge_dist = dist_to_polygon(p, edge_p, new_points);
}
} else {
// No clip plane is in effect. Do the default test.
edge_dist = dist_to_polygon(p, _points);
edge_dist = dist_to_polygon(p, edge_p, _points);
}
// Now we have edge_dist, which is the distance from the sphere center to
@ -527,8 +528,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
max_dist = csqrt(max_dist_2);
}
if (dist > max_dist) {
// There's no intersection: the sphere is hanging off the edge.
if (dist > max_dist || -dist > max_dist) {
// There's no intersection: the sphere is hanging above or under the edge.
return nullptr;
}
@ -548,9 +549,21 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
into_depth = max_dist - orig_dist;
}
if (edge_dist >= 0.0f) {
// If colliding with an edge, we take the point on the edge.
LMatrix4 to_3d_mat;
rederive_to_3d_mat(to_3d_mat);
LPoint3 surface_point = to_3d(edge_p, to_3d_mat);
new_entry->set_surface_point(surface_point);
new_entry->set_interior_point(surface_point - normal * into_depth);
} else {
// Otherwise, we use the projection of the center onto the polygon.
new_entry->set_surface_point(from_center - normal * dist);
new_entry->set_interior_point(from_center - normal * (dist + into_depth));
}
new_entry->set_surface_normal(normal);
new_entry->set_surface_point(from_center - normal * dist);
new_entry->set_interior_point(from_center - normal * (dist + into_depth));
new_entry->set_contact_pos(contact_point);
new_entry->set_contact_normal(get_normal());
new_entry->set_t(actual_t);
@ -1330,9 +1343,12 @@ point_is_inside(const LPoint2 &p, const CollisionPolygon::Points &points) const
* Returns the linear distance from the 2-d point to the nearest part of the
* polygon defined by the points vector. The result is negative if the point
* is within the polygon.
*
* If the point is not within the polygon, the closest point to the edge is
* returned in the edge_p argument.
*/
PN_stdfloat CollisionPolygon::
dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const {
dist_to_polygon(const LPoint2 &p, LPoint2 &edge_p, const CollisionPolygon::Points &points) const {
// We know that that the polygon is convex and is defined with the points in
// counterclockwise order. Therefore, we simply compare the signed distance
@ -1344,6 +1360,7 @@ dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const
bool got_dist = false;
PN_stdfloat best_dist = -1.0f;
size_t best_i;
size_t num_points = points.size();
for (size_t i = 0; i < num_points - 1; ++i) {
@ -1353,6 +1370,7 @@ dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const
if (!got_dist || d < best_dist) {
best_dist = d;
got_dist = true;
best_i = i;
}
}
}
@ -1363,6 +1381,24 @@ dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const
if (!got_dist || d < best_dist) {
best_dist = d;
got_dist = true;
best_i = num_points - 1;
}
}
if (got_dist) {
// Project the point onto the best line, so that we can confine it to the
// line segment.
LPoint2 best_p = points[best_i]._p;
LPoint2 next_p = points[(best_i + 1) % points.size()]._p;
LVector2 segment = next_p - best_p;
PN_stdfloat t = (p - best_p).dot(segment) / segment.length_squared();
if (t <= 0.0f) {
edge_p = best_p;
} else if (t >= 1.0f) {
edge_p = next_p;
} else {
LVector2 v(points[best_i]._v[1], -points[best_i]._v[0]);
edge_p = p - v * best_dist;
}
}

View File

@ -32,12 +32,12 @@ PUBLISHED:
const LVecBase3 &c);
INLINE CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b,
const LVecBase3 &c, const LVecBase3 &d);
INLINE CollisionPolygon(const LPoint3 *begin, const LPoint3 *end);
private:
INLINE CollisionPolygon();
public:
INLINE CollisionPolygon(const LPoint3 *begin, const LPoint3 *end);
CollisionPolygon(const CollisionPolygon &copy);
virtual CollisionSolid *make_copy();
@ -124,7 +124,7 @@ private:
const Points &points) const;
bool point_is_inside(const LPoint2 &p, const Points &points) const;
PN_stdfloat dist_to_polygon(const LPoint2 &p, const Points &points) const;
PN_stdfloat dist_to_polygon(const LPoint2 &p, LPoint2 &edge_p, const Points &points) const;
void project(const LVector3 &axis, PN_stdfloat &center, PN_stdfloat &extent) const;
void setup_points(const LPoint3 *begin, const LPoint3 *end);

View File

@ -37,11 +37,6 @@ remove_python_event_handler(PyObject* name){
if (PyObject_RichCompareBool(pgwp->get_name(), name, Py_EQ) == 1) {
toRemove.push_back(pgwp);
}
#if PY_MAJOR_VERSION < 3
else if (PyObject_Compare(pgwp->get_name(), name) == 0) {
toRemove.push_back(pgwp);
}
#endif
}
std::list<PythonGraphicsWindowProc*>::iterator iter2;
for (iter2 = toRemove.begin(); iter2 != toRemove.end(); ++iter2) {

View File

@ -66,11 +66,7 @@ __init__(PyObject *self, PyObject *args, PyObject *kwds) {
PyObject *key_repr = PyObject_Repr(key);
PyErr_Format(PyExc_TypeError,
"%.100s is an invalid keyword argument for WindowProperties()",
#if PY_MAJOR_VERSION >= 3
PyUnicode_AsUTF8(key_repr)
#else
PyString_AsString(key_repr)
#endif
);
Py_DECREF(key_repr);
return;

View File

@ -20,10 +20,8 @@
*/
BioStreamPtr::
~BioStreamPtr() {
if (_stream != nullptr) {
delete _stream;
_stream = nullptr;
}
delete _stream;
_stream = nullptr;
}
#endif // HAVE_OPENSSL

View File

@ -37,7 +37,7 @@ add_ostream(std::ostream *out, bool delete_later) {
INLINE bool MultiplexStream::
add_stdio_file(FILE *fout, bool close_when_done) {
_msb.add_output(MultiplexStreamBuf::BT_line,
MultiplexStreamBuf::OT_ostream,
MultiplexStreamBuf::OT_stdio,
nullptr, fout, close_when_done);
return true;
}

View File

@ -93,18 +93,10 @@ operator = (const EggTransform::Component &copy) {
*/
INLINE EggTransform::Component::
~Component() {
if (_vec2 != nullptr) {
delete _vec2;
}
if (_vec3 != nullptr) {
delete _vec3;
}
if (_mat3 != nullptr) {
delete _mat3;
}
if (_mat4 != nullptr) {
delete _mat4;
}
delete _vec2;
delete _vec3;
delete _mat3;
delete _mat4;
}
/**

View File

@ -117,22 +117,7 @@ static PyObject *get_done_result(const AsyncFuture *future) {
}
} else {
// If the future was cancelled, we should raise an exception.
static PyObject *exc_type = nullptr;
if (exc_type == nullptr) {
// Get the CancelledError that asyncio uses, too.
PyObject *module = PyImport_ImportModule("concurrent.futures._base");
if (module != nullptr) {
exc_type = PyObject_GetAttrString(module, "CancelledError");
Py_DECREF(module);
}
// If we can't get that, we should pretend and make our own.
if (exc_type == nullptr) {
exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.CancelledError",
(char*)"The Future was cancelled.",
nullptr, nullptr);
}
}
PyErr_SetNone(exc_type);
PyErr_SetNone(Extension<AsyncFuture>::get_cancelled_error_type());
return nullptr;
}
}
@ -211,16 +196,26 @@ result(PyObject *timeout) const {
static PyObject *exc_type = nullptr;
if (exc_type == nullptr) {
// Get the TimeoutError that asyncio uses, too.
#if PY_VERSION_HEX >= 0x03080000
PyObject *module = PyImport_ImportModule("asyncio.exceptions");
#else
PyObject *module = PyImport_ImportModule("concurrent.futures._base");
#endif
if (module != nullptr) {
exc_type = PyObject_GetAttrString(module, "TimeoutError");
Py_DECREF(module);
}
// If we can't get that, we should pretend and make our own.
if (exc_type == nullptr) {
#if PY_VERSION_HEX >= 0x03080000
exc_type = PyErr_NewExceptionWithDoc((char*)"asyncio.exceptions.TimeoutError",
(char*)"The operation exceeded the given deadline.",
nullptr, nullptr);
#else
exc_type = PyErr_NewExceptionWithDoc((char*)"concurrent.futures._base.TimeoutError",
(char*)"The operation exceeded the given deadline.",
nullptr, nullptr);
#endif
}
}
PyErr_SetNone(exc_type);
@ -285,13 +280,11 @@ gather(PyObject *args) {
futures.push_back(fut);
continue;
}
#if PY_VERSION_HEX >= 0x03050000
} else if (PyCoro_CheckExact(item)) {
// We allow passing in a coroutine instead of a future. This causes it
// to be scheduled as a task.
futures.push_back(new PythonTask(item));
continue;
#endif
}
return Dtool_Raise_ArgTypeError(item, i, "gather", "coroutine, task or future");
}
@ -305,4 +298,37 @@ gather(PyObject *args) {
}
}
/**
* Returns a borrowed reference to the CancelledError exception type.
*/
PyObject *Extension<AsyncFuture>::
get_cancelled_error_type() {
static PyObject *exc_type = nullptr;
if (exc_type == nullptr) {
// Get the CancelledError that asyncio uses, too.
#if PY_VERSION_HEX >= 0x03080000
PyObject *module = PyImport_ImportModule("asyncio.exceptions");
#else
PyObject *module = PyImport_ImportModule("concurrent.futures._base");
#endif
if (module != nullptr) {
exc_type = PyObject_GetAttrString(module, "CancelledError");
Py_DECREF(module);
}
// If we can't get that, we should pretend and make our own.
if (exc_type == nullptr) {
#if PY_VERSION_HEX >= 0x03080000
exc_type = PyErr_NewExceptionWithDoc((char *)"asyncio.exceptions.CancelledError",
(char *)"The Future or Task was cancelled.",
PyExc_BaseException, nullptr);
#else
exc_type = PyErr_NewExceptionWithDoc((char *)"concurrent.futures._base.CancelledError",
(char *)"The Future was cancelled.",
nullptr, nullptr);
#endif
}
}
return exc_type;
}
#endif

Some files were not shown because too many files have changed in this diff Show More