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

Mark pants as an explicit namespace package (rather than implicit) #17563

Merged
merged 11 commits into from Nov 21, 2022

Conversation

thejcannon
Copy link
Member

@thejcannon thejcannon commented Nov 17, 2022

Now we aren't touching our source tree during tests, which is causing unintended side-effects in #17520, because really we shouldn't be assuming the process sandboxes for tests are mutable (at least in the source tree). Not to mention that lengthy comment in conftest.py which should raise alarm.

@thejcannon thejcannon added the category:internal CI, fixes for not-yet-released features, etc. label Nov 17, 2022
Copy link
Sponsor Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!

You'll want to force this to build/test the wheels, to make sure it doesn't break anything in there.

@thejcannon
Copy link
Member Author

(temporarily touching pants.toml to force CI to build+test wheels)

@kaos
Copy link
Member

kaos commented Nov 17, 2022

(temporarily touching pants.toml to force CI to build+test wheels)

coolest touch I've seen! :D

Copy link
Sponsor 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.

That comment is precisely what I wanted, thanks!

pants.toml Outdated
Comment on lines 69 to 84
# ___________ ____
# ______/ \__// \__/____\
# _/ \_/ : //____\\
# /| : : .. / \
# | | :: :: \ /
# | | :| || \ \______/
# | | || || |\ / |
# \| || || | / | \
# | || || | / /_\ \
# | ___ || ___ || | / / \
# \_-_/ \_-_/ | ____ |/__/ \
# _\_--_/ \ /
# /____ /
# / \ /
# \______\_________/
#
Copy link
Contributor

Choose a reason for hiding this comment

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

huh? nevermind

Copy link
Member Author

Choose a reason for hiding this comment

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

(temporarily touching pants.toml to force CI to build+test wheels)

Copy link
Member

Choose a reason for hiding this comment

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

huh? nevermind

was my reaction too... but I was "fortunate" enough to spot Josh's comment before saying anything ;)

@thejcannon
Copy link
Member Author

subprocess.CalledProcessError: Command '[PosixPath('/var/folders/y3/3xtfkj390kg4w2v44gyyfl7h0000gp/T/tmpf6fv4e0x/bin/python'), '-c', 'import pants.testutil.option_util, pants.testutil.rule_runner, pants.testutil.pants_integration_test']' returned non-zero exit status 1.

ruh roh

@thejcannon
Copy link
Member Author

Oh so the failures are only on MacOS? Bother...

@benjyw
Copy link
Sponsor Contributor

benjyw commented Nov 18, 2022

What's the issue with VERSION? That has been a constant thorn in our side.

@thejcannon
Copy link
Member Author

thejcannon commented Nov 18, 2022

@benjyw I updated the description to explain VERSION issues

@thejcannon
Copy link
Member Author

Buddy PR: pantsbuild/setup#135

@chrisjrn
Copy link
Contributor

Buddy PR: pantsbuild/setup#135

Suggest not merging this PR until we are confident that we can update the launcher script to be useful for people who are using PANTS_FROM_SHA. See the linked ticket for discussion.

src/python/pants/version/BUILD Outdated Show resolved Hide resolved
Copy link
Member

@jsirois jsirois left a comment

Choose a reason for hiding this comment

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

I missed the VERSION shenanigans. Its not clear to me this is ship-itable. I'll bow out - the overall motivation seems weakish and this VERSION bit seems slapdashish.

Copy link
Sponsor 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.

Not a fan of code in __init__.py, and we don't do that anywhere else in the repo, so why here? I'm not sure it's important that the import name remain the same? This isn't part of an external API...

Also, possibly we can temporarily have a copy of VERSION in the root, temporarily, until we sort out the pants script issues?

@thejcannon
Copy link
Member Author

Not a fan of code in init.py, and we don't do that anywhere else in the repo, so why here? I'm not sure it's important that the import name remain the same? This isn't part of an external API...

On the contrary, the module name is version and not _version or anything likewise "private". And to add fuel to the fire, with the rate at which we break the plugin API I would completely expect plugins in the wild to change their declarations based on Pants version. I wouldn't feel comfortable changing this in a non-backwards-compatible way.

An alternative solution is to keep version.py and have it re-export symbols from pants._version.<whatever>.

@thejcannon
Copy link
Member Author

@jsirois Can you be more specific? Your message only tells me how you feel about the change (and it isn't great) and not how to improve it so you feel differently. Otherwise it feels almost like criticism without the "constructive" bit 😞

@jsirois
Copy link
Member

jsirois commented Nov 18, 2022

The constructive bit is I'm clueless what is motivating this change. FWICT this shifts things around with no clear purpose or real upside. It started as that with the NS package re-jiggle and then added more apparently unmotivated changes with the VERSION thing. As such there is too much I don't understand here - clearly - to be a useful reiewer.

@thejcannon
Copy link
Member Author

thejcannon commented Nov 18, 2022

Hm, perhaps I split the VERSION change off into a dedicated PR then.

Hold on tight! 😄

(also, next time you're very welcome to say "hey I dont' understand why we're doing this. Can you update the description and/or make smaller PRs?". It's a lot less disheartening, and I very much value feedback. Especially yours)

@jsirois
Copy link
Member

jsirois commented Nov 18, 2022

@thejcannon thanks. I'll stay bowed out of both though. It seems like others already active here may be clued in more.

@thejcannon
Copy link
Member Author

OK version moving is now in #17582.

thejcannon added a commit that referenced this pull request Nov 21, 2022
This moves `VERSION` to be in a subdirectory of the main `pants` package. 

This is because loading resources from top-level names of namespace packages is extremely hand-wavy and ambiguous (Who "owns" `pants`? The `pants` package or the `pants.testutil` package?) So now we have it unambiguously in `pants/_version/`.

This pain is seen in #17563 which tries to convert `pants` to be an _explicit_ namespace package, which truly messes up resource loading via `pkgutil` and `importlib.resources` ([this long ticket](python/importlib_resources#68) has some context, too).

This PR makes `_version/VERSION` a symlink to the existing `VERSION` so that https://github.com/pantsbuild/setup isn't broken. This "works" because Pants is symlink oblivious in source-tree traversal, and therefore sees `pants/_version/VERSION` as `pants/VERSION`.
@thejcannon
Copy link
Member Author

Wheel building passed.

@thejcannon thejcannon merged commit a405486 into pantsbuild:main Nov 21, 2022
@thejcannon thejcannon deleted the explicit-namespace branch November 21, 2022 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants