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

Refactor Pex working directory handling. #12479

Merged
merged 2 commits into from
Aug 2, 2021

Conversation

jsirois
Copy link
Contributor

@jsirois jsirois commented Aug 1, 2021

Encapsulate working directory handling in PexEnvironment and
CompletePexEnvironment and force passing a value for the working
directory. Also refactor the venv pex script to fully handle
working directory issues on its own.

[ci skip-rust]
[ci skip-build-wheels]

Encapsulate working directory handling in PexEnvironment and
CompletePexEnvironment and for passing a value for the working
directory. Also refactor the venv pex script to fully handle
working directory issues on its own.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@jsirois
Copy link
Contributor Author

jsirois commented Aug 1, 2021

I'm not sure this is any better, but see what you think.

@jsirois jsirois requested a review from benjyw August 1, 2021 04:25
Copy link
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

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

Took me a while to follow, but this seems correct and better. Thanks!

append_only_caches=FrozenDict({cls._PEX_ROOT_DIRNAME: str(pex_root)}),
)


class WorkspacePexEnvironment(CompletePexEnvironment):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this class at all? Couldn't in_workspace() return a CompletePexEnvironment? If not for some reason I can't see, then possibly we want a similarly trivial SandboxPexEnvironment, for symmetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do if you hold being explicit about working directory as a goal, which I was. That said, I could churn a bit more and just eliminate the presence of any rule to produce any CompletePexEnvironment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! I would have also been fine with keeping WorkspacePexEnvironment but also having SandboxPexEnvironment. It just seemed odd to have one and not the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - that wouldn't really work since they used to be symmetric in requiring no input parameters (well both required just a PexEnvironment) but now are not. You must provide an additional input parameter to get a SandboxPexEnvironment now - the working directory - and so it cannot be a rule parameter like WorkspacePexEnvironment could be and still can be; so this was really the only route.

Instead have all injections be of PexEnvironment and force
all usages to call the appropriate in_... method.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@jsirois jsirois merged commit 650a9b3 into pantsbuild:main Aug 2, 2021
@jsirois jsirois deleted the pex/working_directory/follow-up branch August 2, 2021 21:37
jsirois added a commit to jsirois/pants that referenced this pull request Aug 13, 2021
This was missed in pantsbuild#12479.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@jsirois jsirois mentioned this pull request Aug 13, 2021
jsirois added a commit that referenced this pull request Aug 13, 2021
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.

3 participants