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

distutils import is problematic (causes error with frozen tests) #29

Closed
The-Compiler opened this issue Jan 27, 2016 · 4 comments
Closed

Comments

@The-Compiler
Copy link
Member

distutils is a somewhat weird biest, and it's used in #27. I thought a simple util method would be okay while reviewing - turns out I was wrong.

I get this when trying to run the tests frozen via cx_Freeze:

C:\projects\qutebrowser\.tox\unittests-frozen\build\library.zip\distutils\__init__.py:14: UserWarning: The virtualenv distutils package at %s appears to be in the same location as the system distutils?
Traceback (most recent call last):
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
    exec(code, m.__dict__)
  File "scripts/dev/run_frozen_tests.py", line 27, in <module>
    import pytest_mock
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\pytest_mock.py", line 5, in <module>
    from distutils.util import strtobool
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2212, in _find_and_load_unlocked
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_with_frames_removed
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2237, in _find_and_load
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2226, in _find_and_load_unlocked
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_unlocked
  File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_backward_compatible
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\distutils\__init__.py", line 25, in <module>
    from distutils import dist, sysconfig
ImportError: cannot import name 'dist'

I guess it'd be better to just do {'false': False, 'true': True}[val.lower()] or so.

cc @Chronial

@nicoddemus
Copy link
Member

Today I thought with myself "I think I will test packages with devpi after this release"... well, what do you know! 😅

I'm working on a fix as well.

@nicoddemus
Copy link
Member

Release 0.10.1, thanks! 😄

@Chronial
Copy link
Contributor

Sorry 😄. I actually had it like this before – that's why there is this test: 773f8d9#diff-7cc07d0976b2f8543c7956925eb81df9R334

But then I really disliked doing something this basic ourselves and found the distutils function... ^^.

@The-Compiler
Copy link
Member Author

For the record, I think it'd make a lot of sense having this utility function added to the pytest core for plugins to use. Want to make a PR by any chance? 😆

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

3 participants