Cimbali / pysrpm

Easily convert a python source package to a source RPM package
0 stars 1 forks source link

Cannot run pysrpm #2

Open MikeFalowski opened 1 year ago

MikeFalowski commented 1 year ago

I try to build rpm from tar.gz package but unfortunately I got this error:

[user@localhost localhost]$ pysrpm dist/my-project-0.0.0.tar.gz 
Traceback (most recent call last):
  File "/home/user/.local/bin/pysrpm", line 5, in <module>
    from pysrpm.__main__ import cli
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/__main__.py", line 7, in <module>
    from pysrpm.rpm import RPM
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 40, in <module>
    class RPM:
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 191, in RPM
    def load_toml_config(path):
  File "/usr/lib64/python3.9/functools.py", line 652, in cache
    return lru_cache(maxsize=None)(user_function)
  File "/usr/lib64/python3.9/functools.py", line 518, in decorating_function
    wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
TypeError: the first argument must be callable

For additional info, I'm using pyproject.toml and python3 -m build.

MikeFalowski commented 1 year ago

Ok, I removed functools.cache for test purposes (I have no idea what does it do here) and then I got this error:

[user@localhost localhost]$ pysrpm 
Traceback (most recent call last):
  File "/home/user/.local/bin/pysrpm", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/__main__.py", line 68, in cli
    with RPM(source, **options, cli_templates=templates) as rpm_builder:
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 52, in __init__
    with self.preset_configs() as config_lists:
  File "/usr/lib64/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 69, in preset_configs
    with importlib_resources.path('pysrpm', 'presets') as defaults_path:
  File "/usr/lib64/python3.9/contextlib.py", line 119, in __enter__
    return next(self.gen)
  File "/usr/lib64/python3.9/importlib/resources.py", line 175, in _path_from_reader
    opener_reader = reader.open_resource(norm_resource)
  File "<frozen importlib._bootstrap_external>", line 1055, in open_resource
IsADirectoryError: [Errno 21] Is a directory: '/home/user/.local/lib/python3.9/site-packages/pysrpm/presets'
[

So, I've changed preset_configs to:

    @staticmethod
    @contextlib.contextmanager
    def preset_configs():
        """ Context manager that ensures the preset configurations are in a directory, and yields the sorted list """
        with importlib_resources.files('pysrpm').joinpath("presets") as defaults_path:
        # with importlib_resources.path('pysrpm', 'presets') as defaults_path:
            yield sorted(defaults_path.glob('*.conf'))

and I got this error:

[user@localhost localhost]$ pysrpm dist/dev-solaris-mlworker-0.0.0.tar.gz 
/home/user/.local/lib/python3.9/site-packages/pysrpm/presets
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 377, in _format_lines
    successful_lines.append(line.format(**kwargs))
KeyError: 'author'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/.local/bin/pysrpm", line 8, in <module>
    sys.exit(cli())
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/__main__.py", line 69, in cli
    rpm_builder.run()
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 460, in run
    spec = self.make_spec(pkg_info)
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 395, in make_spec
    spec = self._format_lines(self.templates['preamble'].lstrip('\n'), **pkg_info)
  File "/home/user/.local/lib/python3.9/site-packages/pysrpm/rpm.py", line 380, in _format_lines
    raise KeyError(f'Missing template key(s) {", ".join(err.args)}') from err
KeyError: 'Missing template key(s) author'

I'm stuck here for now. In pyproject.toml there is authors field, not author.

MikeFalowski commented 1 year ago

It looks like the first error is related to this https://github.com/cython/cython/issues/1434 When I left cache but removed staticmethod it also worked.

Cimbali commented 1 year ago

I’m afraid this project isn’t that well maintained anymore, as it turns out there’s a lot more differences between various rpm specs that I suspected so I’m not regularly using it anymore.

To answer your questions: