openSUSE / py2pack

Generate distribution packages from PyPI
Apache License 2.0
69 stars 40 forks source link

0.8.7 failing for pynitrokey: distutils.errors.DistutilsOptionError: No configuration found for dynamic 'description'. #173

Closed johanneskastl closed 1 year ago

johanneskastl commented 1 year ago

pynitrokey https://github.com/Nitrokey/pynitrokey https://pypi.org/project/pynitrokey/

py2pack generate -t opensuse.spec -f python-pynitrokey.spec pynitrokey
generating spec file for pynitrokey...                                                        
Traceback (most recent call last):                                                                                                                                                           
  File "/tmp/metaextract_qfu613wv/pynitrokey-0.4.36/setup.py", line 3, in <module>
    setup()                                                                                   
  File "/usr/lib/python3.10/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)                                                      
  File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 159, in setup
    dist.parse_config_files()                                                                                                                                                                
  File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 885, in parse_config_files 
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 62, in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)                                                                                                                  
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 140, in read_configuration
    return expand_configuration(asdict, root_dir, ignore_option_errors, dist)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 195, in expand_configuration
    return _ConfigExpander(config, root_dir, ignore_option_errors, dist).expand()
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 243, in expand
    self._expand_all_dynamic(dist, package_dir) 
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 281, in _expand_all_dynamic
    obtained_dynamic = {
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 282, in <dictcomp>
    field: self._obtain(dist, field, package_dir)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 331, in _obtain
    self._ensure_previously_set(dist, field)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 307, in _ensure_previously_set
    raise OptionError(msg)
distutils.errors.DistutilsOptionError: No configuration found for dynamic 'description'.
Some dynamic fields need to be specified via `tool.setuptools.dynamic`
others must be specified via the equivalent attribute in `setup.py`.
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/metaextract/utils.py", line 111, in _setup_py_run_from_dir
    subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
  File "/usr/lib64/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib64/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '/usr/bin/python3.10 setup.py -q --command-packages metaextract metaextract -o /tmp/tmpv2463ofm ' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module> 
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 366, in main
    args.func(args)
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 255, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 163, in _augment_data_from_tarball
    data_archive = meta_utils.from_archive(filename)
  File "/usr/lib/python3.10/site-packages/metaextract/utils.py", line 140, in from_archive
    data = _setup_py_run_from_dir(root_dir, py_interpreter)
  File "/usr/lib/python3.10/site-packages/metaextract/utils.py", line 115, in _setup_py_run_from_dir
    subprocess.check_output(cmd, shell=True)
  File "/usr/lib64/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib64/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '/usr/bin/python3.10 setup.py -q --command-packages metaextract metaextract -o /tmp/tmpv2463ofm ' returned non-zero exit status 1.
thesp0nge commented 1 year ago

Can you please reproduce it also with the version you find in master?

johanneskastl commented 1 year ago

Can you please reproduce it also with the version you find in master?

Can I just run it from the cloned repository? Or do I need to uninstall the rpm package?

thesp0nge commented 1 year ago

You can run just from the cloned repository. Make sure to pick the right binary. Thank you so much

johanneskastl commented 1 year ago

Starting from within the py2pack folder in the clone, I get this:

.../py2pack/py2pack (master *)>python3.10 ./__init__.py fetch pynitrokey
downloading package pynitrokey-0.4.36...
from https://files.pythonhosted.org/packages/source/p/pynitrokey/pynitrokey-0.4.36.tar.gz
...//py2pack/py2pack (master *)>python3.10 ./__init__.py generate -t opensuse.spec -f python-pynitrokey.spec pynitrokey
generating spec file for pynitrokey...
Traceback (most recent call last):
  File "/tmp/metaextract_b3a8lzih/pynitrokey-0.4.36/setup.py", line 3, in <module>
    setup()
  File "/usr/lib/python3.10/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 159, in setup
    dist.parse_config_files()
  File "/usr/lib/python3.10/site-packages/setuptools/dist.py", line 885, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 62, in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 140, in read_configuration
    return expand_configuration(asdict, root_dir, ignore_option_errors, dist)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 195, in expand_configuration
    return _ConfigExpander(config, root_dir, ignore_option_errors, dist).expand()
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 243, in expand
    self._expand_all_dynamic(dist, package_dir)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 281, in _expand_all_dynamic
    obtained_dynamic = {
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 282, in <dictcomp>
    field: self._obtain(dist, field, package_dir)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 331, in _obtain
    self._ensure_previously_set(dist, field)
  File "/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 307, in _ensure_previously_set
    raise OptionError(msg)
distutils.errors.DistutilsOptionError: No configuration found for dynamic 'description'.
Some dynamic fields need to be specified via `tool.setuptools.dynamic`
others must be specified via the equivalent attribute in `setup.py`.
/home/GIT_Repositories/OBS_und_Co/py2pack/py2pack/./__init__.py:262: UserWarning: Could not get information from tarball pynitrokey-0.4.36.tar.gz: Command '/usr/bin/python3.10 setup.py -q --command-packages metaextract metaextract -o /tmp/tmpsrut3zie ' returned non-zero exit status 1.. Valuable information for the generation might be missing.
  warnings.warn("Could not get information from tarball {}: {}. Valuable "

The distutils.errors.DistutilsOptionError: No configuration found for dynamic 'description'. is the same as in the initial error. The warning in the end looks like it is coming from running from the cloned directory.

bnavigator commented 1 year ago

Hi Johannes,

With

[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

in pynitrokey's pyproject.toml, the code should never get to the UserWarning about failing setuptools in the current master branch:

https://github.com/openSUSE/py2pack/blob/d93c4294188a9dc76e323e34fc88a789ae7089b3/py2pack/__init__.py#L221-L233

Your backtrace shows a different wording and line number, you seem to still have the old code:

https://github.com/openSUSE/py2pack/blob/a3f821bb7195316ae24164544f6604e16d95118b/py2pack/__init__.py#L258-L268

Please do a git pull and check again.

johanneskastl commented 1 year ago

Thanks for the explanation, @bnavigator !

I tried to use current master, even uninstall py2pack to make sure nothing interferes. But now I get this error (which seems to be unrelated to the original error):

$ python3.10 ./__init__.py fetch pynitrokey
Traceback (most recent call last):
  File "/home/GIT_Repositories/OBS_und_Co/py2pack/py2pack/./__init__.py", line 39, in <module>
    import py2pack.proxy
ModuleNotFoundError: No module named 'py2pack.proxy'
$ python3.10 ./__init__.py generate -t opensuse.spec -f python-pynitrokey.spec pynitrokey
Traceback (most recent call last):
  File "/home/GIT_Repositories/OBS_und_Co/py2pack/py2pack/./__init__.py", line 39, in <module>
    import py2pack.proxy
ModuleNotFoundError: No module named 'py2pack.proxy'
bnavigator commented 1 year ago

You're one directory level too deep. Call __init__.py from the repository toplevel or add it to your PYTHONPATH so that py2pack is found in sys.path.

PYTHONPATH=$PWD python3.10 ./py2pack/__init__.py fetch pynitrokey
johanneskastl commented 1 year ago

Thanks @bnavigator , that worked. The command does no longer crash and creates a spec file. Setting this to solved, current state from git does not have this problem.

thesp0nge commented 1 year ago

A new release is urgent here. Thanks Johannes