TypeError: expected string, got instance object

Issue #377 resolved
Jason Madden
created an issue

When installing a sdist whose setup.py uses the cffi_modules keyword argument, you can get this exception building a wheel:

  running install_headers
  creating build/bdist.linux-x86_64/wheel/persistent-4.4.0.data
  creating build/bdist.linux-x86_64/wheel/persistent-4.4.0.data/headers
  Traceback (most recent call last):
    File "<module>", line 1, in <module>
    File "/tmp/pip-install-mrcpQo/persistent/setup.py", line 130, in <module>
      entry_points={},
    File "/home/travis/virtualenv/pypy2.7-5.8.0/site-packages/setuptools/__init__.py", line 140, in setup
      return distutils.core.setup(**attrs)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/core.py", line 151, in setup
      dist.run_commands()
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/dist.py", line 953, in run_commands
      self.run_command(cmd)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/home/travis/virtualenv/pypy2.7-5.8.0/site-packages/wheel/bdist_wheel.py", line 238, in run
      self.run_command('install')
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/cmd.py", line 334, in run_command
      self.distribution.run_command(command)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/home/travis/virtualenv/pypy2.7-5.8.0/site-packages/setuptools/command/install.py", line 61, in run
      return orig.install.run(self)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/command/install.py", line 585, in run
      self.run_command(cmd_name)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/cmd.py", line 334, in run_command
      self.distribution.run_command(command)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/dist.py", line 972, in run_command
      cmd_obj.run()
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/command/install_headers.py", line 42, in run
      (out, _) = self.copy_file(header, self.install_dir)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/cmd.py", line 373, in copy_file
      dry_run=self.dry_run)
    File "/opt/python/pypy2.7-5.8.0/lib-python/2.7/distutils/file_util.py", line 108, in copy_file
      if not os.path.isfile(src):
    File "/home/travis/virtualenv/pypy2.7-5.8.0/lib-python/2.7/genericpath.py", line 37, in isfile
      st = os.stat(path)
  TypeError: expected string, got instance object

I've observed this with PyPy2 5.8 and 6.0 and PyPy3 5.8.

Here is the setup.py being run. On PyPy, there are no extensions specified except for the one automatically being created by the cffi_modules keyword. That extension object is the "instance object" that's being passed down to the install_headers command (for some reason).

Any thoughts? Is the setup.py or the module it references broken in some way?

Comments (2)

  1. Jason Madden reporter

    The proximate cause seems to be cffi.setuptools_ext:_add_c_module when it does dist.ext_modules.append(ext). It happens that dist.headers and dist.ext_modules are the same object....which is exactly what setup.py is doing. This is clearly our fault. Thanks!

  2. Log in to comment