Skip to content

Commit

Permalink
cleanup: Remove support for EOL versions of Python
Browse files Browse the repository at this point in the history
Fixes #905
  • Loading branch information
rdb committed Apr 26, 2020
1 parent 54f2bc4 commit d799a09
Show file tree
Hide file tree
Showing 103 changed files with 245 additions and 1,367 deletions.
44 changes: 1 addition & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -407,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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions direct/src/cluster/ClusterMsgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@
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:
Expand Down
8 changes: 0 additions & 8 deletions direct/src/dcparser/dcClass_ext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions direct/src/dcparser/dcField_ext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -266,34 +266,22 @@ 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;
}

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;
}
Expand Down
61 changes: 0 additions & 61 deletions direct/src/dcparser/dcPacker_ext.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,27 @@ 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:
if (PyLong_Check(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:
if (PyLong_Check(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:
if (PyLong_Check(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:
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down
11 changes: 3 additions & 8 deletions direct/src/directscripts/extract_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

__all__ = []

import os, sys
import os
from distutils import sysconfig
import panda3d, pandac
from panda3d.interrogatedb import *
Expand Down Expand Up @@ -309,13 +309,8 @@ def processModule(handle, package):
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.'):
Expand Down
6 changes: 1 addition & 5 deletions direct/src/directtools/DirectSession.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import math
import sys

from panda3d.core import *
from .DirectUtil import *
Expand Down Expand Up @@ -942,10 +941,7 @@ def downAncestry(self):

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:
Expand Down
1 change: 0 additions & 1 deletion direct/src/dist/FreezeTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
# dummy entry should be written to the inittab.
builtinInitFuncs = {
'builtins': None,
'__builtin__': None,
'sys': None,
'exceptions': None,
'_warnings': '_PyWarnings_Init',
Expand Down
10 changes: 1 addition & 9 deletions direct/src/dist/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
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
Expand All @@ -48,7 +44,7 @@


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()]
Expand Down Expand Up @@ -407,10 +403,6 @@ def download_wheels(self, platform):
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)

Expand Down

0 comments on commit d799a09

Please sign in to comment.