Skip to content

gh-105540: Show source files relative to root #106927

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

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Jul 20, 2023

This restores a corner case: when the generator is run with working directory set to Tools/cases_generator, the source filenames listed in the generated provenance header should be relative to the repo root directory.

@@ -1154,7 +1155,7 @@ def write_function(

def from_source_files(self) -> str:
paths = f"\n{self.out.comment} ".join(
prettify_filename(filename)
prettify_filename(os.path.relpath(filename, ROOT))
Copy link
Member

Choose a reason for hiding this comment

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

Tests fail again with ValueError: path is on mount 'C:', start on mount 'D:' because of tempdir location.

I think we can solve this by using something like:

try:
    filename = os.path.relpath(filename, ROOT))
except ValueError:
    # This can happen if `filename` and `ROOT` are on different disks on Win:
    pass

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Will do.

@gvanrossum gvanrossum merged commit 1218910 into python:main Jul 20, 2023
@gvanrossum gvanrossum deleted the add-relpath branch July 20, 2023 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants