Optionally allow a cwd for get_distribution_version_string #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Needed for matrix-org/synapse#12968.
Since we now use
poetry-core
to build distributions for Synapse, thelocate_file(".")
trick no longer seems to work to find Synapse's source directory.In principle we could do something like
__name__
inimportlib.metadata.packages_distributions()
, and use that to get a version as todaycwd
from the module's__file__
attribute and use that for the git invocationsUnfortunately the second step is brittle. When I tried to test this on matrix.org's configuration,
packages_distributions()["synapse"]
gave me a KeyError for my troubles.Instead, keep things simple and have the caller give us an optional cwd.
If accepted, I will do a minor release of matrix-python-common and change Synapse to depend on it in matrix-org/synapse#12973 (which is presently a WIP).