1

I'm trying to use tox for my tests.

So far it worked great, but now I'm trying to add a dependency to another of my packages. I have build a wheel locally and specified the link to it in the setup.py dependency_links, but now when running tox I get the following error :

Collecting PySide2
  Using cached https://files.pythonhosted.org/packages/48/84/b776c8811dd453eb023b5dd05554e0292d5919fdbb881f3c613f57f5cbe2/PySide2-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win32.whl
Collecting Qt.py>=1.2
  Using cached https://files.pythonhosted.org/packages/cf/08/04c51fb1ee9bbfb2196c956f8a3f7da4e9757710582e8700bf812f258d43/Qt.py-1.3.3-py2.py3-none-any.whl
Collecting pytest-cov
  Using cached https://files.pythonhosted.org/packages/e3/1a/6affecd2344efee7f2487fac82242474cbac09f9e04929da5944907baf11/pytest_cov-2.11.1-py2.py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement graph-it (from ComponentAssembler-abs==0.0.1) (from versions: none)
ERROR: No matching distribution found for graph-it (from ComponentAssembler-abs==0.0.1)

Here's my setup.py :


with open("README.md", "r") as fh:
    long_description = fh.read()

name = "ComponentAssembler-abs"

author = "me me me"

author_email = "me@somemail.com"

description = "Acyclic Block System"

url = "https://github.com/me me me/ComponentAssembler"

python_requires = '>=3.6, <4'


setup(
      name=name,
      version="0.0.1",
      author=author,
      author_email=author_email,
      description=description,
      long_description=long_description,
      url=url,
      package_dir={'': 'src'},
      packages=find_packages(where='src'),
      classifiers=[
            "Programming Language :: Python :: 3",
            "Operating System :: OS Independent",
      ],
      python_requires=python_requires,
      install_requires=[
          'PySide2',
          'Qt.py>=1.2',
          'pytest-cov',
          'graph-it',
      ],
      dependency_links=[
          'D:\\python\\graph-it\\dist',
      ]
)

My wheel is located here on my machine : D:\python\graph-it\dist\graph_it-0.1.0-py3-none-any.whl

What am I missing? :D

Thanks!

Martin
  • 105
  • 1
  • 10
  • Does this answer your question? [How to include and install local dependencies in setup.py in Python?](https://stackoverflow.com/questions/35668295/how-to-include-and-install-local-dependencies-in-setup-py-in-python) – Jürgen Gmach May 01 '21 at 06:12
  • Thanks for the link, but unfortunately, no, it doesn't help. First because according to [this](https://github.com/Applied-GeoSolutions/gips/issues/246) `dependency_links` is deprecated, second because the link you provided mentions egg files and suggests that it uses egg files already created, when I am trying to get setup.py to install using a local wheel file. Your link however also brought me [there](https://caremad.io/posts/2013/07/setup-vs-requirement/) which is much more promising, unfortunately I haven't been able to make it work so far. – Martin May 01 '21 at 07:06
  • I need to add, the link you shared works well to install using `python setup.py install` but raises an error when used through tox. – Martin May 01 '21 at 07:26

1 Answers1

3

My advice would be:

  • Get rid of dependency_links, since as already mentioned, it is deprecated.
  • Do not call python setup.py install, it is also deprecated. Use pip install . or pip install --editable . instead.
  • Use pip's --find-links option to point to the local directory containing the locally built wheels: pip install --find-links 'D:\python\graph-it\dist' .
  • You can also add a line --find-links 'D:\python\graph-it\dist' to a requirements.txt file. Note that this is not portable. You could use a relative path instead, and maybe it is a bit more portable.
  • For tox:
    • You could try to call tox with a pip environment variable, like this: PIP_FIND_LINKS='D:\python\graph-it\dist' tox
    • You could put the path to the wheel file in the deps of tox.ini: deps = graph-it @ D:\python\graph-it\dist\graph_it-0.1.0-py3-none-any.whl.
    • Here is a tox example showing how to use pip's find-links in tox.
sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • Thanks! `pip install --find-links D:\python\graph-it\dist .` works, I have also tried with a relative path 'pip install --find-links . .` and it works as well. Ideally I'd like to put that dependency link in either the setup.py or requirements.txt to not have to specify it every time, any idea how I can do that? I have tried the same requirements.txt content as suggested [here](https://caremad.io/posts/2013/07/setup-vs-requirement/), and putting my wheel right next to the setup.py, but this didn't work, any idea why? – Martin May 01 '21 at 16:13
  • About tox, as suggested in the link you provided, this did the trick `install_command = pip install --find-links . {packages}`. Again, ideally I'd like to be able to specify all this in the requirements.txt or setup.py if possible to keep a more consistent approach without having to do it for the install and for tox every time. Any idea? Thanks again for the solution anyway :) – Martin May 01 '21 at 16:56
  • You can not put such a thing in `setup.py`, this used to be possible with `dependency_links` but it was a bad idea and is now deprecated. -- You can put a `--find-links D:\python\graph-it\dist` in the `requirements.txt`. I do not think it's a great idea, but you can, and if it's helpful for you, then do it. – sinoroc May 01 '21 at 18:12