Skip to content

Python 3 support #4

@tomaszsmolarek

Description

@tomaszsmolarek

Per @sharoonthomas's request from openlabs/magento#23

Seems like @giampaolo's patch works perfectly and allows to use code with python 3. Can we please add that to repo?

diff --git a/magento/api.py b/magento/api.py
index dc7c085..bda6977 100644
--- a/magento/api.py
+++ b/magento/api.py
@@ -9,9 +9,14 @@
     :license: AGPLv3, see LICENSE for more details
 '''

+import sys
+
 PROTOCOLS = []
 try:
-    from xmlrpclib import ServerProxy
+    if sys.version_info <= (2, ):
+        from xmlrpclib import ServerProxy
+    else:
+        from xmlrpc.client import ServerProxy
 except ImportError:
     pass
 else:
diff --git a/setup.py b/setup.py
index 16a1c32..ba9a7cb 100644
--- a/setup.py
+++ b/setup.py
@@ -8,10 +8,11 @@
     :license: AGPLv3, see LICENSE for more details

 '''
+
 import os
 from setuptools import setup

-execfile(os.path.join('magento', 'version.py'))
+exec(open(os.path.join('magento', 'version.py')).read())

 setup(
     name = 'magento',
@@ -26,15 +27,17 @@ setup(
     zip_safe=False,
     platforms='any',
     install_requires=[
-        'suds>=0.3.9',
+        'suds-jurko',
     ],
     classifiers=[
         'Development Status :: 6 - Mature',
         'Environment :: Web Environment',
         'Intended Audience :: Developers',
-        'License :: OSI Approved :: GNU Affero General Public License v3', 
+        'License :: OSI Approved :: GNU Affero General Public License v3',
         'Operating System :: OS Independent',
         'Programming Language :: Python',
+        'Programming Language :: Python :: 2',
+        'Programming Language :: Python :: 3',
         'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
         'Topic :: Software Development :: Libraries :: Python Modules'
     ],

Above code is written by @giampaolo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions