Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Python 2 #1837

Merged
merged 7 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [2.7.18, 3.8.14]
python-version: [3.8.14]

steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 1 addition & 7 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ ALICEVISION_ROOT=/path/to/AliceVision/install/directory

### Python Environment
* Windows: Python 3 (>=3.5)
* Linux: Python 3 (>=3.5) or Python 2 (>= 2.7)

> No Python 2.7 support on Windows ?
>
> Official Python 2.7 binary package is built with Visual Studio 2008, while PySide2/Qt is built using Visual Studio 2015/2017.
>Therefore, in order to avoid mixing MSVC runtime libraries, Qt does not ship PySide2 wheels for Python 2.7 on Windows (as explained [here](https://wiki.qt.io/Qt_for_Python/Considerations#Missing_Windows_.2F_Python_2.7_release)).
>Note that for using Meshroom in command line mode only (no UI), PySide2 is not required and Python 2.7 would be fine.
* Linux: Python 3 (>=3.5)


To install all the requirements for runtime, development and packaging, simply run:
Expand Down
3 changes: 1 addition & 2 deletions bin/meshroom_batch
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ with multiview.GraphModification(graph):
publish.output.value = args.output

if args.overrides:
import io
import json
with io.open(args.overrides, 'r', encoding='utf-8', errors='ignore') as f:
with open(args.overrides, 'r', encoding='utf-8', errors='ignore') as f:
data = json.load(f)
for nodeName, overrides in data.items():
for attrName, value in overrides.items():
Expand Down
68 changes: 0 additions & 68 deletions docker/Dockerfile_centos_deps_py2

This file was deleted.

72 changes: 0 additions & 72 deletions docker/Dockerfile_centos_py2

This file was deleted.

12 changes: 4 additions & 8 deletions docker/build-centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ test -z "$MESHROOM_VERSION" && MESHROOM_VERSION="$(git rev-parse --abbrev-ref HE
test -z "$AV_VERSION" && echo "AliceVision version not specified, set AV_VERSION in the environment" && exit 1
test -z "$CUDA_VERSION" && CUDA_VERSION="10.2"
test -z "$CENTOS_VERSION" && CENTOS_VERSION="7"
test -z "$MESHROOM_PYTHON2" || echo "========== Build for Python 2 =========="
test -z "$MESHROOM_PYTHON2" || export PYTHON2_DOCKER_EXT="-py2"
test -z "$MESHROOM_PYTHON2" || export PYTHON2_DOCKERFILE_EXT="_py2"
test -z "$MESHROOM_PYTHON2" && echo "========== Build for Python 3 =========="

test -d docker || (
echo This script must be run from the top level Meshroom directory
Expand All @@ -27,8 +23,8 @@ docker build \
--build-arg "CUDA_VERSION=${CUDA_VERSION}" \
--build-arg "CENTOS_VERSION=${CENTOS_VERSION}" \
--build-arg "AV_VERSION=${AV_VERSION}" \
--tag "alicevision/meshroom-deps:${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}${PYTHON2_DOCKER_EXT}" \
-f docker/Dockerfile_centos_deps${PYTHON2_DOCKERFILE_EXT} .
--tag "alicevision/meshroom-deps:${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}" \
-f docker/Dockerfile_centos_deps .

# Meshroom
docker build \
Expand All @@ -37,6 +33,6 @@ docker build \
--build-arg "CUDA_VERSION=${CUDA_VERSION}" \
--build-arg "CENTOS_VERSION=${CENTOS_VERSION}" \
--build-arg "AV_VERSION=${AV_VERSION}" \
--tag "alicevision/meshroom:${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}${PYTHON2_DOCKER_EXT}" \
-f docker/Dockerfile_centos${PYTHON2_DOCKERFILE_EXT} .
--tag "alicevision/meshroom:${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}" \
-f docker/Dockerfile_centos .

6 changes: 1 addition & 5 deletions docker/extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ test -z "$MESHROOM_VERSION" && MESHROOM_VERSION="$(git rev-parse --abbrev-ref HE
test -z "$AV_VERSION" && echo "AliceVision version not specified, set AV_VERSION in the environment" && exit 1
test -z "$CUDA_VERSION" && CUDA_VERSION="10.2"
test -z "$CENTOS_VERSION" && CENTOS_VERSION="7"
test -z "$MESHROOM_PYTHON2" || echo "========== Build for Python 2 =========="
test -z "$MESHROOM_PYTHON2" || export PYTHON2_DOCKER_EXT="-py2"
test -z "$MESHROOM_PYTHON2" || export PYTHON2_DOCKERFILE_EXT="_py2"
test -z "$MESHROOM_PYTHON2" && echo "========== Build for Python 3 =========="

test -d docker || (
echo This script must be run from the top level Meshroom directory
exit 1
)

VERSION_NAME=${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}${PYTHON2_DOCKER_EXT}
VERSION_NAME=${MESHROOM_VERSION}-av${AV_VERSION}-centos${CENTOS_VERSION}-cuda${CUDA_VERSION}

# Retrieve the Meshroom bundle folder
rm -rf ./Meshroom-${VERSION_NAME}
Expand Down
6 changes: 0 additions & 6 deletions docs/source/_ext/fetch_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
from docutils.parsers.rst import Directive
from utils import md_to_docutils, get_link_key

# Python2 compatibility
try:
FileNotFoundError
except NameError:
FileNotFoundError = IOError


class Relinker(SparseNodeVisitor):

Expand Down
54 changes: 1 addition & 53 deletions meshroom/common/PySignal.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,7 @@
import sys
import weakref
from functools import partial


# weakref.WeakMethod backport
try:
from weakref import WeakMethod

except ImportError:
import types

class WeakMethod(object):
"""Light WeakMethod backport compiled from various sources. Tested in 2.7"""

def __init__(self, func):
if inspect.ismethod(func):
self._obj = weakref.ref(func.__self__)
self._func = weakref.ref(func.__func__)

else:
self._obj = None

try:
self._func = weakref.ref(func.__func__)

# Rather than attempting to handle this, raise the same exception
# you get from WeakMethod.
except AttributeError:
raise TypeError("argument should be a bound method, not %s" % type(func))

def __call__(self):
if self._obj is not None:
obj = self._obj()
func = self._func()
if func is None or obj is None:
return None

else:
return types.MethodType(func, obj, obj.__class__)

elif self._func is not None:
return self._func()

else:
return None

def __eq__(self, other):
try:
return type(self) is type(other) and self() == other()

except Exception:
return False

def __ne__(self, other):
return not self.__eq__(other)
from weakref import WeakMethod


class Signal(object):
Expand Down
3 changes: 1 addition & 2 deletions meshroom/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from meshroom.core.submitter import BaseSubmitter
from . import desc
from . import pyCompatibility

# Setup logging
logging.basicConfig(format='[%(asctime)s][%(levelname)s] %(message)s', level=logging.INFO)
Expand Down Expand Up @@ -150,7 +149,7 @@ def __init__(self, *args):
self.components = tuple()
elif len(args) == 1:
versionName = args[0]
if isinstance(versionName, pyCompatibility.basestring):
if isinstance(versionName, str):
self.components = Version.toComponents(versionName)
elif isinstance(versionName, (list, tuple)):
self.components = tuple([int(v) for v in versionName])
Expand Down
9 changes: 5 additions & 4 deletions meshroom/core/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import types
import logging

from collections.abc import Sequence
from string import Template
from meshroom.common import BaseObject, Property, Variant, Signal, ListModel, DictModel, Slot
from meshroom.core import desc, pyCompatibility, hashValue
from meshroom.core import desc, hashValue


def attributeFactory(description, value, isOutput, node, root=None, parent=None):
Expand Down Expand Up @@ -213,7 +214,7 @@ def isLinkExpression(value):
Return whether the given argument is a link expression.
A link expression is a string matching the {nodeName.attrName} pattern.
"""
return isinstance(value, pyCompatibility.basestring) and Attribute.stringIsLinkRe.match(value)
return isinstance(value, str) and Attribute.stringIsLinkRe.match(value)

def getLinkParam(self, recursive=False):
if not self.isLink:
Expand Down Expand Up @@ -264,13 +265,13 @@ def getExportValue(self):
return self._value

def getEvalValue(self):
if isinstance(self.value, pyCompatibility.basestring):
if isinstance(self.value, str):
return Template(self.value).safe_substitute(os.environ)
return self.value

def getValueStr(self):
if isinstance(self.attributeDesc, desc.ChoiceParam) and not self.attributeDesc.exclusive:
assert(isinstance(self.value, pyCompatibility.Sequence) and not isinstance(self.value, pyCompatibility.basestring))
assert(isinstance(self.value, Sequence) and not isinstance(self.value, str))
return self.attributeDesc.joinChar.join(self.getEvalValue())
if isinstance(self.attributeDesc, (desc.StringParam, desc.File)):
return '"{}"'.format(self.getEvalValue())
Expand Down
Loading