New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests_require=['pytest', 'pytest-cov'] breaks setuptools.setup #196

Closed
bb-migration opened this Issue May 3, 2014 · 9 comments

Comments

Projects
None yet
5 participants
@bb-migration

bb-migration commented May 3, 2014

Originally reported by: slashfoo (Bitbucket: slashfoo, GitHub: slashfoo)


(test)[20:24:14] [jamiel@moeka:masterskel/] $ python setup.py coverage
This command (coverage) requires the installation of pytest-cov
running coverage
Searching for pytest-cov
Reading https://pypi.python.org/simple/pytest-cov/
Best match: pytest-cov 1.6
Downloading https://pypi.python.org/packages/source/p/pytest-cov/pytest-cov-1.6.tar.gz#md5=6da54d74bde9d200de45068ba2ea637a
Processing pytest-cov-1.6.tar.gz
Writing /tmp/easy_install-xvMxzZ/pytest-cov-1.6/setup.cfg
Running pytest-cov-1.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-xvMxzZ/pytest-cov-1.6/egg-dist-tmp-BGJIES

Installed /home/jamiel/dev/masterskel/pytest_cov-1.6-py2.7.egg
Searching for pytest
Best match: pytest cov-1.6
Downloading https://pypi.python.org/packages/source/p/pytest-cov/pytest-cov-1.6.tar.gz#md5=6da54d74bde9d200de45068ba2ea637a
Processing pytest-cov-1.6.tar.gz
Writing /tmp/easy_install-EweVbo/pytest-cov-1.6/setup.cfg
Running pytest-cov-1.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-EweVbo/pytest-cov-1.6/egg-dist-tmp-zxCrHa

Installed /home/jamiel/dev/masterskel/pytest_cov-1.6-py2.7.egg
Traceback (most recent call last):
  File "setup.py", line 203, in <module>
    zip_safe=False,
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/jamiel/.virtualenvs/test/local/lib/python2.7/site-packages/setuptools/command/test.py", line 130, in run
    self.distribution.fetch_build_eggs(self.distribution.tests_require)
  File "/home/jamiel/.virtualenvs/test/local/lib/python2.7/site-packages/setuptools/dist.py", line 264, in fetch_build_eggs
    replace_conflicting=True
  File "/home/jamiel/.virtualenvs/test/local/lib/python2.7/site-packages/pkg_resources.py", line 588, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pytest

since 'pytest-cov' depends on 'pytest', making tests_require=['pytest-cov'] fixes the issue, same if it is tests_require=['pytest-cov', 'pytest'].

Setting a breakpoint on ${HOME}/.virtualenvs/slashpyenv/lib/python3.4/site-packages/pkg_resources.py:620 (replace for your path to pkg_sources.py) shows:

dist = best[req.key] = env.best_match(req, ws, installer)

after running on for req = Requirement.parse('pytest-cov'), when I run !env.best_match(Requirement.parse('pytest'), ws, installer) it returns the best match to be 'pytest-cov 1.6' and exits.

note: In the report you see 3.4 in the outputs ect... but this is also present in 2.7.


@bb-migration

This comment has been minimized.

bb-migration commented Jun 28, 2014

Original comment by jkbr (Bitbucket: jkbr, GitHub: jkbr):


Got the same problem with

#!python

tests_require = [
   'pytest',
   'pytest-httpbin',

]

Reversing the order fixed it.

@bb-migration

This comment has been minimized.

bb-migration commented Jul 17, 2014

Original comment by pbn (Bitbucket: pbn, GitHub: pbn):


I am seeing the same problem here with:

```
#!python

install_require = [
    'pytest',
    'pytest-instafail',
]
```
@bb-migration

This comment has been minimized.

bb-migration commented Jul 17, 2014

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


It looks like pytest-cov is being matched as the "cov" version of pytest, and so is fulfilling the requirement of "pytest". I seem to recall somewhere that setuptools discourages the use of dashes in package names, probably for this reason.

I don't yet know what to recommend here other than to follow the indicated workaround.

@bb-migration

This comment has been minimized.

bb-migration commented Apr 10, 2015

Original comment by jaraco (Bitbucket: jaraco, GitHub: jaraco):


Issue #370 was marked as a duplicate of this issue.

@jaraco jaraco removed the 3.4.4 label Mar 31, 2016

gbartolini pushed a commit to 2ndquadrant-it/barman that referenced this issue Oct 28, 2016

Workaroud to setuptools testrunner bug.
Ref links:

* https://bitbucket.org/pypa/setuptools/issue/196
* pypa/setuptools#196

Signed-off-by: Giulio Calacoci <giulio.calacoci@2ndquadrant.it>
Signed-off-by: Leonardo Cecchi <leonardo.cecchi@2ndquadrant.it>
Signed-off-by: Francesco Canovai <francesco.canovai@2ndquadrant.it>

jeremycline added a commit to jeremycline/anitya that referenced this issue Apr 17, 2017

Remove the explicit dependency on Flask to avoid setuptools bug
At the moment you cannot ``python setup.py install`` Anitya (and this is
causing our documentation to not build) because we're hitting a
setuptools bug[0] which is causing "Flask-WTF" to be matched for the
"Flask" requirement. Without the explicit requirement, the Flask plugins
we use (including Flask-WTF) will pull Flask in.

[0] pypa/setuptools#196

Signed-off-by: Jeremy Cline <jeremy@jcline.org>

jeremycline added a commit to jeremycline/anitya that referenced this issue Apr 17, 2017

