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

pyimport raises ImportMismatchError #200

Closed
gillesdouaire opened this issue Sep 25, 2018 · 1 comment
Closed

pyimport raises ImportMismatchError #200

gillesdouaire opened this issue Sep 25, 2018 · 1 comment

Comments

@gillesdouaire
Copy link

Here's our case:

We run our build pipelines in Gitlab with Windows runners.

  1. We create a Python virtual env using 'Gitlab runner A'. This will create a Python virtualenv with runner A's path hardcoded 'everywhere'.

  2. We save the virtual environment using Gitlab's artifacts.

  3. We download the virtual env built under 'Gitlab runner A' and in certain cases, we use it under 'Gitlab runner B'. Because a) Python has the habit of using absolute paths in the venvs, and b) Gitlab uses different paths for each runner, to make the venv usable, we created a symlink named after the path for 'Gitlab runner A' and pointing to 'Gitlab runner B'.

  4. Step 3 works in every situation we have encountered in the last year, except with pytest when we started using custom plugins. That context raises ImportMismatchError, even if the venv if fully functional; the check is purely nominal (path A is not equal to path B), whereas both paths work, because we have the symlink and the actual physical path.

COS:

  • raise an error only when the functionality is actually broken ?
  • have the possibility to ignore the error?
  • do not ignore symlinks?
@nicoddemus
Copy link
Member

With the recently released 1.7.0, you can set PY_IGNORE_IMPORTMISMATCH=1 to suppress that error when you know it is a false negative.

This has been discussed at length in pytest-dev/pytest#2042, but no workable solution has been found in a long time.

I'm closing now, but feel free to follow up with further questions.

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

2 participants