Skip to content

Purge Python #110479

Closed
Closed
@Ezrashaw

Description

@Ezrashaw
Contributor

Running the command: fd --extension py -E src/llvm-project gives a list of python files in rust-lang/rust:

compiler/rustc_codegen_gcc/tools/check_intrinsics_duplicates.py
compiler/rustc_codegen_gcc/tools/generate_intrinsics.py
library/core/src/unicode/printable.py
src/bootstrap/bootstrap.py
src/bootstrap/bootstrap_test.py
src/bootstrap/configure.py
src/ci/cpu-usage-over-time.py
src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py
src/ci/docker/scripts/android-sdk-manager.py
src/ci/docker/scripts/fuchsia-test-runner.py
src/ci/github-actions/calculate-job-matrix.py
src/ci/scripts/upload-build-metrics.py
src/etc/dec2flt_table.py
src/etc/gdb_load_rust_pretty_printers.py
src/etc/gdb_lookup.py
src/etc/gdb_providers.py
src/etc/generate-deriving-span-tests.py
src/etc/generate-keyword-tests.py
src/etc/htmldocck.py
src/etc/lldb_batchmode.py
src/etc/lldb_lookup.py
src/etc/lldb_providers.py
src/etc/rust_types.py
src/tools/cargo/ci/generate.py
src/tools/cargo/publish.py
src/tools/clippy/util/versions.py
src/tools/miri/ci/scrape-targets.py
src/tools/miri/test-cargo-miri/run-test.py
src/tools/publish_toolstate.py
tests/debuginfo/auxiliary/dependency-with-embedded-visualizers.py
tests/debuginfo/embedded-visualizer-point.py
tests/debuginfo/embedded-visualizer.py
tests/run-make/debugger-visualizer-dep-info/my_gdb_script.py
tests/run-make/libtest-junit/validate_junit.py
x.py

While there will (probably) always be a need for a little bit of Python in bootstrap, we should aim to replace misc scripts that really should be Written In Rust. Especially relevant are files like src/etc/htmldocck.py which is the rustdoc UI test harness(!); we should rewrite this in Rust.

Extra points:

  • I wonder if CI scripts do actually need to be Python?
  • Longer term, I wonder if we can require a host installation of Rust (we just download one anyway) and use that for bootstrap?

Activity

Ezrashaw

Ezrashaw commented on Apr 18, 2023

@Ezrashaw
ContributorAuthor

cc @jyn514 am I crazy about getting rid of Python from bootstrap?

jyn514

jyn514 commented on Apr 18, 2023

@jyn514
Member

I don't see the point in rewriting all this code. The main goal of #94829 is so we don't make people deal with python before they start working on the repo; but half the scripts you mentioned are for CI only. What do we get from rewriting them?

Ezrashaw

Ezrashaw commented on Apr 18, 2023

@Ezrashaw
ContributorAuthor

I guess maintainability in a way. I mean, why is compiletest not written in Python? It then makes sense to have the rustdoc part of it written in the same language, possibly src/etc/htmldocck.py could be rewritten and moved into compiletest itself. I'm not saying that this is important, just that it's something that should happen at some point.

jyn514

jyn514 commented on Apr 18, 2023

@jyn514
Member

I don't think this is worth spending contributor time on. There are other ways people can get started contributing (https://rustc-dev-guide.rust-lang.org/#what-should-i-work-on).

Ezrashaw

Ezrashaw commented on Apr 18, 2023

@Ezrashaw
ContributorAuthor

I agree, I think it's just good to have this here as a long-term goal.

compiler-errors

compiler-errors commented on Apr 18, 2023

@compiler-errors
Member

It's probably worthwhile to first step back and characterize the existing python that we have. I think only once it's clear what python actually can be rewritten should we actually discuss whether it should be rewritten.

e.g. those gdb and llvm scripts can't be rewritten in rust afaict.

Ezrashaw

Ezrashaw commented on Apr 18, 2023

@Ezrashaw
ContributorAuthor

Yeah, perhaps CI scripts as well might not be rewritable?

I do think there is some low-hanging fruit here which could have tangible benefits.

added
T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
on Apr 18, 2023
thomcc

thomcc commented on Apr 18, 2023

@thomcc
Member

I have a rewrite of library/core/src/unicode/printable.py on another machine, moving it into the rest of the table generation code. I'll try to get it up when I'm more easily able to contribute.

self-assigned this
on Jun 4, 2023
thomcc

thomcc commented on Jun 4, 2023

@thomcc
Member

Assigning to myself to do this for the unicode tables because @jyn514 indicated it might be the only one that's worth doing (no strong opinions from me, although I don't like that one being python)

added a commit that references this issue on Aug 15, 2024

Auto merge of rust-lang#129111 - Zalathar:python-sysroot, r=<try>

added a commit that references this issue on Aug 15, 2024

Rollup merge of rust-lang#129111 - Zalathar:python-sysroot, r=jieyouxu

324025f

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @thomcc@compiler-errors@ChrisDenton@Kobzol@Zalathar

        Issue actions

          Purge Python · Issue #110479 · rust-lang/rust