executorch icon indicating copy to clipboard operation
executorch copied to clipboard

Error in Pip Install Editable Mode

Open Jerry-Ge opened this issue 1 year ago • 3 comments

When trying to run the following command to install in editable mode: pip install --editable . --config-settings editable_mode=strict --no-build-isolation

Hit the following error:

Building wheels for collected packages: executorch
  Building editable for executorch (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building editable for executorch (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [144 lines of output]
      [04/05/24 15:57:12] WARNING  pyproject.toml does not contain a setuptools.py:119
                                   tool.setuptools_scm section
      running editable_wheel
      creating /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info
      writing /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/dependency_links.txt
      writing entry points to /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/entry_points.txt
      writing requirements to /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/requires.txt
      writing top-level names to /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/top_level.txt
      writing manifest file '/tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      writing manifest file '/tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch.egg-info/SOURCES.txt'
      creating '/tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch-0.1.0.dist-info'
      creating /tmp/pip-wheel-91gm0nbw/.tmp-sdag809b/executorch-0.1.0.dist-info/WHEEL
      running build_py
      creating /tmp/tmprwpw5zbw.build-lib/executorch
      creating /tmp/tmprwpw5zbw.build-lib/executorch/exir
      creating /tmp/tmprwpw5zbw.build-lib/executorch/exir/_serialize
      copying schema/scalar_type.fbs -> /tmp/tmprwpw5zbw.build-lib/executorch/exir/_serialize
      copying schema/program.fbs -> /tmp/tmprwpw5zbw.build-lib/executorch/exir/_serialize
      creating /tmp/tmprwpw5zbw.build-lib/executorch/sdk
      creating /tmp/tmprwpw5zbw.build-lib/executorch/sdk/bundled_program
      creating /tmp/tmprwpw5zbw.build-lib/executorch/sdk/bundled_program/serialize
      copying sdk/bundled_program/schema/bundled_program_schema.fbs -> /tmp/tmprwpw5zbw.build-lib/executorch/sdk/bundled_program/serialize
      copying sdk/bundled_program/schema/scalar_type.fbs -> /tmp/tmprwpw5zbw.build-lib/executorch/sdk/bundled_program/serialize
      running build_ext
      Traceback (most recent call last):
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 156, in run
          self._create_wheel_file(bdist_wheel)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 345, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 268, in _run_build_commands
          self._run_build_subcommands()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 295, in _run_build_subcommands
          self.run_command(name)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/build_ext.py", line 88, in run
          _build_ext.run(self)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
          self.build_extensions()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 465, in build_extensions
          self._build_extensions_parallel()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 488, in _build_extensions_parallel
          fut.result()
        File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
          return self.__get_result()
        File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
          raise self._exception
        File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
          result = self.fn(*self.args, **self.kwargs)
        File "<string>", line 235, in build_extension
        File "<string>", line 127, in src_path
      ValueError: Expected exactly one file matching 'third-party/flatbuffers/flatc'; found ()
      /usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py:988: _DebuggingTips: Problem in editable installation.
      !!
      
              ********************************************************************************
              An error happened while installing `executorch` in editable mode.
      
              The following steps are recommended to help debug this problem:
      
              - Try to install the project normally, without using the editable mode.
                Does the error still persist?
                (If it does, try fixing the problem before attempting the editable mode).
              - If you are using binary extensions, make sure you have all OS-level
                dependencies installed (e.g. compilers, toolchains, binary libraries, ...).
              - Try the latest version of setuptools (maybe the error was already fixed).
              - If you (or your project dependencies) are using any setuptools extension
                or customization, make sure they support the editable mode.
      
              After following the steps above, if the problem still persists and
              you think this is related to how setuptools handles editable installations,
              please submit a reproducible example
              (see https://stackoverflow.com/help/minimal-reproducible-example) to:
      
                  https://github.com/pypa/setuptools/issues
      
              See https://setuptools.pypa.io/en/latest/userguide/development_mode.html for details.
              ********************************************************************************
      
      !!
        cmd_obj.run()
      Traceback (most recent call last):
        File "/home/x/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/x/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/x/.local/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 273, in build_editable
          return hook(wheel_directory, config_settings, metadata_directory)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 436, in build_editable
          return self._build_with_temp_dir(
        File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 389, in _build_with_temp_dir
          self.run_setup()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 448, in <module>
        File "/usr/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 156, in run
          self._create_wheel_file(bdist_wheel)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 345, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 268, in _run_build_commands
          self._run_build_subcommands()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/editable_wheel.py", line 295, in _run_build_subcommands
          self.run_command(name)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 963, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/build_ext.py", line 88, in run
          _build_ext.run(self)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
          self.build_extensions()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 465, in build_extensions
          self._build_extensions_parallel()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/command/build_ext.py", line 488, in _build_extensions_parallel
          fut.result()
        File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
          return self.__get_result()
        File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
          raise self._exception
        File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
          result = self.fn(*self.args, **self.kwargs)
        File "<string>", line 235, in build_extension
        File "<string>", line 127, in src_path
      ValueError: Expected exactly one file matching 'third-party/flatbuffers/flatc'; found ()
      [end of output]
  

The normal pip install . still works.

Jerry-Ge avatar Apr 05 '24 16:04 Jerry-Ge

@dbort is this being looked at?

freddan80 avatar May 06 '24 13:05 freddan80

Sorry yeah I broke this while hardening up the pip build process to support flatc and pybindings.

https://github.com/pytorch/executorch/blob/cc2d3b57420c9dd73abf458c8cc45e099d9e8a7b/setup.py#L411-L413 has some notes about what needs to change here: I think we need to report the existence of flatc. And from the looks of it, we probably also need to copy the flatc binary into the source tree when building in editable mode.

I hadn't planned to fix this in the near term because I didn't know that anyone was using that feature. I'll try to find some time in the next couple of weeks. Though if anyone wants to take a stab at fixing it before then I can help advise.

dbort avatar May 09 '24 22:05 dbort

I hadn't planned to fix this in the near term because I didn't know that anyone was using that feature. I'll try to find some time in the next couple of weeks.

That would be awesome! I think it's a great Python feature that speeds up the dev loop.

freddan80 avatar May 13 '24 16:05 freddan80

@dbort We have a workaround in https://github.com/pytorch/executorch/pull/3844.

oscarandersson8218 avatar Jun 05 '24 06:06 oscarandersson8218

This is still something that we could improve if anyone would like to, but with a workaround it's less urgent for now, and I don't expect to have time in the near term.

dbort avatar Jul 01 '24 23:07 dbort