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

Align cache directory calculation so that the LMDB store location is uniformly configurable #10391

Merged
merged 1 commit into from Jul 17, 2020

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented Jul 17, 2020

Problem

Because we have tried to keep it in sync across multiple consumers, the lmdb_store location does not obey the XDG_CACHE_HOME setting.

Solution

Align the calculation of the default location for the lmdb_store across rust and python. Unfortunately, this currently requires duplicating the relevant methods, in order to dodge a cycle between Native and build_environment.py, which is used transitively by BinaryUtil (via OptionsBootstrapper and options parsing) in this entrypoint to download tools used during rust bootstrap.

Result

The XDG_CACHE_HOME setting is respected for all cache-related options.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thank you!

@@ -34,7 +34,9 @@ def get_buildroot() -> str:

def get_pants_cachedir() -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only being used in BinaryUtil now, it would be good to move there. Ditto on pants_configdir. It reduces the risk of people accidentally using this.

Or, maybe even better, keep these, but have them return Native().default_cache_path(). Move this non-Rust version into BinaryUtil.

Copy link
Sponsor Member Author

@stuhood stuhood Jul 17, 2020

Choose a reason for hiding this comment

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

It goes much deeper than that, unfortunately... follow the references from the method I linked in the description:

if __name__ == "__main__":
print(select(sys.argv))

...and you'll find that it uses the OptionsBootstrapper and a bunch of other APIs, which have lots of dependencies throughout the system.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

But maybe I don't understand what you're suggesting.

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion is to stop implementing any custom logic in base/build_environment.py. Solely have this function return Native().default_cache_path(). Move this implementation to binary_util.py.

But, actually, don't spend time on this. It's not that big of a deal because you have the new unit tests. It's not worth spending more time on this, imo.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Move this implementation to binary_util.py.

Yea, unfortunately that won't work: see my expanded response above.

@@ -54,6 +56,11 @@ impl NamedCaches {
NamedCaches { local_base }
}

// This default suffix is also hard-coded into the Python options code in global_options.py
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add to global_options.py a note about the duplication.

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

It's there already: see the edit I made in that file.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thank you again!

@stuhood stuhood merged commit f824da3 into pantsbuild:master Jul 17, 2020
@stuhood stuhood deleted the stuhood/align-cache-roots branch July 17, 2020 19:27
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