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

Python 3 support #23

Open
giampaolo opened this issue Aug 15, 2014 · 5 comments
Open

Python 3 support #23

giampaolo opened this issue Aug 15, 2014 · 5 comments

Comments

@giampaolo
Copy link

giampaolo commented Aug 15, 2014

This is currently missing. Any plan to migrate magento to Python 3?

$ pip3.4 install magento --user
Downloading/unpacking magento
  Using download cache from /home/giampaolo/.pip/cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fm%2Fmagento%2Fmagento-0.4.tar.gz
  Running setup.py (path:/tmp/pip_build_giampaolo/magento/setup.py) egg_info for package magento
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_giampaolo/magento/setup.py", line 14, in <module>
        execfile(os.path.join('magento', 'version.py'))
    NameError: name 'execfile' is not defined
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_giampaolo/magento/setup.py", line 14, in <module>

    execfile(os.path.join('magento', 'version.py'))

NameError: name 'execfile' is not defined

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_giampaolo/magento
Storing debug log for failure in /home/giampaolo/.pip/pip.log

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/3739583-python-3-support?utm_campaign=plugin&utm_content=tracker%2F490249&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F490249&utm_medium=issues&utm_source=github).
@sharoonthomas
Copy link

Not planning on doing immediately though its in the roadmap. We mostly use it for the tryton magento integration and when tryton moves to python 3 this module should too. However, happy to accept a PR if you would like to implement it :)

@sharoonthomas
Copy link

running 2to3 should fix most issues I guess

@giampaolo
Copy link
Author

With the following patch I'm able to install magento on Python 3.4. It uses "suds-jurko" instead of "suds" as apparently "suds" has not been ported yet and "suds-jurko" is the only viable alternative so far.

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'
     ],

@tomaszsmolarek
Copy link

This patch seems to work perfectly. Any chance we could get this added to the repo? I'd like to be able to create a submodule out of your repo.

@sharoonthomas
Copy link

Can you send a patch to https://github.com/fulfilio/python-magento ? not maintained here anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants