-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
Move code around to declutter the src/python/pants
directory
#11458
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.
Excellent!
@@ -21,6 +20,11 @@ class DistDir: | |||
relpath: Path | |||
|
|||
|
|||
def is_child_of(path: Path, directory: Path) -> bool: | |||
abs_path = path if path.is_absolute() else directory.joinpath(path).resolve() |
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.
Hm this technically breaks the "no side effects" thing with the engine by calling .resolve()
. It's good this is now isolated to one place at least so that we're less likely to keep using it.
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 spent a bit of time looking to see if there was a Python stdlib function that did this check for us already, but didn't find a convenient one.
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 concern is more using Path().resolve()
. Ideally this function would solely use PurePath
and not Path
so that it didn't do any file operations. Those FS operations break the contract with the Rules API to avoid side effects.
This was a problem already before, so it's not a blocker. I'm not sure what the fix is in general, and this PR is good that it isolates this issue to only one call site.
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 should probably be implemented in terms of fast_relpath_optional
.
src/python/pants/init/util.py
Outdated
if len(workdir_src) > _MAX_FILENAME_LENGTH: | ||
logger.warning( | ||
f"The specified --pants-workdir `{workdir_src}` is longer than {_MAX_FILENAME_LENGTH}. This may be too long of a filename for some systems." | ||
) |
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 think this is fine, but please wait for an ack from someone else.
e64be8a
to
4d2c1d7
Compare
|
3218b2e
to
7f04c9f
Compare
So, while we should stop using Path-length and path-component-length are limited on real systems (many Docker mounts, for example), and when issues are encountered, they can break everything in surprising ways ("breaks only on my machine"). Particularly in large monorepos By "rebased directory structures", I'm referring to generating alternate destinations for a file/target like |
Makes sense. This was intended to be a quick refactor commit, and it sounds like actually getting rid of this functionality is both a good idea and would best be done in a separate chunk of work. I will put |
Mm, yea. Another reason to tackle this independently is that we now have duplicated codepaths doing this: pants/src/python/pants/build_graph/address.py Lines 301 to 318 in e9115cd
|
[ci skip-rust] [ci skip-build-wheels]
lock.py is only impored from in pantsd code. Moving the file to within pantsd makes the `src/python` directory structure less cluttered. [ci skip-rust] [ci skip-build-wheels]
7f04c9f
to
90cbb60
Compare
clean_global_runtime_state
in lieu of calling its single line at its single callsitelock.py
into thepantsd
directory, since it is only ever called there. This allowssrc/python/pants/process
to be removed.is_child_of
and its associated test to its single callsite. This allowssrc/python/pants/fs
to be removed.