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

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

Closed
johanneskastl opened this issue May 11, 2023 · 9 comments

Comments

@johanneskastl
Copy link

johanneskastl commented May 11, 2023

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

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

@johanneskastl
Copy link
Author

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

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

@johanneskastl
Copy link
Author

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

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:

py2pack/py2pack/__init__.py

Lines 221 to 233 in d93c429

try:
buildrequires = data['build-system']['requires']
except KeyError:
# No build system specified in pyproject.toml: legacy setuptools
buildrequires = ['setuptools']
if any(['setuptools' in br for br in buildrequires]):
try:
data_archive = meta_utils.from_archive(filename)
data.update(data_archive['data'])
except Exception as exc:
warnings.warn("Could not get setuptools information from tarball {}: {}. "
"Valuable information for the generation might be missing."
.format(filename, exc))

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

py2pack/py2pack/__init__.py

Lines 258 to 268 in a3f821b

if tarball_file: # get some more info from that
try:
_augment_data_from_tarball(args, tarball_file[0], data)
except Exception as exc:
warnings.warn("Could not get information from tarball {}: {}. Valuable "
"information for the generation might be missing."
.format(tarball_file[0], exc))
else:
warnings.warn("No tarball for {} in version {} found. Valuable "
"information for the generation might be missing."
"".format(args.name, args.version))

Please do a git pull and check again.

@johanneskastl
Copy link
Author

johanneskastl commented May 14, 2023

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

bnavigator commented May 14, 2023

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

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

A new release is urgent here.
Thanks Johannes

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

3 participants