pypa / setuptools

Official project repository for the Setuptools build system
https://pypi.org/project/setuptools/
MIT License
2.49k stars 1.19k forks source link

[BUG] AttributeError: 'NoneType' object has no attribute 'origin' and ModuleNotFoundError: No module named 'XXX' #2605

Open chaosAD opened 3 years ago

chaosAD commented 3 years ago

setuptools version

54.1.1

Python version

3.7.9

OS

Windows 10

Additional environment information

This is happening on Windows 10 that I have tried so far. If executing the same steps under Raspbian GNU/Linux 10 (buster) with the same version of Python and setuptools, no such error encountered.

Description

I received two exceptions triggered by config.py when installing luma.oled:

  1. AttributeError: 'NoneType' object has no attribute 'origin'
  2. ModuleNotFoundError: No module named 'luma.oled'

Expected behavior

I don't expect such exceptions to happen.

How to Reproduce

  1. pip install https://github.com/rm-hull/luma.core/archive/master.zip
  2. pip install https://github.com/rm-hull/luma.oled/archive/master.zip

The exceptions would be triggered in step (2). Note that the installation MUST be in the order specified, otherwise no error would be generated.

Output

Collecting https://github.com/rm-hull/luma.oled/archive/master.zip
  Using cached https://github.com/rm-hull/luma.oled/archive/master.zip
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\user\appdata\local\programs\thonny\python.exe' 'c:\users\user\appdata\local\programs\thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user\AppData\Local\Temp\tmphvzewynk'
       cwd: C:\Users\user\AppData\Local\Temp\pip-req-build-5w6wbo9g
  Complete output (48 lines):
  Traceback (most recent call last):
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 387, in _parse_attr
      return getattr(StaticModule(module_name), attr_name)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 25, in __init__
      with open(spec.origin) as strm:
  AttributeError: 'NoneType' object has no attribute 'origin'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "c:\users\user\appdata\local\programs\thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
      main()
    File "c:\users\user\appdata\local\programs\thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\users\user\appdata\local\programs\thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\build_meta.py", line 150, in get_requires_for_build_wheel
      config_settings, requirements=['wheel'])
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 7, in <module>
      setuptools.setup()
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "c:\users\user\appdata\local\programs\thonny\lib\distutils\core.py", line 121, in setup
      dist.parse_config_files()
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\dist.py", line 708, in parse_config_files
      ignore_option_errors=ignore_option_errors)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 157, in parse_configuration
      meta.parse()
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 463, in parse
      section_parser_method(section_options)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 436, in parse_section
      self[name] = value
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 220, in __setitem__
      value = parser(value)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 552, in _parse_version
      version = self._parse_attr(value, self.package_dir)
    File "C:\Users\user\AppData\Local\Temp\pip-build-env-_xeaivwi\overlay\Lib\site-packages\setuptools\config.py", line 390, in _parse_attr
      module = importlib.import_module(module_name)
    File "c:\users\user\appdata\local\programs\thonny\lib\importlib\__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
    File "<frozen importlib._bootstrap>", line 983, in _find_and_load
    File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'luma.oled'
  ----------------------------------------
WARNING: Discarding https://github.com/rm-hull/luma.oled/archive/master.zip. Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\thonny\python.exe' 'c:\users\user\appdata\local\programs\thonny\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user\AppData\Local\Temp\tmphvzewynk' Check the logs for full command output.

Code of Conduct

bblommers commented 2 years ago

I just got the same error when building my own package, and it was caused by this line in setup.cfg:

version = attr: package.__version__

The luma.oled-package uses the same configuration, so I imagine that's what triggers this bug.

ortegauriol commented 2 years ago

I just got the same error when building my own package, and it was caused by this line in setup.cfg:

version = attr: package.__version__

The luma.oled-package uses the same configuration, so I imagine that's what triggers this bug.

Hey @bblommers how did you replace it to solve the problem? thanks heaps!

bblommers commented 2 years ago

Hey @bblommers how did you replace it to solve the problem? thanks heaps!

We didn't, @ortegauriol - we worked around it by duplicating the version-number in __init__.py and setup.cfg :slightly_frowning_face: