Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python] Editable pip installs do not work #1692

Closed
nicholasjng opened this issue Nov 3, 2023 · 1 comment
Closed

[BUG] [Python] Editable pip installs do not work #1692

nicholasjng opened this issue Nov 3, 2023 · 1 comment

Comments

@nicholasjng
Copy link
Contributor

Describe the bug
Editable installs of the GBM Python bindings do not work.

System
Which OS, compiler, and compiler version are you using:

  • OS: MacOS 14.1
  • Compiler and version: clang 15.0.0

To reproduce
Steps to reproduce the behavior:
At HEAD (reproduced with Python 3.12) in a virtual environment:

python -m pip install -e .

Results in:

Error message
➜ python -m pip install -e .
Obtaining file:///Users/nicholasjunge/Workspaces/c%2B%2B/benchmark
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: absl-py>=0.7.1 in ./venv/lib/python3.12/site-packages (from google-benchmark==1.8.4.dev18+gb40db86) (2.0.0)
Building wheels for collected packages: google-benchmark
  Building editable for google-benchmark (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building editable for google-benchmark (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [124 lines of output]
      running editable_wheel
      creating /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info
      writing /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/dependency_links.txt
      writing requirements to /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/requires.txt
      writing top-level names to /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/top_level.txt
      writing manifest file '/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      adding license file 'AUTHORS'
      writing manifest file '/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark.egg-info/SOURCES.txt'
      creating '/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark-1.8.4.dev18+gb40db86.dist-info'
      creating /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-wheel-9dvyhm2t/.tmp-9v4excon/google_benchmark-1.8.4.dev18+gb40db86.dist-info/WHEEL
      running build_py
      running build_ext
      bazel build //bindings/python/google_benchmark:_benchmark --symlink_prefix=/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/tmp6eh7nuci.build-temp/bazel- --compilation_mode=opt --cxxopt=-std=c++17 --macos_minimum_os=11.0
      Starting local Bazel server and connecting to it...
      Loading:
      DEBUG: /private/var/tmp/_bazel_nicholasjunge/7931a2ee992544fe3d1024dd6c7623f6/external/rules_python/python/pip.bzl:48:10: pip_install is deprecated. Please switch to pip_parse. pip_install will be removed in a future release.
      Loading:
      Loading: 0 packages loaded
      Analyzing: target //bindings/python/google_benchmark:_benchmark (1 packages loaded, 0 targets configured)
      Analyzing: target //bindings/python/google_benchmark:_benchmark (43 packages loaded, 196 targets configured)
      Analyzing: target //bindings/python/google_benchmark:_benchmark (43 packages loaded, 196 targets configured)
      Analyzing: target //bindings/python/google_benchmark:_benchmark (43 packages loaded, 196 targets configured)
      DEBUG: Rule 'nanobind' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "555ec7595c89c60ce7cf53e803bc226dc4899abb" and dropping ["tag"]
      DEBUG: Repository nanobind instantiated at:
        /Users/nicholasjunge/Workspaces/c++/benchmark/WORKSPACE:5:15: in <toplevel>
        /Users/nicholasjunge/Workspaces/c++/benchmark/bazel/benchmark_deps.bzl:53:27: in benchmark_deps
      Repository rule git_repository defined at:
        /private/var/tmp/_bazel_nicholasjunge/7931a2ee992544fe3d1024dd6c7623f6/external/bazel_tools/tools/build_defs/repo/git.bzl:181:33: in <toplevel>
      Analyzing: target //bindings/python/google_benchmark:_benchmark (47 packages loaded, 501 targets configured)
      Analyzing: target //bindings/python/google_benchmark:_benchmark (48 packages loaded, 504 targets configured)
      INFO: Analyzed target //bindings/python/google_benchmark:_benchmark (48 packages loaded, 620 targets configured).
      INFO: Found 1 target...
      [0 / 18] [Prepa] BazelWorkspaceStatusAction stable-status.txt
      [4 / 37] Compiling src/counter.cc; 1s darwin-sandbox ... (10 actions running)
      [6 / 37] Compiling src/timers.cc; 2s darwin-sandbox ... (9 actions, 8 running)
      [23 / 37] Compiling src/benchmark_register.cc; 1s darwin-sandbox ... (10 actions, 9 running)
      [36 / 37] [Prepa] Linking bindings/python/google_benchmark/_benchmark.so
      INFO: From Linking bindings/python/google_benchmark/_benchmark.so:
      ld: warning: ignoring duplicate libraries: '-lc++'
      Target //bindings/python/google_benchmark:_benchmark up-to-date (nothing to build)
      INFO: Elapsed time: 15.013s, Critical Path: 4.42s
      INFO: 36 processes: 3 internal, 33 darwin-sandbox.
      INFO: Build completed successfully, 36 total actions
      building 'google_benchmark._benchmark' extension
      creating /var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/tmplwn57agx.build-lib/google_benchmark
      clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -o /var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/tmplwn57agx.build-lib/google_benchmark/_benchmark.cpython-312-darwin.so
      clang: error: no input files
      Traceback (most recent call last):
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 266, in link
          self.spawn(linker + ld_args)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn
          spawn(cmd, dry_run=self.dry_run, **kwargs)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
          raise DistutilsExecError(
      distutils.errors.DistutilsExecError: command '/usr/bin/clang' failed with exit code 1
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 156, in run
          self._create_wheel_file(bdist_wheel)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 345, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 268, in _run_build_commands
          self._run_build_subcommands()
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 295, in _run_build_subcommands
          self.run_command(name)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/dist.py", line 989, in run_command
          super().run_command(command)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "<string>", line 56, in run
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 88, in run
          _build_ext.run(self)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
          self.build_extensions()
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
          self._build_extensions_serial()
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
          self.build_extension(ext)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
          _build_ext.build_extension(self, ext)
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 572, in build_extension
          self.compiler.link_shared_object(
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/ccompiler.py", line 752, in link_shared_object
          self.link(
        File "/private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/unixccompiler.py", line 268, in link
          raise LinkError(msg)
      distutils.errors.LinkError: command '/usr/bin/clang' failed with exit code 1
      /private/var/folders/rw/mj164vm16k10x_byww6my1s00000gn/T/pip-build-env-dresdcwp/overlay/lib/python3.12/site-packages/setuptools/_distutils/dist.py:988: _DebuggingTips: Problem in editable installation.
      !!
      
              ********************************************************************************
              An error happened while installing `google_benchmark` 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()
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for google-benchmark
Failed to build google-benchmark
ERROR: Could not build wheels for google-benchmark, which is required to install pyproject.toml-based projects

I see no reason why this shouldn't work, so I assume that the runfiles are not correctly passed in the Bazel extension.
Will need to confirm the status on Python 3.11 before though, to make sure this is not a Python 3.12 problem.

@nicholasjng
Copy link
Contributor Author

Fixed in #1710.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant