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

feat: support sourceRoot selection #118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RaitoBezarius
Copy link
Member

This is now possible to package from a mono-repository, check opentelemetry-python for a usecase.

src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@figsoda figsoda left a 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 Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated
}

if is_target_for_packaging(subdir.path()) {
sourceroot_candidates.push(subdir.path());
Copy link
Member

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

Copy link
Member Author

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

src/main.rs Outdated Show resolved Hide resolved
Copy link
Member

@figsoda figsoda left a 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]);
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workspaces?

Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member Author

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?

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member

@figsoda figsoda Jun 9, 2023

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fixing

@RaitoBezarius RaitoBezarius force-pushed the sourceroot branch 3 times, most recently from 5ad1ba8 to 3918c06 Compare June 9, 2023 18:38
This is now possible to package from a mono-repository, check opentelemetry-python for a usecase.
@RaitoBezarius
Copy link
Member Author

FFS, encountered the first thing that overcomes the depth check: https://github.com/NiklasRosenstein/python-nr.util

@figsoda
Copy link
Member

figsoda commented Jun 10, 2023

might be a good idea to add a configuration and cli flag, but we can do that in a separate pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants