-
Notifications
You must be signed in to change notification settings - Fork 323
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
Use ruff-python-parser to compute Python imports #3103
base: main
Are you sure you want to change the base?
Conversation
@mikea when I try to run this with:
I get:
any ideas what I'm doing wrong? |
I get the same error when I try to run |
CI has a different error. You need this:
Workerd rust includes are prefixed with "workerd/" to disambiguate with edgeworker rust folders. |
something is broken for you since it can't even build kj:kj target (which has nothing to do with rust). I assume your environment is broken? This happens to me with workerd everytime I touch anything on my system. |
Thanks @mikea! I got it to work by running it from edgeworker, and get the same path error. After fixing that it seems to works correctly. |
2a6a506
to
7ada9d9
Compare
7ada9d9
to
51afa67
Compare
|
||
#[cxx::bridge(namespace = "edgeworker::rust::python_parser")] | ||
mod ffi { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have formatting enabled for Rust files. Can you run just rustfmt
to see if any formatting changes are being made? If yes, we need to fix this (in a separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do and --config=lint
should be checking it. Let me know if this is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran this and don't see any changes. Maybe it's already set up correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome to see rust usage!
Just a lot of nits, sorry.
deps/rust/cargo.bzl
Outdated
@@ -21,6 +21,8 @@ PACKAGES = { | |||
"pico-args": crate.spec(version = "0"), | |||
"proc-macro2": crate.spec(version = "1"), | |||
"quote": crate.spec(version = "1"), | |||
"ruff_python_ast": crate.spec(git = "https://github.com/astral-sh/ruff.git", tag = "0.7.0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any idea why the don't publish on crates.io ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that they have a big monorepo and don't really care about supporting downstream users of the crates only of the CLI tools they are used to define.
deps/rust/cargo.bzl
Outdated
@@ -21,6 +21,8 @@ PACKAGES = { | |||
"pico-args": crate.spec(version = "0"), | |||
"proc-macro2": crate.spec(version = "1"), | |||
"quote": crate.spec(version = "1"), | |||
"ruff_python_ast": crate.spec(git = "https://github.com/astral-sh/ruff.git", tag = "0.7.0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will need downstream changes to add these crates too.
|
||
#[cxx::bridge(namespace = "edgeworker::rust::python_parser")] | ||
mod ffi { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do and --config=lint
should be checking it. Let me know if this is not the case.
src/rust/python-parser/lib.rs
Outdated
mod ffi { | ||
|
||
extern "Rust" { | ||
fn get_imports(sources: &Vec<String>) -> Vec<String>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add some /// comments here. They will be visible from c++ code too.
Don't forget to document sorting behavior.
ouch. Windows as usual. The name doesn't seem to be really long, is windows limit so low??? Can we raise it?
|
@mikea we need to add a prefix for UNC paths to avoid such errors.
|
we can try doing it for C:\tmp that we set for bazel root |
6c100fc
to
225d6dc
Compare
225d6dc
to
ee358fb
Compare
The goal is to use ruff to replace Dominik's ad-hoc parser. This just adds the new code, I'll switch to using it and remove the old code in a followup.
ee358fb
to
cf7021d
Compare
Well I tried |
I think it should be "\\\\?\\C:\\tmp" |
Using
|
All the too long paths have |
@@ -49,6 +49,14 @@ inline kj::ArrayPtr<const char> fromRust(const ::rust::Str& str) { | |||
return kj::ArrayPtr<const char>(str.data(), str.size()); | |||
} | |||
|
|||
inline kj::Array<kj::String> fromRust(::rust::Vec<::rust::String> vec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This copies 😢
The goal is to use ruff to replace Dominik's ad-hoc parser. This just adds the
new code, I'll switch to using it and remove the old code in a followup.