Coder Social home page Coder Social logo

Comments (5)

vonschultz avatar vonschultz commented on September 18, 2024 1

Yes, that works. Thank you!

(Full disclosure: I had to change $(location [...]) to $(rlocationpath [...]) and use bazel_tools.tools.python.runfiles in my wrapper to find the file, but that may be because I'm upgrading to Bazel 7 and is probably unrelated to Buildozer itself.)

from buildozer.

fmeum avatar fmeum commented on September 18, 2024 1

I would recommend using @rules_python//python/runfiles instead as it's compatible with Bzlmod and maintained.

from buildozer.

fmeum avatar fmeum commented on September 18, 2024

It's not currently built in a way that would properly support this use case, which is why the target hasn't been marked public yet.

What would you like to do with the target? I can look into adding support for your use case.

from buildozer.

vonschultz avatar vonschultz commented on September 18, 2024

I'm doing

load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
expand_template(
    name = "make_buildozer_wrapper",
    out = "buildozer_wrapper.py",
    data = ["@buildozer"],
    substitutions = {
        "$(location @buildozer//:buildozer)": (
            "$(location @buildozer//:buildozer)"
        ),
    },
    template = "buildozer_wrapper.tpl.py",
)

The wrapper does some set up, calls buildozer with subprocess.run() and the path from the location substitution, and then tidies up.

The wrapper use case is generic, in that different people may want to do different things. My specific use case is to first rename all the BUILD.bazel files to BUILD as buildozer doesn't (didn't?) support BUILD.bazel files, and then rename them back again after buildozer ran, as well as mapping return codes 0 and 3 from buildozer (success with changes, and success without changes) to return code 0 from the wrapper. (The wrapper is called by a shell script that does the desired changes, and the shell considers exit code 3 a failure.)

from buildozer.

fmeum avatar fmeum commented on September 18, 2024

Could you try replacing @buildozer//:buildozer with the contents of load("@buildozer//:buildozer.bzl", "BUILDOZER_LABEL")? That directly gives you the binary, not the wrapper target, which avoids the setup issues and is publicly visible. If that works, I can update https://github.com/fmeum/buildozer?tab=readme-ov-file#using-buildozer-in-repository-rules-and-module-extensions to mention this case.

from buildozer.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.