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

Replace Bash ~and Python~ scripts with Rust #3349

Closed
emilk opened this issue Sep 18, 2023 · 7 comments
Closed

Replace Bash ~and Python~ scripts with Rust #3349

emilk opened this issue Sep 18, 2023 · 7 comments
Assignees
Labels
🧑‍💻 dev experience developer experience (excluding CI) enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@emilk
Copy link
Member

emilk commented Sep 18, 2023

We have a bunch of Python scripts in our repository for CI stuff, linting, etc.

We would like to replace them all with Rust, perhaps using something like xtask.

Some things we need to make sure of:

Related issues:


If we replace lint.py with Rust, we should consider using ast_grep_core of https://github.com/ast-grep/ast-grep

@emilk emilk added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed 🧑‍💻 dev experience developer experience (excluding CI) labels Sep 18, 2023
@abey79 abey79 added this to the 0.9.1 milestone Oct 9, 2023
@jleibs jleibs removed this from the 0.9.1 milestone Oct 9, 2023
@abey79
Copy link
Member

abey79 commented Oct 9, 2023

I feel Bash and Python scripts don't deserve the same treatment. Bash scripts are a plague on Windows, but the same is not true for Python, in the context of a project that otherwise heavily relies on a working Python install.

I, for one, feel like I'm leagues away from being as quick to improve on, e.g., upload_image.py if it was in Rust instead.

@emilk
Copy link
Member Author

emilk commented Oct 9, 2023

True, but python still requires a separate pip install -r … step at the moment which cargo run doesn't, but that may be something pixi will solve for us

@abey79
Copy link
Member

abey79 commented Oct 9, 2023

I'd argue our ubiquitous use of requirements.txt is a bit the issue there. We should put everything in pyproject.toml for a centralised, single source of truth, using this pattern:

[project.optional-dependencies]
tests = ["pytest==7.1.2"] # we somehow have this here already, not sure we actually use it
dev = [
    # .... put everything we need
]
docs = [
    # ... if we feel necessary, we can sub-categorise
]

Then, pip install -e ".[dev]" should do the trick.

The disadvantage is that these "extra" are published/visible to pypi. Poetry includes another mechanism (optional groups) that would be a better fit.

@emilk
Copy link
Member Author

emilk commented Oct 9, 2023

The point I was trying to make is that we are primarily a Rust shop. To work on e.g. the Rerun viewer, you should ideally need only to install Rust, and that's it. Anything beyond that are extra steps that we should try to avoid, including installing Python, pip, and any pip requirements.

Ideally you should only need to install Python if you are working on the Python SDK.
Just like you should only need to install a CMake if you are working on the C++ SDK.

@abey79
Copy link
Member

abey79 commented Oct 9, 2023

I'm not totally on-board with that.

Rust users should cargo add rerun and not have to think of Python—I agree with that. Contributors, on the other hand, are by nature exposed to the project's build system (in the broad meaning of the term).

The build system needs to strike a balance between up-front setup for contributor vs. constraints on its day-to-day maintenance/development. My position is that banning Python from the build system would shift that balance to a level that would overall be detrimental to the dev experience. This is obviously a somewhat subjective topic. Maybe less so is the question of being a contributor without the ability to run the Python test suite.

@emilk
Copy link
Member Author

emilk commented Jan 11, 2024

We (well, @jprochazk) have started porting more and more .sh and .py scripts to Rust, and so far I think it has been a win. However, so far each such "Rust script" has become its own separate crate, which I think is the wrong direction:

So, I think we should consider an xtask-esque approach, where a single Rust binary multiplexes out into different Rust "scripts", so that each script is just a file added to the same crate.

I've opened an issue for this:

@emilk emilk changed the title Replace Bash and Python scripts with Rust Replace Bash ~and Python~ scripts with Rust Apr 10, 2024
@Wumpf Wumpf self-assigned this Apr 15, 2024
@Wumpf
Copy link
Member

Wumpf commented Apr 15, 2024

all subtasks done now!

@Wumpf Wumpf closed this as completed Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants