git: f41aeac54f93 - main - databases/py-Elixir: Fix build with setuptools 58.0.0+

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Fri, 25 Mar 2022 13:49:42 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f41aeac54f93961058a65aa9e3b043fcc82b600e

commit f41aeac54f93961058a65aa9e3b043fcc82b600e
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-03-25 13:32:04 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-03-25 13:38:05 +0000

    databases/py-Elixir: Fix build with setuptools 58.0.0+
    
    With hat:       python
---
 databases/py-Elixir/files/patch-2to3 | 190 +++++++++++++++++++++++++++++++++++
 1 file changed, 190 insertions(+)

diff --git a/databases/py-Elixir/files/patch-2to3 b/databases/py-Elixir/files/patch-2to3
new file mode 100644
index 000000000000..ab5974dac8a3
--- /dev/null
+++ b/databases/py-Elixir/files/patch-2to3
@@ -0,0 +1,190 @@
+--- elixir/entity.py.orig	2009-11-13 19:50:38 UTC
++++ elixir/entity.py
+@@ -3,7 +3,7 @@ This module provides the ``Entity`` base class, as wel
+ ``EntityMeta``.
+ '''
+ 
+-from py23compat import sorted
++from .py23compat import sorted
+ 
+ import sys
+ import types
+@@ -172,7 +172,7 @@ class EntityDescriptor(object):
+             self.identity = self.identity(entity)
+ 
+         if self.polymorphic:
+-            if not isinstance(self.polymorphic, basestring):
++            if not isinstance(self.polymorphic, str):
+                 self.polymorphic = options.DEFAULT_POLYMORPHIC_COL_NAME
+ 
+     #---------------------
+@@ -226,7 +226,7 @@ class EntityDescriptor(object):
+                         if col.primary_key:
+                             self.add_column(col.copy())
+             elif not self.has_pk and self.auto_primarykey:
+-                if isinstance(self.auto_primarykey, basestring):
++                if isinstance(self.auto_primarykey, str):
+                     colname = self.auto_primarykey
+                 else:
+                     colname = options.DEFAULT_AUTO_PRIMARYKEY_NAME
+@@ -298,7 +298,7 @@ class EntityDescriptor(object):
+                                        options.POLYMORPHIC_COL_TYPE))
+ 
+             if self.version_id_col:
+-                if not isinstance(self.version_id_col, basestring):
++                if not isinstance(self.version_id_col, str):
+                     self.version_id_col = options.DEFAULT_VERSION_ID_COL_NAME
+                 self.add_column(Column(self.version_id_col, Integer))
+ 
+@@ -306,7 +306,7 @@ class EntityDescriptor(object):
+         self.entity.table = Table(self.tablename, self.metadata,
+                                   *args, **kwargs)
+         if DEBUG:
+-            print self.entity.table.repr2()
++            print(self.entity.table.repr2())
+ 
+     def setup_reltables(self):
+         self.call_builders('create_tables')
+@@ -365,7 +365,7 @@ class EntityDescriptor(object):
+         return children
+ 
+     def translate_order_by(self, order_by):
+-        if isinstance(order_by, basestring):
++        if isinstance(order_by, str):
+             order_by = [order_by]
+ 
+         order = []
+@@ -505,12 +505,12 @@ class EntityDescriptor(object):
+         # get one in any case.
+         table = type.__getattribute__(self.entity, 'table')
+         if table is not None:
+-            if check_duplicate and col.key in table.columns.keys():
++            if check_duplicate and col.key in list(table.columns.keys()):
+                 raise Exception("Column '%s' already exist in table '%s' ! " %
+                                 (col.key, table.name))
+             table.append_column(col)
+             if DEBUG:
+-                print "table.append_column(%s)" % col
++                print("table.append_column(%s)" % col)
+ 
+     def add_constraint(self, constraint):
+         self.constraints.append(constraint)
+@@ -537,7 +537,7 @@ class EntityDescriptor(object):
+         if mapper:
+             mapper.add_property(name, property)
+             if DEBUG:
+-                print "mapper.add_property('%s', %s)" % (name, repr(property))
++                print("mapper.add_property('%s', %s)" % (name, repr(property)))
+ 
+     def add_mapper_extension(self, extension):
+         extensions = self.mapper_options.get('extension', [])
+@@ -795,7 +795,7 @@ def instrument_class(cls):
+ 
+     # Process attributes (using the assignment syntax), looking for
+     # 'Property' instances and attaching them to this entity.
+-    properties = [(name, attr) for name, attr in cls.__dict__.iteritems()
++    properties = [(name, attr) for name, attr in cls.__dict__.items()
+                                if isinstance(attr, Property)]
+     sorted_props = sorted(base_props + properties,
+                           key=lambda i: i[1]._counter)
+@@ -924,7 +924,7 @@ def setup_entities(entities):
+         # delete all Elixir properties so that it doesn't interfere with
+         # SQLAlchemy. At this point they should have be converted to
+         # builders.
+-        for name, attr in entity.__dict__.items():
++        for name, attr in list(entity.__dict__.items()):
+             if isinstance(attr, Property):
+                 delattr(entity, name)
+ 
+@@ -1004,7 +1004,7 @@ class EntityBase(object):
+         self.set(**kwargs)
+ 
+     def set(self, **kwargs):
+-        for key, value in kwargs.iteritems():
++        for key, value in kwargs.items():
+             setattr(self, key, value)
+ 
+     def update_or_create(cls, data, surrogate=True):
+@@ -1038,7 +1038,7 @@ class EntityBase(object):
+ 
+         mapper = sqlalchemy.orm.object_mapper(self)
+ 
+-        for key, value in data.iteritems():
++        for key, value in data.items():
+             if isinstance(value, dict):
+                 dbvalue = getattr(self, key)
+                 rel_class = mapper.get_property(key).mapper.class_
+@@ -1074,7 +1074,7 @@ class EntityBase(object):
+                                       if isinstance(p, ColumnProperty)]
+         data = dict([(name, getattr(self, name))
+                      for name in col_prop_names if name not in exclude])
+-        for rname, rdeep in deep.iteritems():
++        for rname, rdeep in deep.items():
+             dbdata = getattr(self, rname)
+             #FIXME: use attribute names (ie coltoprop) instead of column names
+             fks = self.mapper.get_property(rname).remote_side
+@@ -1145,7 +1145,7 @@ class EntityBase(object):
+     get = classmethod(get)
+ 
+ 
+-class Entity(EntityBase):
++class Entity(EntityBase, metaclass=EntityMeta):
+     '''
+     The base class for all entities
+ 
+@@ -1167,6 +1167,5 @@ class Entity(EntityBase):
+     For further information, please refer to the provided examples or
+     tutorial.
+     '''
+-    __metaclass__ = EntityMeta
+ 
+ 
+--- elixir/py23compat.py.orig	2009-10-02 10:19:50 UTC
++++ elixir/py23compat.py
+@@ -11,7 +11,7 @@ orig_cmp = cmp
+ def sort_list(l, cmp=None, key=None, reverse=False):
+     try:
+         l.sort(cmp, key, reverse)
+-    except TypeError, e:
++    except TypeError as e:
+         if not str(e).startswith('sort expected at most 1 arguments'):
+             raise
+         if cmp is None:
+--- elixir/relationships.py.orig	2009-11-13 20:04:26 UTC
++++ elixir/relationships.py
+@@ -412,7 +412,7 @@ from sqlalchemy import ForeignKeyConstraint, Column, T
+ from sqlalchemy.orm import relation, backref, class_mapper
+ from sqlalchemy.ext.associationproxy import association_proxy
+ 
+-import options
++from . import options
+ from elixir.statements import ClassMutator
+ from elixir.properties import Property
+ from elixir.entity import EntityMeta, DEBUG
+@@ -495,7 +495,7 @@ class Relationship(Property):
+ 
+     def target(self):
+         if not self._target:
+-            if isinstance(self.of_kind, basestring):
++            if isinstance(self.of_kind, str):
+                 collection = self.entity._descriptor.collection
+                 self._target = collection.resolve(self.of_kind, self.entity)
+             else:
+@@ -1115,7 +1115,7 @@ class ManyToMany(Relationship):
+             self.table = Table(tablename, e1_desc.metadata,
+                                schema=schema, *args, **complete_kwargs)
+             if DEBUG:
+-                print self.table.repr2()
++                print(self.table.repr2())
+ 
+     def _build_join_clauses(self):
+         # In the case we have a self-reference, we need to build join clauses
+@@ -1222,7 +1222,7 @@ def _get_join_clauses(local_table, local_cols1, local_
+     # match.
+ 
+ #TODO: rewrite this. Even with the comment, I don't even understand it myself.
+-    for cols, constraint in constraint_map.iteritems():
++    for cols, constraint in constraint_map.items():
+         if cols == cols1 or (cols != cols2 and
+                              not cols1 and (cols2 in constraint_map or
+                                             cols2 is None)):