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

Get rid of setup.py #66

Open
Zopolis4 opened this issue May 16, 2024 · 4 comments
Open

Get rid of setup.py #66

Zopolis4 opened this issue May 16, 2024 · 4 comments

Comments

@Zopolis4
Copy link

(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
Copy link
Owner

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

@Zopolis4
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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 praiskup/argparse-manpage#111

@rrthomas rrthomas changed the title Build failure: No package metadata was found for pspdfutils Get rid of setup.py Jan 8, 2025
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

No branches or pull requests

2 participants