1. Tarek Ziadé
  2. distribute
  3. Issues
Issue #120 new

pkg_resources.require can't deal with older versions if -m wasn't specified?

posita NA
created an issue

Perhaps I have misunderstood the intended behavior, but I thought one should be able to do this:

{{{ % easy_install BeautifulSoup==3.0.8 ... % easy_install -U BeautifulSoup [installs 3.1.0.1] ... % python -c 'import pkg_resources ; print pkg_resources.require("BeautifulSoup==3.0.8")' Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../site-packages/distribute-0.6.10-py2.5.egg/pkg_resources.py", line 648, in require needed = self.resolve(parse_requirements(requirements)) File ".../site-packages/distribute-0.6.10-py2.5.egg/pkg_resources.py", line 550, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (BeautifulSoup 3.1.0.1 (.../site-packages/BeautifulSoup-3.1.0.1-py2.5.egg), Requirement.parse('BeautifulSoup==3.0.8')) }}}

If I use the '-m' tag (to keep it out of easy_install.pth), I have a different problem:

{{{ % easy_install -m BeautifulSoup==3.0.8 ... % easy_install -U -m BeautifulSoup [installs 3.1.0.1] ... % python -c 'import pkg_resources ; print pkg_resources.require("BeautifulSoup==3.0.8")' [BeautifulSoup 3.0.8 (.../site-packages/BeautifulSoup-3.0.8-py2.5.egg)] % python -c 'import BeautifulSoup' Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named BeautifulSoup }}}

Can I not have my cake and eat it too? Meaning, can I not have multiple installed versions of a package with a default (i.e., an entry in easy-install.pth), but still be able to explicitly specify a previously installed version?

Comments (3)

  1. Anonymous

    I just hit this as well. pkg_resources takes a wild guess at what the "best" match is. () looks for the project name with no regard for version.

    I've played with a patch but it gets worse. When a distribution is activated, the path is reordered to move the best forward. Since the version was never considered, I'm guessing the path was never actually modified. When it is, all requires of the required module have to be imported in order as well resulting in more path changes.

    As pkg_resources were not importing at require() time, it looks to me like a require() of one module after another could have disrupted the import of the first be re-order the path underneath it. Importing them as they when require() is invoked should at least raise a VersionConflict if there are conflicting versions in the requirements.

    I can now require() a distribution and get it regardless of it's order in the path. Unfortunately, I've broken the find_plugins tests and I haven't played with the find_plugins api at all so I may or may not get around to futzing with it :(

    The bottom line is that multiple versions of eggs are supported only so far as installing them goes. How ever many you have, you get the version that's first on the path or a VersionConflict if you require any other.

  2. Log in to comment