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

Add setting to disable adding cwd to pythonpath #121

Open
AmatanHead opened this issue Feb 16, 2017 · 1 comment
Open

Add setting to disable adding cwd to pythonpath #121

AmatanHead opened this issue Feb 16, 2017 · 1 comment

Comments

@AmatanHead
Copy link

Hello!

I'm trying to use pytest-xdist together with tox to test a python extension written with cython.

When I run tox, it creates a new virtualenv, compiles my project and installs it to ./.tox/.../site-packages/modulename so that there is a directory with source code (./project/modulename) and a directory with compiled python extensions (./project/.tox/.../site-packages/modulename):

./project
  |-setup.py
  |-modulename
  |  |-__init__.py
  |  |-extension.pyx
  |-...
  |-.tox
     |-python/.../site-packages
        |-modulename
           |-__init__.py
           |-extension.so

When running normally, there is ./project/.tox/python/.../site-packages in PYTHONPATH and there is no ./project in it so modulename from site-packages imported when testing.

However, xdist adds ./project to PYTHONPATH (before .tox/.../site-packages) which causes modulename from project root being imported instead of modulename from site-packages. And everything fails with ImportError because there are no .so files in that modulename from project root.

As I understand, the code that adds cwd to pythonpath is here and it seems like there is no way to control this.

I propose adding a setting (a cli parameter) to disable this behavior.

@AmatanHead
Copy link
Author

I've realized that the problem is a bit deeper that I thought. Py.test runs tests against the current development version of program, therefore it should ignore any package with the same name installed globally. On the other hand, you may have a special develop install (as in my case) and you want to run tests against that install. So maybe this should be solved by adding an option to py.test to remove cwd from pythonpath.

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

1 participant