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

pkg_resources: UnboundLocalError: local variable 'dist' referenced before assignment #702

Closed
The-Compiler opened this issue Jul 29, 2016 · 6 comments · Fixed by #703
Closed

Comments

@The-Compiler
Copy link

When trying to run my package's tests frozen via cx_Freeze on Windows, I just got this:

  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\pkg_resources\__init__.py", line 2986, in _initialize_master_working_set
    del dist
UnboundLocalError: local variable 'dist' referenced before assignment

full traceback:

unittests-frozen runtests: commands[2] | C:\projects\qutebrowser\.tox\unittests-frozen/build/run-frozen-tests
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 38, in <module>
    pytest_rerunfailures, pytest_warnings]))
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\config.py", line 39, in main
    config = _prepareconfig(args, plugins)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\config.py", line 118, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\helpconfig.py", line 28, in pytest_cmdline_parse
    config = outcome.get_result()
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 278, in get_result
    raise ex[1].with_traceback(ex[2])
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
    self.result = func()
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\config.py", line 861, in pytest_cmdline_parse
    self.parse(args)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\config.py", line 966, in parse
    self._preparse(args, addopts=addopts)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\config.py", line 927, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 495, in load_setuptools_entrypoints
    from pkg_resources import iter_entry_points, DistributionNotFound
  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\pkg_resources\__init__.py", line 2958, in <module>
    @_call_aside
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\pkg_resources\__init__.py", line 2944, in _call_aside
    f(*args, **kwargs)
  File "C:\projects\qutebrowser\.tox\unittests-frozen\lib\site-packages\pkg_resources\__init__.py", line 2986, in _initialize_master_working_set
    del dist
UnboundLocalError: local variable 'dist' referenced before assignment

This seems to be introduced in #698 (cc @minrk) and happens when the for dist in working_set: above doesn't assign to dist because working_set is empty.

@minrk
Copy link
Contributor

minrk commented Jul 29, 2016

Fixed by #703. Sorry about that, and thanks for catching it!

@The-Compiler
Copy link
Author

No worries, that was a mean one, probably wouldn't have noticed it either. Thanks for the quick fix!

@destijl
Copy link

destijl commented Aug 1, 2016

Thanks for fixing this, just hit it myself. I see that 25.1.2 includes this fix and is tagged on github but isn't released on pypi? If you're expecting to get that onto pypi soon I can probably avoid having to go through all my install scripts pinning the setuptools version. Any idea when that might happen?

@jaraco
Copy link
Member

jaraco commented Aug 1, 2016

Hmm. PyPI releases are meant to be automatic from tagged versions. Let's see what happened.

Aah, so it built and tests passed, but the upload failed because I forgot to bump the versions in the code (by running bumpversion patch) first.

I'll push out a release momentarily.

@jaraco
Copy link
Member

jaraco commented Aug 1, 2016

I expect the release to go out with this job.

@destijl
Copy link

destijl commented Aug 1, 2016

Great, it's out, thanks!

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

Successfully merging a pull request may close this issue.

4 participants