Skip to content
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

Problem with pkg_resources in pytest 3.0 and Jython #1853

Closed
raquelalegre opened this issue Aug 23, 2016 · 8 comments
Closed

Problem with pkg_resources in pytest 3.0 and Jython #1853

raquelalegre opened this issue Aug 23, 2016 · 8 comments

Comments

@raquelalegre
Copy link
Contributor

I am working on a Jython project that is built with Maven and uses py.test. All was going fine up until the new py.test 3.0 release. I keep on getting this error, which I can't really explain and dissappears if I use py.test<3.0:

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "<string>", line 2, in <module>
  File "/private/tmp/nammu/target/jython-plugins-tmp/build/pytest/pytest.py", line 21, in <module>
    from _pytest.config import (
  File "/private/tmp/nammu/target/jython-plugins-tmp/build/pytest/_pytest/config.py", line 8, in <module>
    import pkg_resources
ImportError: No module named pkg_resources

I have looked briefly in your code and I'll submit a small PR to move the import sentence in _python/config.py to inside the method that uses it. I think that'd solve the problem.

Reproduce like this:

I'm using Maven 3.3.9 and Java 8. In order to reproduce this problem, you can install those and clone my work repo.

git clone https://github.com/oracc/nammu.git
cd nammu

Then run the build:

mvn clean install

This will automatically download the latest py.test (3.0) to be included in the deliverable JAR (plus many other things), and run some tests, which will fail with the above error message.

Note you can get rid of all these downloaded stuff by removing the packages from your maven folder in your home directory called .m2 and the target folder in the clone directory.

@nicoddemus
Copy link
Member

Hmm that's weird, doesn't Jython have the pkg_resources module?

raquelalegre added a commit to raquelalegre/pytest that referenced this issue Aug 23, 2016
@RonnyPfannschmidt
Copy link
Member

based on his maven config, it seems like he never added setuptools

does it work when adding setuptools (i wont install maven on my box)

@raquelalegre
Copy link
Contributor Author

@RonnyPfannschmidt setuptools is being used from the Maven plugin that install all the python packages, it doesn't need to be included in the POM file.

@nicoddemus Jython does have the pkg_resources module.

Thanks both for your comments so far :)

We have just found this error comes from the Maven plugin that install all the python modules. It uses a very old version of setuptools (0.6) which is the one causing the problem.

We can update that plugin, but we were suspecting maybe other people had the same problem and you would consider making a change in the next release to only install pkg_resources when necessary, like you did in the past here, for example.

@RonnyPfannschmidt
Copy link
Member

@raquel-ucl so if setuptools is there, why is it not availiable?

pytest itself should even work with a broken old one like 0.6 since its only trying for entrypoints

@raquelalegre
Copy link
Contributor Author

Sorry, I might have wrongly assumed such old version of setuptools might not include it. Then I don't understand why the error is happening :(

@The-Compiler
Copy link
Member

When we depend on pkg_resources being available, shouldn't we add setuptools to install_requires in setup.py anyways?

@The-Compiler
Copy link
Member

@raquel-ucl I'm not familiar with Jython or Maven at all - but could it be possible that that tool itself has setuptools available, but doesn't include it in the generated .jar, thus code in it won't have access to setuptools/pkg_resources?

@flub
Copy link
Member

flub commented Sep 19, 2016

Fixed in #1854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants