Optionally allow a cwd for get_distribution_version_string #25
Merged
DMRobertson merged 2 commits intomainfrom Jun 7, 2022
Merged
Optionally allow a cwd for get_distribution_version_string #25DMRobertson merged 2 commits intomainfrom
DMRobertson merged 2 commits intomainfrom
Conversation
to workaround psf/black#2964
d4504da to
1b58254
Compare
DMRobertson
pushed a commit
to matrix-org/synapse
that referenced
this pull request
Jun 6, 2022
WIP. Fixes #12968. Requires matrix-org/matrix-python-common#25
4 tasks
Feels a bit icky, but this is hopefully good enough.
aaa6c39 to
c27e6d8
Compare
DMRobertson
commented
Jun 7, 2022
Comment on lines
+50
to
+51
| cwd: if provided, the directory to run all git commands in. `cwd` may also be | ||
| the path to a file, in which case `os.path.dirname(cwd)` is used instead. |
Contributor
Author
There was a problem hiding this comment.
I definitely had code which did this. Must have lost it when force pushing. Will fix on main branch and do another release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-coreto 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 todaycwdfrom 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).