jeffdaily / parasail-python

Python bindings for the parasail C library.
Other
87 stars 17 forks source link

Installation failing on Python 3.5 #6

Closed bow closed 7 years ago

bow commented 7 years ago

Hi @jeffdaily,

Thanks for writing parasail. I was about to try it out under Python 3.5, when I found out that the pip installation is not working (I'm on CPython 3.5.2, to be exact).

Here's my stack trace:

Collecting parasail
  Downloading parasail-1.0.1.tar.gz (3.4MB)
    100% |████████████████████████████████| 3.4MB 338kB/s 
Requirement already satisfied (use --upgrade to upgrade): numpy in /home/bow/.virtualenvs/align-dev/lib/python3.5/site-packages (from parasail)
Building wheels for collected packages: parasail
  Running setup.py bdist_wheel for parasail ... error
  Complete output from command /home/bow/.virtualenvs/align-dev/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-u4fvnn0a/parasail/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpzocavws5pip-wheel- --python-tag cp35:
  running bdist_wheel
  Downloading latest parasail master
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-u4fvnn0a/parasail/setup.py", line 233, in <module>
      install_requires=INSTALL_REQUIRES,
    File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-u4fvnn0a/parasail/setup.py", line 205, in run
      build_parasail(libname)
    File "/tmp/pip-build-u4fvnn0a/parasail/setup.py", line 150, in build_parasail
      name,hdrs = urllib.urlretrieve(theurl, archive)
  AttributeError: module 'urllib' has no attribute 'urlretrieve'

  ----------------------------------------
  Failed building wheel for parasail
  Running setup.py clean for parasail
Failed to build parasail

Parasail is still installed afterwards, but importing failed (as expected). The cause is is simply urlretrieve being moved under urllib.request (instead of just urllib) in Python 3.5 (official docs here).

I haven't checked if there's any other urllib-related errors aside from this.

jeffdaily commented 7 years ago

What if I made the following change?

--- a/setup.py
+++ b/setup.py
@@ -147,7 +147,10 @@ def build_parasail(libname):
     if not os.path.exists(archive):
         print("Downloading latest parasail master")
         theurl = 'https://github.com/jeffdaily/parasail/archive/master.zip'
-        name,hdrs = urllib.urlretrieve(theurl, archive)
+        try:
+            name,hdrs = urllib.urlretrieve(theurl, archive)
+        except:
+            name,hdrs = urllib.request.urlretrieve(theurl, archive)
     else:
         print("Archive '{}' already downloaded".format(archive))

Would that work?

bow commented 7 years ago

That doesn't exactly work, unfortunately. I just saw that request.py is a Python file inside the urllib directory.

I tried this locally and python setup.py bdist_wheel seems to work:

diff --git i/setup.py w/setup.py
index 2b12c2b..43dd83c 100644
--- i/setup.py
+++ w/setup.py
@@ -6,7 +6,10 @@ import shutil
 import stat
 import subprocess
 import sys
-import urllib
+try:
+    from urllib import urlretrieve
+except ImportError:
+    from urllib.request import urlretrieve
 import zipfile

 from distutils.util import get_platform
@@ -147,7 +150,7 @@ def build_parasail(libname):
     if not os.path.exists(archive):
         print("Downloading latest parasail master")
         theurl = 'https://github.com/jeffdaily/parasail/archive/master.zip'
-        name,hdrs = urllib.urlretrieve(theurl, archive)
+        name,hdrs = urlretrieve(theurl, archive)
     else:
         print("Archive '{}' already downloaded".format(archive))
jeffdaily commented 7 years ago

I can't believe to took me so long to get this fixed. I just took your code and committed it. Please try it if you get a chance.

bow commented 7 years ago

Hi @jeffdaily,

No worries. Thanks for committing the changes, it works fine now.