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

Package.__init__() got an unexpected keyword argument 'autolib' #13826

Closed
dtolnay opened this issue Oct 26, 2024 · 2 comments · Fixed by #13828
Closed

Package.__init__() got an unexpected keyword argument 'autolib' #13826

dtolnay opened this issue Oct 26, 2024 · 2 comments · Fixed by #13828
Assignees
Labels
bug module:rust Specific to the Rust module

Comments

@dtolnay
Copy link

dtolnay commented Oct 26, 2024

Describe the bug
New versions of Rust's Cargo package manager have started publishing an autolib entry in Cargo.toml.

All packages published to crates.io by a recent version of Cargo contain this entry.

To Reproduce

meson.build
project('repro', 'rust')
subproject('proc-macro2')
subprojects/proc-macro2.wrap
[wrap-file]
directory = proc-macro2-1.0.87
source_url = https://static.crates.io/crates/proc-macro2/1.0.87/download
source_filename = unicode-ident-1.0.87.tar.gz
source_hash = b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a
method = cargo
$ /git/tmp/meson/meson.py setup build
The Meson build system
Version: 1.6.99
Source dir: /path/to
Build dir: /path/to/build
Build type: native build
Project name: repro
Project version: undefined
Rust compiler for the host machine: rustc -C linker=cc (rustc 1.84.0-nightly)
Rust linker for the host machine: rustc -C linker=cc ld.bfd 2.42
Host machine cpu family: x86_64
Host machine cpu: x86_64

Executing subproject proc-macro2 method cargo 

meson.build:2: WARNING: Cargo subproject is an experimental feature and has no backwards compatibility guarantees.
Traceback (most recent call last):
  File "/path/to/meson/mesonbuild/mesonmain.py", line 193, in run
    return options.run_func(options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/msetup.py", line 365, in run
    app.generate()
  File "/path/to/meson/mesonbuild/msetup.py", line 188, in generate
    return self._generate(env, capture, vslite_ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/msetup.py", line 227, in _generate
    intr.run()
  File "/path/to/meson/mesonbuild/interpreter/interpreter.py", line 3062, in run
    super().run()
  File "/path/to/meson/mesonbuild/interpreterbase/interpreterbase.py", line 169, in run
    self.evaluate_codeblock(self.ast, start=1)
  File "/path/top/meson/mesonbuild/interpreterbase/interpreterbase.py", line 195, in evaluate_codeblock
    raise e
  File "/path/to/meson/mesonbuild/interpreterbase/interpreterbase.py", line 187, in evaluate_codeblock
    self.evaluate_statement(cur)
  File "/path/to/meson/mesonbuild/interpreterbase/interpreterbase.py", line 201, in evaluate_statement
    return self.function_call(cur)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreterbase/interpreterbase.py", line 528, in function_call
    res = func(node, func_args, kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreterbase/decorators.py", line 237, in wrapper
    return f(*nargs, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreterbase/decorators.py", line 556, in wrapper
    return f(*wrapped_args, **wrapped_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreter/interpreter.py", line 869, in func_subproject
    return self.do_subproject(args[0], kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreter/interpreter.py", line 951, in do_subproject
    raise e
  File "/path/to/meson/mesonbuild/interpreter/interpreter.py", line 939, in do_subproject
    return methods_map[method](subp_name, subdir, default_options, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/interpreter/interpreter.py", line 1051, in _do_subproject_cargo
    ast = self.environment.cargo.interpret(subdir)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/cargo/interpreter.py", line 467, in interpret
    manifest = self._load_manifest(subdir)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/cargo/interpreter.py", line 524, in _load_manifest
    manifest_ = _convert_manifest(raw_manifest, subdir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/meson/mesonbuild/cargo/interpreter.py", line 358, in _convert_manifest
    Package(**pkg),
    ^^^^^^^^^^^^^^
TypeError: Package.__init__() got an unexpected keyword argument 'autolib'

meson.build:2:0: ERROR: Unhandled python exception

    This is a Meson bug and should be reported!

This is the relevant line:

Package(**pkg),

Expected behavior
Presence of autolib = false within the Cargo.toml of a method = cargo wrap-file does not cause a type error in Meson's cargo interpreter.

The path determined by [lib] path = "..." in the Cargo.toml is treated as the root of the crate's library.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?
  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)
  • what Python version are you using e.g. 3.8.0
    • Python 3.12.3
  • what meson --version
  • what ninja --version if it's a Ninja build
@dcbaker dcbaker added bug module:rust Specific to the Rust module labels Oct 27, 2024
@dcbaker
Copy link
Member

dcbaker commented Oct 27, 2024

@xclaesse I think my initial easy approach of splatting the dict is going to be problematic, and we probably want to be explicit, plus warn when there are keys the version of Meson doesn't understand.

@dcbaker dcbaker self-assigned this Oct 27, 2024
dcbaker added a commit to dcbaker/meson that referenced this issue Oct 27, 2024
This adds support for parsing the new `autolib` member
(rust-lang/cargo#14591).

This is a quick and easy fix, suitable for backport. A larger more
involved fix will be to stop splatting out the cargo dictionaries, and
instead pass the fields we know about 1 by 1, and warning the user if we
come across unknown fields.

Fixes: mesonbuild#13826
dcbaker added a commit to dcbaker/meson that referenced this issue Oct 27, 2024
This adds support for parsing the new `autolib` member
(rust-lang/cargo#14591).

This is a quick and easy fix, suitable for backport. A larger more
involved fix will be to stop splatting out the cargo dictionaries, and
instead pass the fields we know about 1 by 1, and warning the user if we
come across unknown fields.

Fixes: mesonbuild#13826
@eli-schwartz
Copy link
Member

We could still single-source the fields themselves using e.g. [x.name for x in dataclasses.fields(Package)]

dcbaker added a commit to dcbaker/meson that referenced this issue Oct 28, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
dcbaker added a commit to dcbaker/meson that referenced this issue Oct 28, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
dcbaker added a commit to dcbaker/meson that referenced this issue Nov 1, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
dcbaker added a commit to dcbaker/meson that referenced this issue Nov 1, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
dcbaker added a commit to dcbaker/meson that referenced this issue Nov 1, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
dcbaker added a commit to dcbaker/meson that referenced this issue Nov 1, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See mesonbuild#13826 for the motivation for this change
eli-schwartz pushed a commit that referenced this issue Nov 5, 2024
Cargo sometimes adds new keys and Meson needs to gracefully handle
those. Currently, an unknown key will trigger an uncaught Python
exception, which is pretty much the worse case. With this change Meson
will instead issue a warning much like the one for unknown cpu
architectures.

See #13826 for the motivation for this change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug module:rust Specific to the Rust module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants