twisted / incremental

A library for versioning your Python projects.
Other
139 stars 22 forks source link

incremental 24.7.0 breaks arbitrary projects #100

Closed mgorny closed 4 months ago

mgorny commented 4 months ago

After upgrading incremental to 24.7.0, various projects (that never used it) fail to build now, e.g. stripe:

pypy3 -m gpep517 build-wheel --prefix=/usr --backend setuptools.build_meta:__legacy__ --output-fd 3 --wheel-dir /tmp/portage/dev-python/stripe-10.5.0/work/stripe-10.5.0-pypy3/wheel
2024-07-26 03:44:10,409 gpep517 INFO Building wheel via backend setuptools.build_meta:__legacy__
Traceback (most recent call last):
  File "/usr/lib/pypy3.10/site-packages/incremental/__init__.py", line 487, in _load_pyproject_toml
    package = data["project"]["name"]
KeyError: 'project'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/pypy3.10/runpy.py", line 199, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/pypy3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/pypy3.10/site-packages/gpep517/__main__.py", line 443, in <module>
    sys.exit(main())
  File "/usr/lib/pypy3.10/site-packages/gpep517/__main__.py", line 439, in main
    return func(args)
  File "/usr/lib/pypy3.10/site-packages/gpep517/__main__.py", line 229, in build_wheel
    print(build_wheel_impl(args, args.wheel_dir), file=out)
  File "/usr/lib/pypy3.10/site-packages/gpep517/__main__.py", line 221, in build_wheel_impl
    wheel_name = backend.build_wheel(str(wheel_dir), args.config_json)
  File "/usr/lib/pypy3.10/site-packages/setuptools/build_meta.py", line 415, in build_wheel
    return self._build_with_temp_dir(
  File "/usr/lib/pypy3.10/site-packages/setuptools/build_meta.py", line 397, in _build_with_temp_dir
    self.run_setup()
  File "/usr/lib/pypy3.10/site-packages/setuptools/build_meta.py", line 497, in run_setup
    super().run_setup(setup_script=setup_script)
  File "/usr/lib/pypy3.10/site-packages/setuptools/build_meta.py", line 313, in run_setup
    exec(code, locals())
  File "<string>", line 19, in <module>
  File "/usr/lib/pypy3.10/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/pypy3.10/site-packages/setuptools/_distutils/core.py", line 146, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/pypy3.10/site-packages/setuptools/dist.py", line 289, in __init__
    _Distribution.__init__(self, dist_attrs)
  File "/usr/lib/pypy3.10/site-packages/setuptools/_distutils/dist.py", line 286, in __init__
    self.finalize_options()
  File "/usr/lib/pypy3.10/site-packages/setuptools/dist.py", line 641, in finalize_options
    ep(self)
  File "/usr/lib/pypy3.10/site-packages/incremental/__init__.py", line 402, in _get_setuptools_version
    config = _load_pyproject_toml("./pyproject.toml")
  File "/usr/lib/pypy3.10/site-packages/incremental/__init__.py", line 489, in _load_pyproject_toml
    raise ValueError("""\
ValueError: Couldn't extract the package name from pyproject.toml. Specify it like:

    [project]
    name = "Foo"

Or:

    [tool.incremental]
    name = "Foo"

In fact, I can't even build the previous version of incremental itself.

kyluca commented 4 months ago

Encountered the same issue on a few of our internal builds this morning too. We use pyproject.toml for configuring a suite of third party packages, but not for the project itself (still using setup.py instead).

Our workaround was to pin to the previous version incremental==22.10.0. Worth noting we also use towncrier, which has an uncapped dependency on incremental so that's how it got the latest version pulled in.

The command that triggered the same error for us was python setup.py bdist_wheel, however some of our other builds which use the newer python -m build --wheel command were unaffected.

twm commented 4 months ago

Hmm, looking at the stripe setup.py it should be a no-op from Incremental's perspective. There is no use_incremental=True opt-in. There is a pyproject.toml with various tool configs which triggers this bug.

I'll put together a fix shortly.

twm commented 4 months ago

Given this can potentially break the build of any setuptools-based project, generally causing havoc, I've yanked release 24.7.0 on PyPI so that folks don't automatically upgrade.

mgorny commented 4 months ago

Thank you!

twm commented 4 months ago

Thank you for the report! (And sorry for the breakage.)