Code Monkey home page Code Monkey logo

Comments (3)

allsey87 avatar allsey87 commented on July 17, 2024

I tried to place the python_rules stuff into WORKSPACE instead of MODULE.bazel, this is currently what my WORKSPACE file looks like:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "c68bdc4fbec25de5b5493b8819cfc877c4ea299c0dcb15c244c5a00208cde311",
    strip_prefix = "rules_python-0.31.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.31.0/rules_python-0.31.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
    name = "python_3_11_3",
    python_version = "3.11.3",
)

load("@python_3_11_3//:defs.bzl", "interpreter")

http_archive(
    name = "emsdk",
    sha256 = "8b5b3433eb732dcc7643a2707a12fd5cbe793a5dadbbae9a60c24a737a78fe33",
    strip_prefix = "emsdk-3.1.45/bazel",
    url = "https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.45.tar.gz",
)

load("@emsdk//:deps.bzl", emsdk_deps = "deps")
emsdk_deps()

load("@emsdk//:emscripten_deps.bzl", emsdk_emscripten_deps = "emscripten_deps")
emsdk_emscripten_deps(emscripten_version = "3.1.45")

load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")
register_emscripten_toolchains()

This doesn't change anything though, I still get the same error about python3 not being found... This is with Bazel 7.1.1 .

from emsdk.

allsey87 avatar allsey87 commented on July 17, 2024

This error also happens when cloning emsdk and attempting to build the hello-world-wasm target with bazel build :hello-world-wasm.

For reference, I am building inside of a Docker container:

FROM python:3.11.6-slim-bookworm
ENV SHELL /bin/bash
ARG user_id=1000
ARG group_id=1000
ARG bazel_version=7.1.1

RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
    build-essential \
    ca-certificates \
    curl \
    git \
    openjdk-17-jdk \
    sudo \
    unzip \
    zip \
    && rm -rf /var/lib/apt/lists/*

# Download Bazel
WORKDIR /tmp
RUN curl \
    --fail \
    --location \
    --remote-name \
    "https://github.com/bazelbuild/bazel/releases/download/${bazel_version}/bazel-${bazel_version}-linux-x86_64"
RUN mv "bazel-${bazel_version}-linux-x86_64" /usr/local/bin/bazel
RUN chmod +x /usr/local/bin/bazel
# Download Bazel buildtools
RUN curl \
    --fail \
    --location \
    --remote-name \
    "https://github.com/bazelbuild/buildtools/releases/download/v${bazel_version}/buildifier-linux-amd64"
RUN mv "buildifier-linux-amd64" /usr/local/bin/buildifier
RUN chmod +x /usr/local/bin/buildifier

# Create a developer user
ARG user_id=1000
ARG group_id=1000
RUN groupadd --gid ${group_id} developer && \
    useradd --uid ${user_id} --gid ${group_id} -m developer -s /bin/bash && \
    echo developer ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer

# Switch the developer user
USER developer

from emsdk.

allsey87 avatar allsey87 commented on July 17, 2024

After a lot of trial and error, I managed to solve this by changing the Docker image's base layer from python:3.11.6-slim-bookworm to debian:bookworm-slim and installing python3 with apt.

As I understand, the issue was that python-rules needs a local interpreter to bootstrap the interpreter that is going to be used by python-rules. However, due to however python-rules/bazel is handling PATH etc, the difference in how Python was installed was enough to break stuff.

from emsdk.

Related Issues (20)

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.