← Back to team overview

cloud-init team mailing list archive

python3 and argparse

 

Hello,

In openSUSE Tumbleweed we're now building cloud-init with python3. Building works fine, but at runtime any
calling of cloud-init (such as "cloud-init --help") fails with quite an impressive traceback . eg

Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3036, in <module>
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3020, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3049, in
_initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 654, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 968, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 854, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'argparse' distribution was not found and is required by cloud-init

We're working around the problem with the below patch, which we'd like to have considered for inclusion in
cloud-init, or a better solution proposed

+--- requirements.txt
++++ requirements.txt
+@@ -27,9 +27,6 @@
+ # All new style configurations are in the yaml format
+ pyyaml
+ 
+-# The new main entrypoint uses argparse instead of optparse
+-argparse
+-
+ # Requests handles ssl correctly!
+ requests
+ 
+--- setup.py
++++ setup.py
+@@ -198,7 +198,7 @@
+ 
+ requirements = read_requires()
+ if sys.version_info < (3,):
+-    requirements.append('cheetah')
++    requirements.append('cheetah', 'argparse')
+ 
+ setuptools.setup(
+     name='cloud-init',

Regards,
-- 
Richard Brown
Linux Distribution Engineer - Future Technology Team
Chairman - openSUSE
  
Phone +4991174053-361
SUSE Linux GmbH,  Maxfeldstr. 5,  D-90409 Nuernberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton, 
HRB 21284 (AG Nürnberg)










Follow ups