Skip to content

Regression: Crash when compiling trivial program using mypyc #18168

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

Closed
JukkaL opened this issue Nov 19, 2024 · 2 comments · Fixed by #18172
Closed

Regression: Crash when compiling trivial program using mypyc #18168

JukkaL opened this issue Nov 19, 2024 · 2 comments · Fixed by #18172

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 19, 2024

When I try to compile a simple program using mypyc, I experience a crash (at least on macOS):

$ python -m mypyc t.py
Traceback (most recent call last):
  File "/Users/jukka/src/mypy/build/setup.py", line 4, in <module>
    setup(name='mypyc_output',
    ~~~~~^^^^^^^^^^^^^^^^^^^^^
          ext_modules=mypycify(['t/t.py'], opt_level="3", debug_level="1", strict_dunder_typing=False),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/_distutils/core.py", line 157, in setup
    dist.parse_config_files()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/dist.py", line 608, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 71, in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 143, in read_configuration
    return expand_configuration(asdict, root_dir, ignore_option_errors, dist)
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 168, in expand_configuration
    return _ConfigExpander(config, root_dir, ignore_option_errors, dist).expand()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 216, in expand
    self._expand_all_dynamic(dist, package_dir)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 262, in _expand_all_dynamic
    readme=self._obtain_readme(dist),
           ~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 328, in _obtain_readme
    self._ensure_previously_set(dist, "readme")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/jukka/venv/mypy/lib/python3.13/site-packages/setuptools/config/pyprojecttoml.py", line 280, in _ensure_previously_set
    raise InvalidConfigError(msg)
setuptools.errors.InvalidConfigError: No configuration found for dynamic 'readme'.
Some dynamic fields need to be specified via `tool.setuptools.dynamic`

The program t.py that I compiled is trivial:

print('hello')

This appears to be a regression that bisects to #18146. cc @cdce8p

@brianschubert
Copy link
Collaborator

brianschubert commented Nov 19, 2024

This appears to only happen when running mypyc from the root directory with mypy's pyproject.toml. Running mypyc from a different directory (without pyproject.toml) seems to work as expected.

I think what's happening is that 1) setuptools looks at the pyproject.toml file in the working directory, 2) mypy's pyproject.toml declares dynamic = ["readme"], meaning that setup.py needs to define long_description, 3) the setup.py generated by mypyc doesn't define long_description, hence setuptools complains.

@cdce8p cdce8p self-assigned this Nov 19, 2024
@cdce8p
Copy link
Collaborator

cdce8p commented Nov 19, 2024

Will take a look later today. I do have an idea in mind, just want to confirm it's working before opening the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants