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

Setting prog and pyfile in options gives an error #79

Closed
rrthomas opened this issue Apr 8, 2023 · 2 comments · Fixed by #101
Closed

Setting prog and pyfile in options gives an error #79

rrthomas opened this issue Apr 8, 2023 · 2 comments · Fixed by #101

Comments

@rrthomas
Copy link
Contributor

rrthomas commented Apr 8, 2023

It turned out I was doing the wrong thing (I should have been setting module, not pyfile), but…

In the examples, there are these lines:

[build_manpages]
manpages =
    man/foo.1:object=parser:pyfile=bin/foo.py
    man/bar.1:function=get_parser:pyfile=bin/bar
    man/baz.1:function=get_parser:pyfile=bin/bar:prog=baz

However, if with argparse-manpage 4 I set both prog and pyfile, then I get this error:

running build_manpages
Traceback (most recent call last):
  File "/home/rrt/.local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 351, in <module>
    main()
  File "/home/rrt/.local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 333, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/rrt/.local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 249, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/build_meta.py", line 413, in build_wheel
    return self._build_with_temp_dir(['bdist_wheel'], '.whl',
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/build_meta.py", line 398, in _build_with_temp_dir
    self.run_setup()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/build_meta.py", line 484, in run_setup
    super(_BuildMetaLegacyBackend,
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
    exec(code, locals())
  File "<string>", line 18, in <module>
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/dist.py", line 1221, in run_command
    super().run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 343, in run
    self.run_command("build")
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/dist.py", line 1221, in run_command
    super().run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 131, in run
    self.run_command(cmd_name)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/dist.py", line 1221, in run_command
    super().run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/build_manpages/build_manpages.py", line 117, in run
    self.run_command(DEFAULT_CMD_NAME)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/dist.py", line 1221, in run_command
    super().run_command(command)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.ensure_finalized()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
    self.finalize_options()
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/build_manpages/build_manpages.py", line 84, in finalize_options
    self.manpages_data = parse_manpages_spec(self.manpages)
  File "/tmp/build-env-4kgiaqi2/lib/python3.10/site-packages/build_manpages/build_manpages.py", line 59, in parse_manpages_spec
    assert(not oname in manpagedata)
AssertionError

This appears to be because of the following code:

            elif oname in MANPAGE_DATA_ATTRS and oname != "authors":
                assert(not oname in manpagedata)
                manpagedata[oname] = ovalue

This is triggered when oname is prog, because previously the following code was run:

                if oname == 'pyfile':
                    manpagedata['prog'] = os.path.basename(ovalue)

Setting prog before pyfile does not cause an error, but does cause pyfile's value to overwrite prog's. Neither seems to be what is really wanted!

@praiskup
Copy link
Owner

praiskup commented Sep 1, 2023

Thank you for the report!

@rrthomas
Copy link
Contributor Author

rrthomas commented Sep 2, 2023

Thanks for the fix!

clrpackages pushed a commit to clearlinux-pkgs/pypi-argparse_manpage that referenced this issue Sep 7, 2023
…to version 4.4

News in v4.4

* The `prog=` specifier (in setup.py/setup.cfg/pyproject.toml) is now
  better handled so it doesn't conflict with ArgumentParser(prog=..).
  Fixes praiskup/argparse-manpage#79
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 6, 2023
News in v4.5

* We newly provide `build_manpages.build_py` and `build_manpages.install`
  command classes that are re-usable from `pyproject.toml`.  No need to
  provide `setup.py` because of `argparse-manpage`.


News in v4.4

* The `prog=` specifier (in setup.py/setup.cfg/pyproject.toml) is now
  better handled so it doesn't conflict with ArgumentParser(prog=..).
  Fixes praiskup/argparse-manpage#79
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.

2 participants