2

I am unable to install the local packages using setup.py

Here is the project structure:

my-project/
  lib/
     local1/
        local1.1.0.whl
        index.html
     local2/
        local2.1.0.whl
        index.html
  setup.py

setup.py

import os

from setuptools import setup

setup(name='my project',
      version='1.0',
      description='my project',
      install_requires=[
        'lxml >= 4.3.0',
        'local1 @ file://localhost/{}/lib/local1/local1.1.0.whl'.format(os.getcwd()),
        'local2 @ file://localhost/{}/lib/local2/local2.2.0.whl'.format(os.getcwd()),
      ]
      )

I can install if I put the dependencies in a requirements.txt file and use pip install -r requirements.txt --extra-index-url lib/, but I want to know why is it not possible to do python setup.py install or if I am missing something.

This is the error that I get -

No local packages or working download links found for local2@ file://localhost//Users/anusha/Documents/my-project/lib/local2/local2.1.0.whl
error: Could not find suitable distribution for Requirement.parse('local2@ file://localhost//Users/anusha/Documents/my-project/lib/local2/local2.1.0.whl')

On searching, I found this issue on github, but does not give me any pointers or solution as to how it worked.

Any help is welcome, thanks in advance!

Anusha
  • 647
  • 11
  • 29
  • Not entirely sure _setuptools_ supports this notation. Are you referring to ["direct references" of _PEP440_](https://www.python.org/dev/peps/pep-0440/#direct-references)? Note the three (3) slashes! – sinoroc Feb 24 '20 at 09:18
  • 1
    since I am specifying `localhost` 2 slashes should suffice, even I am not sure of setuptools supporting this, but did not find any supporting documents for proving this! I tried `pip install git+file//$PWD/` and it seemed to work – Anusha Feb 24 '20 at 09:36
  • Yes, in between I read the ["File URLs" section of _PEP 440_](https://www.python.org/dev/peps/pep-0440/#file-urls) that seems to specify this notation and thus support your claim. – sinoroc Feb 24 '20 at 09:38

1 Answers1

3

Note this comment from pganssle in the discussion "Setuptools install fails with PEP508 URLs" in setuptools's issue tracker:

Our policy to date has been that if using pip install fixes your problem, you should use pip install and we won't fix the issue.

I believe this is in line with the current evolution of the packaging tools and techniques in the Python community. So if your setuptools-based project with this requirement notation can be installed via pip install . and pip install --editable ., then look no further.


A more complete (exhaustive) article on the topic:

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • 1
    Thanks! enough evidence to not get hung up on `python setup.py install` – Anusha Feb 24 '20 at 09:47
  • The OP only said `pip install -r requirements` works, whicih doesn't use setup.py at all, as opposed to `pip install .` I currently have this problem and `pip install .` doesn't work to install packages at install_requires. install_requires and requirements.txt serve different functions. – Joshua M Nov 07 '22 at 23:45
  • @joshuam I do not understand what is your point. If you have a new (and unique) question, feel free to ask it as a new question (not as a comment). – sinoroc Nov 08 '22 at 08:53