-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: support sourceRoot
selection
#118
base: main
Are you sure you want to change the base?
Conversation
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.
please format with cargo fmt
src/main.rs
Outdated
} | ||
|
||
if is_target_for_packaging(subdir.path()) { | ||
sourceroot_candidates.push(subdir.path()); |
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 might be able to use file_name
here instead, so we don't have to do strip_prefix
later. the same applies to open_subdirs
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.
file_name
only returns the final component, not the N - 1 final components
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 doesn't work with cargoHash
and probably vendorHash
src/main.rs
Outdated
.parse() | ||
.ok() | ||
.and_then(|i: usize| sourceroot_candidates.get(i)) | ||
.unwrap_or_else(|| &sourceroot_candidates[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.
we should still allow packages to opt out of sourceRoot even when there are candidates
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.
hmmm why?
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.
workspaces?
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.
e.g. there can be a rust binary at root that also have a library and a python binding of the library in a subdirectory, but we might want the rust binary instead of the python binding
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 only have to make it so that sourceRoot candidate include the root src dir, right?
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.
actually why
let src_dir = choice
.parse()
.ok()
.and_then(|i: usize| sourceroot_candidates.get(i))
.unwrap_or_else(|| &sourceroot_candidates[0]);
let source_root = if src_dir != &root_src_dir {
Some(src_dir)
} else {
None
};
is not enough?
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.
if your choice is the rootdir, then you don't get a sourceRoot
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.
that would also work, but we would need extra logic to be able to omit the sourceRoot =
part
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.
actually why <...> is not enough?
I haven't checked since the current HEAD is not building for me, but I think source_candidates
never contains root_src_dir
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.
yes, fixing
5ad1ba8
to
3918c06
Compare
This is now possible to package from a mono-repository, check opentelemetry-python for a usecase.
FFS, encountered the first thing that overcomes the depth check: https://github.com/NiklasRosenstein/python-nr.util |
might be a good idea to add a configuration and cli flag, but we can do that in a separate pr |
This is now possible to package from a mono-repository, check opentelemetry-python for a usecase.