rrthomas / psutils

Utilities for manipulating PostScript documents
GNU General Public License v3.0
36 stars 11 forks source link

Build failure: No package metadata was found for pspdfutils #66

Open Zopolis4 opened 2 months ago

Zopolis4 commented 2 months ago

(Debian GNU/Linux trixie/sid x86_64)

user@computer /tmp> git clone https://github.com/rrthomas/psutils
Cloning into 'psutils'...
remote: Enumerating objects: 4851, done.
remote: Counting objects: 100% (1491/1491), done.
remote: Compressing objects: 100% (550/550), done.
remote: Total 4851 (delta 983), reused 1365 (delta 898), pack-reused 3360
Receiving objects: 100% (4851/4851), 1.34 MiB | 5.96 MiB/s, done.
Resolving deltas: 100% (3226/3226), done.
user@computer /tmp> cd psutils
user@computer /t/psutils (main)> python3.12 setup.py build
[05/16/24 16:15:35] WARNING  pyproject.toml does not contain a tool.setuptools_scm section                                                                        setuptools.py:119
running build
running build_py
running build_manpages
generating epsffit.1
Traceback (most recent call last):
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 397, in from_name
    return next(cls.discover(name=name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/psutils/setup.py", line 13, in <module>
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 107, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1233, in run_command
    super().run_command(command)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/build.py", line 131, in run
    self.run_command(cmd_name)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1233, in run_command
    super().run_command(command)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/build_manpages/build_manpages.py", line 151, in run
    self.run_command(DEFAULT_CMD_NAME)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1233, in run_command
    super().run_command(command)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/lib/python3/dist-packages/build_manpages/build_manpages.py", line 127, in run
    parser = get_parser(data['import_type'], data['import_from'], data['objname'], data['objtype'], data.get('prog', None))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/argparse_manpage/tooling.py", line 66, in get_parser
    return get_parser_from_module(import_from, objname, objtype, prog=prog)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/argparse_manpage/tooling.py", line 28, in get_parser_from_module
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/tmp/psutils/psutils/__init__.py", line 9, in <module>
    from .transformers import *
  File "/tmp/psutils/psutils/transformers.py", line 18, in <module>
    from .argparse import parserange
  File "/tmp/psutils/psutils/argparse.py", line 189, in <module>
    VERSION = importlib.metadata.version("pspdfutils")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 888, in version
    return distribution(distribution_name).version
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 861, in distribution
    return Distribution.from_name(distribution_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 399, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for pspdfutils
rrthomas commented 2 months ago

Dumb question, sorry if I'm missing something obvious: why did you expect this to work?

Zopolis4 commented 2 months ago

I'm trying to add this package to chromebrew, and this is just the default build command it uses if there is a setup.py file.

if File.file?('setup.py')
  system "python3 setup.py build --executable=/usr/local/bin/python3"
else
  system "python3 -m build --wheel --no-isolation"
end

I assumed that, given that this logic works for the 50-odd other python packages, that this was the correct command.

That being said, I probably should have looked more closely at the readme before submitting this issue, sorry about that.

rrthomas commented 2 months ago

Thanks! I'm not a Python packaging expert, and to be honest I have struggled with getting packaging to work smoothly with an up-to-date style.

I think what is happening here is that psutils is falling "in the cracks": it's mostly a modern-style package, but it still needs a small setup.py for a couple of things. So in this case, the chromebrew script is misled about which build method it should use.

I think I should at least be able to reduce the amount of code in setup.py now, so I'll look into that.

rrthomas commented 2 months ago

Indeed, it should be possible with the current version of argparse-manpage (4.5) to remove setup.py altogether. I have run into a problem while trying to do so, so I'll keep this issue open to track it. The work is on the pure-pyproject branch, and the issue I ran into is https://github.com/praiskup/argparse-manpage/issues/111