Skip to content

Fails to identify package that specifies python_requires. #33

@rotu

Description

@rotu

If you use a package that specifies a python version, colcon_setup_py chokes. This is because we assume that repr and ast.literal_eval are inverse operations. This is not guaranteed, and in fact not true for SpecifierSet:

$ colcon info --packages-select tox
/usr/lib/python3.8/distutils/dist.py:274: UserWarning: Unknown distribution option: 'use_scm_version'
  warnings.warn(msg)
[1.315s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'python_setup_py' in 'src/tox': invalid syntax (<unknown>, line 1)
Traceback (most recent call last):
  File "/home/dan/Documents/rostools/src/colcon-core/colcon_core/package_identification/__init__.py", line 143, in _identify
    retval = extension.identify(_reused_descriptor_instance)
  File "/home/dan/Documents/rostools/src/colcon-python-setup-py/colcon_python_setup_py/package_identification/python_setup_py.py", line 47, in identify
    config = get_setup_information(setup_py)
  File "/home/dan/Documents/rostools/src/colcon-python-setup-py/colcon_python_setup_py/package_identification/python_setup_py.py", line 267, in get_setup_information
    _setup_information_cache[hashable_env] = _get_setup_information(
  File "/home/dan/Documents/rostools/src/colcon-python-setup-py/colcon_python_setup_py/package_identification/python_setup_py.py", line 309, in _get_setup_information
    return ast.literal_eval(output)
  File "/usr/lib/python3.8/ast.py", line 59, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "/usr/lib/python3.8/ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    {'package_data': {}, 

...

 'python_requires': <SpecifierSet('!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7')>}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ^
SyntaxError: invalid syntax

[1.860s] WARNING:colcon.colcon_core.package_selection:ignoring unknown package 'tox' in --packages-select

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions