rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

fix: Don't include directories with spaces in their name for python_repository

Open mchristen-astranis opened this issue 1 year ago • 8 comments

When installing scikit-rf, a directory with whitespace in it causes installation failures since there's a file in the filegroup that is an invalid Bazel label. https://github.com/scikit-rf/scikit-rf/pull/1019 also attempts to fix the directory name.

This is following the existing exclude that excludes files named with a space to also account for directories named with a space.

mchristen-astranis avatar Jan 30 '24 00:01 mchristen-astranis

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jan 30 '24 00:01 google-cla[bot]

I'm curious if you have any thoughts on how I could add a test of this behavior?

mchristen-astranis avatar Jan 30 '24 00:01 mchristen-astranis

What about using scikit-rf in one of the examples to test this? I think the part that you should change is in //python/pip_install/private:generate_build_bazel_file.bzl or something similar.

aignas avatar Jan 30 '24 01:01 aignas

What about using scikit-rf in one of the examples to test this? I think the part that you should change is in //python/pip_install/private:generate_build_bazel_file.bzl or something similar.

Good idea about the example.

I don't quite follow what you think I should change in pip_install/private, is there a different exclude or other way to filter these targets out?

Either way, it doesn't look like my current solution is doing the trick:

± bazel run main                                                                                                                                                                                                                                                                                                                                                                                                                   !10075
INFO: Invocation ID: eafbe241-0040-4806-8544-fb26c3a72b94
INFO: Analyzed target //:main (87 packages loaded, 10900 targets configured).
ERROR: /home/mchristen/tmp/rules_python/examples/pip_parse/BUILD.bazel:31:10: Creating runfiles tree bazel-out/k8-fastbuild/bin/main.runfiles failed: build-runfiles failed: error executing <shell command> command
  (cd /home/mchristen/.cache/bazel/_bazel_mchristen/af6d72465951c01fc21525a92bd256c3/execroot/_main && \
  exec env - \
    PATH=/home/mchristen/.cache/bazelisk/downloads/bazelbuild/bazel-7.0.2-linux-x86_64/bin:/home/mchristen/.cargo/bin:/home/mchristen/tools/gh-diff:/home/mchristen/tools/nvm/current:/home/mchristen/tools/arcanist/arcanist/bin:/home/mchristen/tools/nvm/current:/home/mchristen/tools/bin:/home/mchristen/tools/bin/go/bin:/home/mchristen/go/bin:/home/mchristen/.local/bin:/home/mchristen/.cargo/bin:/home/mchristen/tools/gh-diff:/home/mchristen/tools/nvm/current:/home/mchristen/tools/arcanist/arcanist/bin:/home/mchristen/tools/nvm/current:/home/mchristen/tools/bin:/home/mchristen/tools/bin/go/bin:/home/mchristen/go/bin:/home/mchristen/.local/bin:/usr/local/bin:/usr/local/sbin:/home/mchristen/.cargo/bin:/home/mchristen/tools/nvm/versions/node/v14.15.5/bin:/home/mchristen/.local/bin:/home/mchristen/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/mchristen/tools/bin:/home/mchristen/tools/arcanist/arcanist/bin:/home/mchristen/tools/bin/go/bin:/home/mchristen/go/bin:/usr/local/go:/usr/local/go/bin:/home/mchristen/go:/home/mchristen/tools/gh-diff \
  /home/mchristen/.cache/bazel/_bazel_mchristen/install/14fb027596f626f2526df4873ea20b8b/build-runfiles --allow_relative bazel-out/k8-fastbuild/bin/main.runfiles_manifest bazel-out/k8-fastbuild/bin/main.runfiles): Process exited with status 1: Process exited with status 1
/home/mchristen/.cache/bazel/_bazel_mchristen/install/14fb027596f626f2526df4873ea20b8b/build-runfiles (args bazel-out/k8-fastbuild/bin/main.runfiles_manifest bazel-out/k8-fastbuild/bin/main.runfiles): link or target filename contains space on line 4960: '_main/external/rules_python~override~pip~pypi_39_scikit_rf/site-packages/skrf_qtapps/skrf_qtwidgets/analyzers/driver development/__init__.py /home/mchristen/.cache/bazel/_bazel_mchristen/af6d72465951c01fc21525a92bd256c3/external/rules_python~override~pip~pypi_39_scikit_rf/site-packages/skrf_qtapps/skrf_qtwidgets/analyzers/driver development/__init__.py'

Target //:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 21.960s, Critical Path: 0.18s
INFO: 2 processes: 2 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target

mchristen-astranis avatar Jan 30 '24 01:01 mchristen-astranis

Consider using https://rules-python.readthedocs.io/en/latest/api/pip.html#package-annotation instead in your setup to add the extra excludes. There is also a bzlmod example for this: https://github.com/bazelbuild/rules_python/blob/main/examples/bzlmod/MODULE.bazel#L84

aignas avatar Jan 31 '24 05:01 aignas

Thank you very much! I'll give that a shot

mchristen-astranis avatar Jan 31 '24 17:01 mchristen-astranis