pyscript: No package metadata error after installing packages

Checklist

  • I added a descriptive title
  • I searched for other issues and couldn’t find a solution or duplication
  • I already searched in Google and didn’t find any good information or help

What happened?

@freakboy3742 reported this in #1203. When installing toga sometimes it would fail with “No package metadata error”.

Traceback (most recent call last):
  File "/lib/python3.10/site-packages/toga/__init__.py", line 97, in _package_version
    from setuptools_scm import get_version
ModuleNotFoundError: No module named 'setuptools_scm'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 435, in eval_code
    .run(globals, locals)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 304, in run
    coroutine = eval(self.code, globals, locals)
  File "<exec>", line 2, in <module>
  File "/lib/python3.10/runpy.py", line 209, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/lib/python3.10/site-packages/freedom/__main__.py", line 1, in <module>
    from freedom.app import main
  File "/lib/python3.10/site-packages/freedom/app.py", line 1, in <module>
    import toga
  File "/lib/python3.10/site-packages/toga/__init__.py", line 118, in <module>
    __version__ = _package_version(__file__, __name__)
  File "/lib/python3.10/site-packages/toga/__init__.py", line 115, in _package_version
    return importlib_metadata.version(package)
  File "/lib/python3.10/importlib/metadata/__init__.py", line 955, in version
    return distribution(distribution_name).version
  File "/lib/python3.10/importlib/metadata/__init__.py", line 928, in distribution
    return Distribution.from_name(distribution_name)
  File "/lib/python3.10/importlib/metadata/__init__.py", line 518, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for toga-core

I’m opening this issue for us to dig more into this since I have seen the same error happening before a couple times and was trying to help a user with this issue.

So far the error seems occur at random. It’s not clear to me if this is happening with a recent change that we have done or if it was always present but we didn’t see the error 🤔

What browsers are you seeing the problem on? (if applicable)

No response

Console info

No response

Additional Context

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

This project is a reproduction case; serving freedom.html with a web server that can access ./static is sufficient.

I’ve tried to reduce it further; but every reduction I’ve made ends up making the problem go away.