Remove the explicit dependency on Flask to avoid setuptools bug
At the moment you cannot ``python setup.py install`` Anitya (and this is
causing our documentation to not build) because we're hitting a
setuptools bug[0] which is causing "Flask-WTF" to be matched for the
"Flask" requirement. Without the explicit requirement, the Flask plugins
we use (including Flask-WTF) will pull Flask in.

[0] pypa/setuptools#196

Signed-off-by: Jeremy Cline <jeremy@jcline.org>
@AlexanderMartynoff

This comment has been minimized.

AlexanderMartynoff commented Apr 17, 2017

Hello everyone, who can say when this bug will be resolved?

@jaraco jaraco closed this Apr 21, 2017

@jaraco jaraco added the wontfix label Apr 21, 2017

@jaraco

This comment has been minimized.

Member

jaraco commented Apr 21, 2017

I don't think it will ever be fixed. Setup requires and easy install are deprecated in favor of PEP 518 in pip and tools like tox and pip. I recommend avoiding easy install and setup requires as much as possible, use the workaround where necesaary.

@Juanlu001

This comment has been minimized.

Contributor

Juanlu001 commented Jul 21, 2017

I recommend avoiding easy install and setup requires as much as possible, use the workaround where necesaary.

What about tests_require? Is there a PEP 518 equivalent yet?

@benoit-pierre

This comment has been minimized.

Member

benoit-pierre commented Jul 21, 2017

Just encountered this issue today while looking at another bug. It looks like it's caused by reusing the easy_install command instead of creating a new one every time:

diff --git a/setuptools/dist.py b/setuptools/dist.py
index fa0b5eb4..6cd04d6e 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -482,36 +482,30 @@ class Distribution(Distribution_parse_config_files, _Distribution):
 
     def fetch_build_egg(self, req):
         """Fetch an egg needed for building"""
-
-        try:
-            cmd = self._egg_fetcher
-            cmd.package_index.to_scan = []
-        except AttributeError:
-            from setuptools.command.easy_install import easy_install
-            dist = self.__class__({'script_args': ['easy_install']})
-            dist.parse_config_files()
-            opts = dist.get_option_dict('easy_install')
-            keep = (
-                'find_links', 'site_dirs', 'index_url', 'optimize',
-                'site_dirs', 'allow_hosts'
-            )
-            for key in list(opts):
-                if key not in keep:
-                    del opts[key]  # don't use any other settings
-            if self.dependency_links:
-                links = self.dependency_links[:]
-                if 'find_links' in opts:
-                    links = opts['find_links'][1].split() + links
-                opts['find_links'] = ('setup', links)
-            install_dir = self.get_egg_cache_dir()
-            cmd = easy_install(
-                dist, args=["x"], install_dir=install_dir,
-                exclude_scripts=True,
-                always_copy=False, build_directory=None, editable=False,
-                upgrade=False, multi_version=True, no_report=True, user=False
-            )
-            cmd.ensure_finalized()
-            self._egg_fetcher = cmd
+        from setuptools.command.easy_install import easy_install
+        dist = self.__class__({'script_args': ['easy_install']})
+        dist.parse_config_files()
+        opts = dist.get_option_dict('easy_install')
+        keep = (
+            'find_links', 'site_dirs', 'index_url', 'optimize',
+            'site_dirs', 'allow_hosts'
+        )
+        for key in list(opts):
+            if key not in keep:
+                del opts[key]  # don't use any other settings
+        if self.dependency_links:
+            links = self.dependency_links[:]
+            if 'find_links' in opts:
+                links = opts['find_links'][1].split() + links
+            opts['find_links'] = ('setup', links)
+        install_dir = self.get_egg_cache_dir()
+        cmd = easy_install(
+            dist, args=["x"], install_dir=install_dir,
+            exclude_scripts=True,
+            always_copy=False, build_directory=None, editable=False,
+            upgrade=False, multi_version=True, no_report=True, user=False
+        )
+        cmd.ensure_finalized()
         return cmd.easy_install(req)
 
     def _set_global_opts_from_features(self):

Working on adding a test before making a PR.

benoit-pierre added a commit to benoit-pierre/setuptools that referenced this issue Aug 5, 2017

workaround easy_install bug
Don't reuse `easy_install` command in `Distribution.fetch_build_egg` implementation.

Fix pypa#196.

benoit-pierre added a commit to benoit-pierre/setuptools that referenced this issue Aug 5, 2017

workaround easy_install bug
Don't reuse `easy_install` command in `Distribution.fetch_build_egg` implementation.

Fix pypa#196.

pgaref added a commit to pgaref/HTTP_Request_Randomizer that referenced this issue Oct 30, 2017

@jaraco

This comment has been minimized.

Member

jaraco commented Dec 16, 2017

oyvindio pushed a commit to fiaas/fiaas-deploy-daemon that referenced this issue Mar 23, 2018

bsilver8192 added a commit to gitenberg-dev/gitberg that referenced this issue May 8, 2018

Update README development directions
`python setup.py install` disagrees with travispy (a new dependency)
because of pypa/setuptools#196, but the
requirements.pip file still does fine for installing all the actual
current dependencies.

bsilver8192 added a commit to gitenberg-dev/gitberg that referenced this issue May 9, 2018

Update README development directions
`python setup.py install` disagrees with travispy (a new dependency)
because of pypa/setuptools#196, but the
requirements.pip file still does fine for installing all the actual
current dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment