Setuptools: SpecifierSet has no attribute split

Created on 9 Oct 2019  路  5Comments  路  Source: pypa/setuptools

Running the tests on cheroot, I'm seeing this error:

  Installing backend dependencies: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /Users/jaraco/code/public/cherrypy/cheroot/.tox/python/bin/python /Users/jaraco/code/public/cherrypy/cheroot/.tox/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmpkxgh82j6
         cwd: /Users/jaraco/code/public/cherrypy/cheroot
    Complete output (28 lines):
    Traceback (most recent call last):
      File "/Users/jaraco/code/public/cherrypy/cheroot/.tox/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
        main()
      File "/Users/jaraco/code/public/cherrypy/cheroot/.tox/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/Users/jaraco/code/public/cherrypy/cheroot/.tox/python/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 69, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 156, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 138, in <module>
        __name__ == '__main__' and setuptools.setup(**setup_params)
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 446, in __init__
        _Distribution.__init__(self, {
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/distutils/dist.py", line 292, in __init__
        self.finalize_options()
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 735, in finalize_options
        ep.load()(self, ep.name, value)
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 291, in check_specifier
        packaging.specifiers.SpecifierSet(value)
      File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-build-env-2krlo7y7/overlay/lib/python3.8/site-packages/setuptools/_vendor/packaging/specifiers.py", line 594, in __init__
        specifiers = [s.strip() for s in specifiers.split(",") if s.strip()]
    AttributeError: 'SpecifierSet' object has no attribute 'split'

I suspect this issue is brought about by #1847, and what's happening is the declarative config python_requires is transforming the value and later the value is parsed again. This code illustrates how the same error is elicited by a double construction:

>>> packaging.specifiers.SpecifierSet(packaging.specifiers.SpecifierSet('>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jaraco/code/public/pypa/setuptools/setuptools/_vendor/packaging/specifiers.py", line 594, in __init__
    specifiers = [s.strip() for s in specifiers.split(",") if s.strip()]
AttributeError: 'SpecifierSet' object has no attribute 'split'

Most helpful comment

Indeed, I'm extremely reluctant to support projects that wish to read declarative config on their own. I suggest if you wish to continue to read declarative config and pass it into setup(), then you'll need to support that interface and (conditionally) normalize any contents before passing into setup(). _Maybe_ it makes sense for setuptools to support accepting a SpecifierSet for python_requires. I'd probably accept a patch for that, though I'd say it is something of a feature request.

All 5 comments

But wait - if 'check_specifier' is called when a declarative 'python_requires' is indicated, then how is it that invalid specifiers were allowed in the bug (#1787)?

Oh, nevermind. It looks like cheroot is doing something weird in its setup.py.

Please reopen this, we need a workaround as it break lots and lots of projects.

@ssbarnea it only breaks hacks

Indeed, I'm extremely reluctant to support projects that wish to read declarative config on their own. I suggest if you wish to continue to read declarative config and pass it into setup(), then you'll need to support that interface and (conditionally) normalize any contents before passing into setup(). _Maybe_ it makes sense for setuptools to support accepting a SpecifierSet for python_requires. I'd probably accept a patch for that, though I'd say it is something of a feature request.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

srikanth-viswanathan picture srikanth-viswanathan  路  4Comments

Cykooz picture Cykooz  路  5Comments

Tobotimus picture Tobotimus  路  4Comments

rickstaa picture rickstaa  路  5Comments

tlatorre-uchicago picture tlatorre-uchicago  路  6Comments