biocommons / eutils

simplified searching, fetching, and parsing records from NCBI using their E-utilities interface
Apache License 2.0
58 stars 25 forks source link

Fails to install with pip on Windows #140

Closed baoilleach closed 7 years ago

baoilleach commented 8 years ago

Python 2.7 32-bit on Windows 7. Failed similarly with both pip 8.1.2 and 9.0.1.

(Looks like using os.path.join might solve the error below)

C:\Users\noel>C:\python27\Scripts\pip2.7.exe install eutils
Collecting eutils
  Using cached eutils-0.2.1.tar.gz
Exception:
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\python27\lib\site-packages\pip\commands\install.py", line 335, in run

    wb.build(autobuilding=True)
  File "c:\python27\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_
files
    ignore_dependencies=self.ignore_dependencies))
  File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare
_file
    session=self.session, hashes=hashes)
  File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
    hashes=hashes
  File "c:\python27\lib\site-packages\pip\download.py", line 663, in unpack_http
_url
    unpack_file(from_path, location, content_type, link)
  File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 605, in unpac
k_file
    untar_file(filename, location)
  File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 577, in untar
_file
    with open(path, 'wb') as destfp:
IOError: [Errno 22] invalid mode ('wb') or filename: 'c:\\users\\noel\\appdata\\
local\\temp\\pip-build-jobfjx\\eutils\\tests/data/efetch.fcgi?db=pubmed&id=23121
403&retmode=xml.xml'
reece commented 7 years ago

That's probably right. I don't have access to a windows machine, so I can't fix and test. I'll wait for a motivated contributor to submit a PR.

zeanzhou commented 7 years ago

I've found a highly possible reason that may cause the problem above. Linux accept a filename containing '?' (a question mark) while Windows don't. When files are extracted from .tar.gz, all question marks in filename are converted to '_' (underscore) in Windows. Unfortunately, lots of files in tests/data/ contain a '?', and as what is described in eutils.egg-info\SOURCES.txt, Python try to find files like

einfo.fcgi?retmode=xml.xml.gz

but it has been renamed to

einfo.fcgi_retmode=xml.xml.gz

which finally leads to a failure of installation.

Is it feasible to rename those tricky files?

reece commented 7 years ago

Thanks for identifying the cause. As you likely inferred, those paths refer to the URLs from which the data were obtained. If we rename them, we'll lose that connection.

There's a better solution. Those files are essentially just test data caches. I would like to migrate eutils tests to use the vcrpy, which will then cache the results in a cross-platform way.

If you're interested in taking that on, see https://github.com/reece/helix/blob/master/tests/ (particularly the bottom of conftest.py and test_helix_client.py) for an example of how it's used.

If you're not interested/able to undertake this, I'll do it sometime. It'll be pretty easy.

reece commented 7 years ago

@zeanzhou Would you please try this version of the package? It eliminates the test files and replaces them with request caches from vcrpy. Please confirm on this issue that it's fixed on Windows, or reopen the issue. Thanks.

zeanzhou commented 7 years ago

@reece Cool! Now it works well on my Windows laptop! Much appreciated :+1: =)

reece commented 7 years ago

Great. I appreciate the confirmation. pypi packages coming shortly...