-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: replace deprecated pkg_resources #7026
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,6 @@ py_library( | |
| ":grpc_provider", | ||
| ":ingester", | ||
| "//tensorboard:expect_grpc_installed", | ||
| "//tensorboard:expect_pkg_resources_installed", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need an equivalent expect_packaging_installed, for this to work with our internal repo. |
||
| "//tensorboard/data/proto:protos_all_py_pb2", | ||
| "//tensorboard/util:tb_logging", | ||
| ], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| # limitations under the License. | ||
|
|
||
|
|
||
| import pkg_resources | ||
| from packaging.version import parse as parse_version | ||
|
|
||
| from tensorboard import test as tb_test | ||
| from tensorboard import version | ||
|
|
@@ -22,21 +22,14 @@ | |
| class VersionTest(tb_test.TestCase): | ||
| def test_valid_pep440_version(self): | ||
| """Ensure that our version is PEP 440-compliant.""" | ||
| # pkg_resources.parse_version() doesn't have a public return type, | ||
| # so we get a handle to it by parsing known good and bad versions. | ||
| # | ||
| # Note: depending on the version of the module (which is bundled | ||
| # with setuptools), when called with a non-compliant version, it | ||
| # either returns a `LegacyVersion` (setuptools < 66) or raises an | ||
| # `InvalidVersion` exception (setuptools >= 66). Handle both cases. | ||
| compliant_version = pkg_resources.parse_version("1.0.0") | ||
| compliant_version = parse_version("1.0.0") | ||
| try: | ||
| legacy_version = pkg_resources.parse_version("arbitrary string") | ||
| legacy_version = parse_version("arbitrary string") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the replacement for this function should have a consistent behavior for the non-compliant ones, so this try-except shouldn't be necessary anymore. |
||
| except Exception: | ||
| legacy_version = None | ||
| self.assertNotEqual(type(compliant_version), type(legacy_version)) | ||
|
|
||
| tensorboard_version = pkg_resources.parse_version(version.VERSION) | ||
| tensorboard_version = parse_version(version.VERSION) | ||
| self.assertIsInstance(tensorboard_version, type(compliant_version)) | ||
|
|
||
|
|
||
|
|
||
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.
Here's where it would need to be updated for the new library instead.