-
-
Notifications
You must be signed in to change notification settings - Fork 440
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
cmdline.py overwrites first sys.path entry #678
Comments
Can you provide some details about what is going wrong? What is the first entry originally, and what bad thing happens because of coverage? How are you running coverage, and can you provide a reproducible scenario? |
I'm trying to develop a plugin for coverage. I do that in an existing project which uses zc.buildout. It generates a script like this for coverage:
Normally coverage is the first entry and setting it to '' doesn't matter, because coverage is already imported. But because the plugin is placed first by buildout, the path to it is overwritten and coverage can't load the plugin. |
@fschulze Normally, the plugin is found by installing it so that it is importable, and then naming the importable module name in the .coveragerc file. Are you doing something different? |
As I said, I'm using zc.buildout. I've made a gist to reproduce: https://gist.github.com/fschulze/fce8a15ca8cc615443fc70bb5f16595c |
The generated
|
I've just checked what the
Here it works, because no one places Python packages in |
@nedbat I have to test that, but I'm pretty sure it will |
@nedbat yes, removing that line fixes it for me |
@fschulze Is it true that the only import problem is coverage trying to import your plugin? Can you tell me more about the plugin (just curious), and how you are configured to find it? |
Yes, it's true, because of the way buildout sets up sys.path:
The first entry would then be set to the empty string by coverage causing the import failure. |
This is re-fixed in commit b7e0eec, released as part of 5.0a4. |
5.0a4 works for me, thanks! |
In the
command_line
method there issys.path[0] = ''
. I guess this works most of the time, because coverage is the first entry in many scenarios. There are cases where this isn't true though, for example with zc.buildout. I guess it would be better to dosys.path.insert(0, '')
, but I'm unsure about further implications of that.The text was updated successfully, but these errors were encountered: