You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/12/04 22:42:27 UTC
[tinkerpop] 01/01: TINKERPOP-2317 Removed Python 2 support
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch TINKERPOP-2317
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 534f4ad02155ab8bb7b05b13649f2e530bd0d92b
Author: stephen <sp...@gmail.com>
AuthorDate: Wed Dec 4 17:38:00 2019 -0500
TINKERPOP-2317 Removed Python 2 support
Had to refactor the radish tests a bit because they weren't previously running on python 3 and therefore were incompatible.
---
CHANGELOG.asciidoc | 1 +
docs/src/upgrade/release-3.5.x.asciidoc | 7 +++
gremlin-python/pom.xml | 65 ++++------------------
.../src/main/jython/gremlin_python/statics.py | 35 ++++--------
.../gremlin_python/structure/io/graphbinaryV1.py | 4 --
.../src/main/jython/radish/feature_steps.py | 11 ++--
gremlin-python/src/main/jython/radish/terrain.py | 2 +-
gremlin-python/src/main/jython/setup.py | 3 +-
.../tests/structure/io/test_functionalityio.py | 17 +++---
.../tests/structure/io/test_graphbinaryV1.py | 9 +--
.../jython/tests/structure/io/test_graphsonV2d0.py | 2 -
.../jython/tests/structure/io/test_graphsonV3d0.py | 2 -
.../src/main/jython/tests/structure/test_graph.py | 4 --
gremlin-test/features/branch/Branch.feature | 16 ++++--
gremlin-test/features/branch/Choose.feature | 6 +-
gremlin-test/features/filter/Is.feature | 3 +-
gremlin-test/features/filter/Or.feature | 3 +-
gremlin-test/features/map/Select.feature | 3 +-
18 files changed, 68 insertions(+), 125 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 234e1b5..9464e46 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,7 @@ This release also includes changes from <<release-3-4-3, 3.4.3>>.
* Refactored `MapStep` to move its logic to `ScalarMapStep` so that the old behavior could be preserved while allow other implementations to have more flexibility.
* Modified TinkerGraph to support `null` property values and can be configured to disable that feature.
* Modified `null` handling in mutations to be consistent for a new `Vertex` as well as update to an existing one.
+* Removed support for Python 2.x in gremlinpython.
* Upgraded to Apache Commons Configuration2.
* Renamed `StoreStep` to `AggregateLocalStep`.
* Renamed `AggregateStep` to `AggregateGlobalStep`.
diff --git a/docs/src/upgrade/release-3.5.x.asciidoc b/docs/src/upgrade/release-3.5.x.asciidoc
index ebe5456..a7568d1 100644
--- a/docs/src/upgrade/release-3.5.x.asciidoc
+++ b/docs/src/upgrade/release-3.5.x.asciidoc
@@ -180,6 +180,13 @@ formerly held the cache for these side-effects, no longer have any effect and ca
See: link:https://issues.apache.org/jira/browse/TINKERPOP-2269[TINKERPOP-2269]
+==== Python 2.x Support
+
+The gremlinpython module no longer supports Python 2.x. Users must use Python 3 going forward. For the most part, from
+a user's perspective, there are no specific API changes to consider as a result of this change.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-2317[TINKERPOP-2317]
+
==== Deprecation Removal
The following deprecated classes, methods or fields have been removed in this version:
diff --git a/gremlin-python/pom.xml b/gremlin-python/pom.xml
index 57bd116..436ac20 100644
--- a/gremlin-python/pom.xml
+++ b/gremlin-python/pom.xml
@@ -304,20 +304,6 @@ limitations under the License.
<copy todir="${project.build.directory}/python3">
<fileset dir="src/main/jython"/>
</copy>
- <copy todir="${project.build.directory}/python2">
- <fileset dir="src/main/jython"/>
- </copy>
- <copy todir="${project.build.directory}/python-packaged">
- <fileset dir="src/main/jython"/>
- </copy>
- <exec dir="${project.build.directory}/python2" executable="virtualenv"
- failonerror="true">
- <arg line="--python=python2 env"/>
- </exec>
- <exec dir="${project.build.directory}/python2" executable="env/bin/pip"
- failonerror="true">
- <arg line="install wheel radish-bdd PyHamcrest aenum isodate"/>
- </exec>
<exec dir="${project.build.directory}/python3" executable="virtualenv"
failonerror="true">
<arg line="--python=python3 env"/>
@@ -326,6 +312,9 @@ limitations under the License.
failonerror="true">
<arg line="install wheel radish-bdd PyHamcrest aenum isodate"/>
</exec>
+ <copy todir="${project.build.directory}/python-packaged">
+ <fileset dir="src/main/jython"/>
+ </copy>
<exec dir="${project.build.directory}/python-packaged" executable="virtualenv"
failonerror="true">
<arg line="--python=python3 env"/>
@@ -338,23 +327,6 @@ limitations under the License.
</configuration>
</execution>
<execution>
- <id>native-python2-build</id>
- <phase>compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target>
- <exec executable="env/bin/python" dir="${project.build.directory}/python2"
- failonerror="true">
- <env key="PYTHONPATH" value=""/>
- <!-- oddly the "build-lib" needs to be in place or else docs won't generate -->
- <arg line="setup.py build --build-lib ${project.build.outputDirectory}/Lib"/>
- </exec>
- </target>
- </configuration>
- </execution>
- <execution>
<id>native-python3-build</id>
<phase>compile</phase>
<goals>
@@ -400,7 +372,7 @@ limitations under the License.
test phase doesn't have a pre/post event like integration-test does.
-->
<execution>
- <id>native-python2-test</id>
+ <id>native-python3-test</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
@@ -408,47 +380,30 @@ limitations under the License.
<configuration>
<skip>${skipTests}</skip>
<target>
- <exec executable="env/bin/python" dir="${project.build.directory}/python2"
+ <exec executable="env/bin/python" dir="${project.build.directory}/python3"
failonerror="true">
<env key="PYTHONPATH" value=""/>
<arg line="setup.py test"/>
</exec>
<!-- radish seems to like all dependencies in place -->
- <exec executable="env/bin/python" dir="${project.build.directory}/python2"
+ <exec executable="env/bin/python" dir="${project.build.directory}/python3"
failonerror="true">
<env key="PYTHONPATH" value=""/>
<arg line="setup.py install"/>
</exec>
<!-- run for graphson 3.0 -->
- <exec executable="env/bin/radish" dir="${project.build.directory}/python2"
+ <exec executable="env/bin/radish" dir="${project.build.directory}/python3"
failonerror="true">
<env key="PYTHONPATH" value=""/>
<env key="PYTHONIOENCODING" value="utf-8:surrogateescape"/>
- <arg line="-f dots -e -t -b ${project.build.directory}/python2/radish ${project.basedir}/../gremlin-test/features/ --user-data="serializer=application/vnd.gremlin-v3.0+json""/> <!-- -no-line-jump -->
+ <arg line="-f dots -e -t -b ${project.build.directory}/python3/radish ${project.basedir}/../gremlin-test/features/ --user-data="serializer=application/vnd.gremlin-v3.0+json""/> <!-- -no-line-jump -->
</exec>
<!-- run for graphbinary 1.0 -->
- <exec executable="env/bin/radish" dir="${project.build.directory}/python2"
+ <exec executable="env/bin/radish" dir="${project.build.directory}/python3"
failonerror="true">
<env key="PYTHONPATH" value=""/>
<env key="PYTHONIOENCODING" value="utf-8:surrogateescape"/>
- <arg line="-f dots -e -t -b ${project.build.directory}/python2/radish ${project.basedir}/../gremlin-test/features/ --user-data="serializer=application/vnd.graphbinary-v1.0""/> <!-- -no-line-jump -->
- </exec>
- </target>
- </configuration>
- </execution>
- <execution>
- <id>native-python3-test</id>
- <phase>integration-test</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <skip>${skipTests}</skip>
- <target>
- <exec executable="env/bin/python" dir="${project.build.directory}/python3"
- failonerror="true">
- <env key="PYTHONPATH" value=""/>
- <arg line="setup.py test"/>
+ <arg line="-f dots -e -t -b ${project.build.directory}/python3/radish ${project.basedir}/../gremlin-test/features/ --user-data="serializer=application/vnd.graphbinary-v1.0""/> <!-- -no-line-jump -->
</exec>
</target>
</configuration>
diff --git a/gremlin-python/src/main/jython/gremlin_python/statics.py b/gremlin-python/src/main/jython/gremlin_python/statics.py
index 221e166..9e27366 100644
--- a/gremlin-python/src/main/jython/gremlin_python/statics.py
+++ b/gremlin-python/src/main/jython/gremlin_python/statics.py
@@ -18,32 +18,21 @@
#
from types import FunctionType
-
-import six
from aenum import Enum
-if six.PY3:
- class long(int): pass
- FloatType = float
- IntType = int
- LongType = long
- TypeType = type
- ListType = list
- DictType = dict
- SetType = set
- ByteBufferType = bytes
-else:
- long = long
- SetType = set
- ByteBufferType = bytearray
- from types import FloatType
- from types import IntType
- from types import LongType
- from types import TypeType
- from types import ListType
- from types import DictType
- from types import TypeType
+class long(int):
+ pass
+
+
+FloatType = float
+IntType = int
+LongType = long
+TypeType = type
+ListType = list
+DictType = dict
+SetType = set
+ByteBufferType = bytes
class timestamp(float):
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
index b5aca52..862d7f6 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphbinaryV1.py
@@ -162,10 +162,6 @@ class GraphBinaryWriter(object):
try:
t = type(obj)
-
- # coerce unicode to str so the serializer will be found properly in the cache...better way?
- if not six.PY3:
- t = str if isinstance(obj, unicode) else t
return self.serializers[t].dictify(obj, self, to_extend)
except KeyError:
for key, serializer in self.serializers.items():
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 6514f3c..4db9167 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -19,6 +19,7 @@
import json
import re
+from gremlin_python.statics import long
from gremlin_python.structure.graph import Path
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.process.graph_traversal import __
@@ -97,7 +98,7 @@ def iterate_the_traversal(step):
if step.context.ignore:
return
- step.context.result = map(lambda x: _convert_results(x), step.context.traversal.toList())
+ step.context.result = list(map(lambda x: _convert_results(x), step.context.traversal.toList()))
@when("iterated next")
@@ -105,7 +106,7 @@ def next_the_traversal(step):
if step.context.ignore:
return
- step.context.result = map(lambda x: _convert_results(x), step.context.traversal.next())
+ step.context.result = list(map(lambda x: _convert_results(x), step.context.traversal.next()))
@then("the result should be {characterized_as:w}")
@@ -137,7 +138,7 @@ def assert_side_effects(step, count, traversal_string):
@then("the result should have a count of {count:d}")
def assert_count(step, count):
- assert_that(len(step.context.result), equal_to(count))
+ assert_that(len(list(step.context.result)), equal_to(count))
@then("nothing should happen because")
@@ -152,8 +153,6 @@ def _convert(val, ctx):
for key, value in val.items():
n[_convert(key, ctx)] = _convert(value, ctx)
return n
- elif isinstance(val, unicode): # convert annoying python 2.x unicode nonsense
- return _convert(val.encode('utf-8'), ctx)
elif isinstance(val, str) and re.match("^l\[.*\]$", val): # parse list
return [] if val == "l[]" else list(map((lambda x: _convert(x, ctx)), val[2:-1].split(",")))
elif isinstance(val, str) and re.match("^s\[.*\]$", val): # parse set
@@ -201,7 +200,7 @@ def __find_cached_element(ctx, graph_name, identifier, element_type):
def _convert_results(val):
if isinstance(val, Path):
# kill out labels as they aren't in the assertion logic
- return Path([set([])], map(lambda p: p.encode("utf-8") if isinstance(p, unicode) else p, val.objects))
+ return Path([set([])], val.objects)
else:
return val
diff --git a/gremlin-python/src/main/jython/radish/terrain.py b/gremlin-python/src/main/jython/radish/terrain.py
index 8fa01d02..e08f864 100644
--- a/gremlin-python/src/main/jython/radish/terrain.py
+++ b/gremlin-python/src/main/jython/radish/terrain.py
@@ -79,7 +79,7 @@ def close_traversal_source(scenario):
@after.all
def close_static_traversal_source(features, marker):
- for key, value in world.cache.iteritems():
+ for key, value in world.cache.items():
value["remote_conn"].close()
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
index da54c87..58cf752 100644
--- a/gremlin-python/src/main/jython/setup.py
+++ b/gremlin-python/src/main/jython/setup.py
@@ -51,7 +51,7 @@ install_requires = [
'isodate>=0.6.0'
]
-if sys.version_info < (3,2):
+if sys.version_info < (3, 2):
install_requires += ['futures>=3.0.5']
setup(
@@ -81,7 +81,6 @@ setup(
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
- "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
]
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_functionalityio.py b/gremlin-python/src/main/jython/tests/structure/io/test_functionalityio.py
index 26a62a2..d221b18 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_functionalityio.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_functionalityio.py
@@ -77,15 +77,14 @@ def test_odd_bits(remote_connection):
finally:
g.V(vid).drop().iterate()
- if six.PY3:
- char_upper = str.__new__(SingleChar, chr(57344))
- resp = g.addV('test_vertex').property('char_upper', char_upper).toList()
- vid = resp[0].id
- try:
- v = g.V(vid).values('char_upper').toList()[0]
- assert v == char_upper
- finally:
- g.V(vid).drop().iterate()
+ char_upper = str.__new__(SingleChar, chr(57344))
+ resp = g.addV('test_vertex').property('char_upper', char_upper).toList()
+ vid = resp[0].id
+ try:
+ v = g.V(vid).values('char_upper').toList()[0]
+ assert v == char_upper
+ finally:
+ g.V(vid).drop().iterate()
dur = datetime.timedelta(seconds=1000, microseconds=1000)
resp = g.addV('test_vertex').property('dur', dur).toList()
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
index 7416a94..cee1bb2 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphbinaryV1.py
@@ -26,8 +26,6 @@ from decimal import *
from mock import Mock
-import six
-
from gremlin_python.statics import timestamp, long, SingleByte, SingleChar, ByteBufferType
from gremlin_python.structure.graph import Vertex, Edge, Property, VertexProperty, Graph, Path
from gremlin_python.structure.io.graphbinaryV1 import GraphBinaryWriter, GraphBinaryReader, DataType
@@ -212,10 +210,9 @@ class TestGraphSONWriter(object):
output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
assert x == output
- if six.PY3:
- x = str.__new__(SingleChar, chr(57344))
- output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
- assert x == output
+ x = str.__new__(SingleChar, chr(57344))
+ output = self.graphbinary_reader.readObject(self.graphbinary_writer.writeObject(x))
+ assert x == output
def test_duration(self):
x = datetime.timedelta(seconds=1000, microseconds=1000)
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
index cebe29c..96682e7 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV2d0.py
@@ -28,8 +28,6 @@ from decimal import *
from mock import Mock
-import six
-
from gremlin_python.statics import *
from gremlin_python.structure.graph import Vertex, Edge, Property, VertexProperty, Graph, Path
from gremlin_python.structure.io.graphsonV2d0 import GraphSONWriter, GraphSONReader, GraphSONUtil
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
index 9366937..1644a1a 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
@@ -28,8 +28,6 @@ from decimal import *
from mock import Mock
-import six
-
from gremlin_python.statics import *
from gremlin_python.structure.graph import Vertex, Edge, Property, VertexProperty, Graph, Path
from gremlin_python.structure.io.graphsonV3d0 import GraphSONWriter, GraphSONReader, GraphSONUtil
diff --git a/gremlin-python/src/main/jython/tests/structure/test_graph.py b/gremlin-python/src/main/jython/tests/structure/test_graph.py
index 67849f6..0937e39 100644
--- a/gremlin-python/src/main/jython/tests/structure/test_graph.py
+++ b/gremlin-python/src/main/jython/tests/structure/test_graph.py
@@ -19,8 +19,6 @@
__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
-import six
-
from gremlin_python.statics import long
from gremlin_python.structure.graph import Edge
from gremlin_python.structure.graph import Property
@@ -62,8 +60,6 @@ class TestGraph(object):
assert Vertex(1) == property.element
assert isinstance(property.value, int)
assert property == Property("age", 29, Vertex(1))
- if not six.PY3:
- assert property != Property("age", long(29), Vertex(1))
#
for i in [vertex, edge, vertex_property, property]:
for j in [vertex, edge, vertex_property, property]:
diff --git a/gremlin-test/features/branch/Branch.feature b/gremlin-test/features/branch/Branch.feature
index e160fc8..a161ba7 100644
--- a/gremlin-test/features/branch/Branch.feature
+++ b/gremlin-test/features/branch/Branch.feature
@@ -42,13 +42,15 @@ Feature: Step - branch()
Scenario: g_V_branchXlabel_isXpersonX_countX_optionX1__ageX_optionX0__langX_optionX0__nameX
Given the modern graph
+ And using the parameter one defined as "d[1].l"
+ And using the parameter zero defined as "d[0].l"
And the traversal of
"""
g.V().
branch(__.label().is("person").count()).
- option(1L, __.values("age")).
- option(0L, __.values("lang")).
- option(0L, __.values("name"))
+ option(one, __.values("age")).
+ option(zero, __.values("lang")).
+ option(zero, __.values("name"))
"""
When iterated to list
Then the result should be unordered
@@ -64,13 +66,15 @@ Feature: Step - branch()
Scenario: g_V_branchXlabel_isXpersonX_countX_optionX1__ageX_optionX0__langX_optionX0__nameX_optionXany__labelX
Given the modern graph
+ And using the parameter one defined as "d[1].l"
+ And using the parameter zero defined as "d[0].l"
And the traversal of
"""
g.V().
branch(__.label().is("person").count()).
- option(1L, __.values("age")).
- option(0L, __.values("lang")).
- option(0L, __.values("name")).
+ option(one, __.values("age")).
+ option(zero, __.values("lang")).
+ option(zero, __.values("name")).
option(Pick.any, __.label())
"""
When iterated to list
diff --git a/gremlin-test/features/branch/Choose.feature b/gremlin-test/features/branch/Choose.feature
index 7bb8c03..99ff4c4 100644
--- a/gremlin-test/features/branch/Choose.feature
+++ b/gremlin-test/features/branch/Choose.feature
@@ -19,11 +19,13 @@ Feature: Step - choose()
Scenario: g_V_chooseXout_countX_optionX2L_nameX_optionX3L_ageX
Given the modern graph
+ And using the parameter two defined as "d[2].l"
+ And using the parameter three defined as "d[3].l"
And the traversal of
"""
g.V().choose(__.out().count()).
- option(2L, __.values("name")).
- option(3L, __.values("age"))
+ option(two, __.values("name")).
+ option(three, __.values("age"))
"""
When iterated to list
Then the result should be unordered
diff --git a/gremlin-test/features/filter/Is.feature b/gremlin-test/features/filter/Is.feature
index 4eec274..70c7a9a 100644
--- a/gremlin-test/features/filter/Is.feature
+++ b/gremlin-test/features/filter/Is.feature
@@ -65,9 +65,10 @@ Feature: Step - coin()
Scenario: g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX
Given the modern graph
+ And using the parameter two defined as "d[2].l"
And the traversal of
"""
- g.V().where(__.in("created").count().is(P.gte(2l))).values("name")
+ g.V().where(__.in("created").count().is(P.gte(two))).values("name")
"""
When iterated to list
Then the result should be unordered
diff --git a/gremlin-test/features/filter/Or.feature b/gremlin-test/features/filter/Or.feature
index 7f4782d..437bcd1 100644
--- a/gremlin-test/features/filter/Or.feature
+++ b/gremlin-test/features/filter/Or.feature
@@ -19,9 +19,10 @@ Feature: Step - or()
Scenario: g_V_orXhasXage_gt_27X__outE_count_gte_2X_name
Given the modern graph
+ And using the parameter two defined as "d[2].l"
And the traversal of
"""
- g.V().or(__.has("age", P.gt(27)), __.outE().count().is(P.gte(2l))).values("name")
+ g.V().or(__.has("age", P.gt(27)), __.outE().count().is(P.gte(two))).values("name")
"""
When iterated to list
Then the result should be unordered
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index be1a899..0d4913a 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -185,9 +185,10 @@ Feature: Step - select()
Scenario: g_V_chooseXoutE_count_isX0X__asXaX__asXbXX_chooseXselectXaX__selectXaX__selectXbXX
Given the modern graph
+ And using the parameter zero defined as "d[0].l"
And the traversal of
"""
- g.V().choose(__.outE().count().is(0L),
+ g.V().choose(__.outE().count().is(zero),
__.as("a"),
__.as("b")).
choose(__.select("a"),