11

I am installing a package using dependency_links. It seems to install the package alright but breaks pip freeze functionality (which probably means there is a deeper install issue.) I want to be able to download the package from a custom server without any setup required outside of running setup.py.

This is my setup.py file:

from setuptools import setup

  setup(
      name='package'
      ,version='0.1.0'
      ,packages=['foo',
                 'bar'
                 ]
      ,long_description=''
      ,url='https://github.com/myrepo'
      ,install_requires=['numpy>=1.9.2'
                         ,'some_package'
                         ]
      ,dependency_links=[
          "http://custom_server/packages/some_package-0.1.0.tar.gz"
      ]               
  )

Install seems to work ok, but if I try and run pip_freeze I get the error below.

pip freeze

Error [Errno 20] Not a directory: '/Users/abc/anaconda/lib/python2.7/site-packages/some_package.egg' while executing command git rev-parse
Exception:
Traceback (most recent call last):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/commands/freeze.py", line 70, in run
    for line in freeze(**freeze_kwargs):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/operations/freeze.py", line 49, in freeze
    dependency_links
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/__init__.py", line 235, in from_dist
    if dist_is_editable(dist) and vcs.get_backend_name(location):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/__init__.py", line 75, in get_backend_name
    if vc_type.controls_location(location):
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/git.py", line 266, in controls_location
    on_returncode='ignore')
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/vcs/__init__.py", line 322, in run_command
    spinner)
  File "/Users/myname/anaconda/lib/python2.7/site-packages/pip/utils/__init__.py", line 677, in call_subprocess
    cwd=cwd, env=env)
  File "/Users/myname/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/Users/myname/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 20] Not a directory: '/Users/myname/anaconda/lib/python2.7/site-packages/some_package.egg'
Chris
  • 12,900
  • 12
  • 43
  • 65
  • I know it has to do with the fact that it's an egg file rather than an egg directory but I don't know how to fix it. – Chris Feb 26 '16 at 16:19
  • try adding #egg=some_package-0.1.0 to your dependency link – irqed Mar 01 '16 at 16:23
  • `http://custom_server/packages/some_package-0.1.0.tar.gz#egg=some_package-0.1.0` gave me the same bug when I run pip freeze. The install still works, it just breaks pip freeze :/ – Chris Mar 01 '16 at 20:06
  • Interesting. I wonder why does it says that error occurs "while executing command git rev-parse", are you sure you're not installing in from git repo? How do you install the package? `pip install .` or `python setup.py install` ? Also we can try adding `zip_safe=False` to setup call. – irqed Mar 02 '16 at 07:48
  • I am using setup.py install. Do I add zip_safe to the setup.py file? It doesn't seem to register as a valid option in the cl argument for setup.py. – Chris Mar 02 '16 at 14:55
  • 1
    This worked `pip install . --extra-index-url http://10.XXX.XXX.XXX:YYYY/ --trusted-host 10.XXX.XXX.XXX`. I had to add the trusted host and extra index url options and install via pip rather than setup.py but this installs without breaking pip freeze. If you post as an answer I will accept it and give you the bounty. – Chris Mar 02 '16 at 15:09

1 Answers1

4

pip install . with --extra-index-url and --trusted-host does the trick, also if you want to install it in editable mode you can do pip install -e ..

You might still want to take a look at listing dependency_links and zip_safe option: https://pythonhosted.org/setuptools/setuptools.html#dependencies-that-aren-t-in-pypi https://pythonhosted.org/setuptools/setuptools.html#setting-the-zip-safe-flag https://github.com/irqed/octokit.py/blob/master/setup.py#L51

By the way you can specify --extra-index-url and --trusted-host in pip requirements.txt file as well.

irqed
  • 649
  • 4
  • 15