Skip to content

Remove LooseVersion#10590

Merged
pllim merged 4 commits intoastropy:masterfrom
mwcraig:remove-LooseVersion
Jul 21, 2020
Merged

Remove LooseVersion#10590
pllim merged 4 commits intoastropy:masterfrom
mwcraig:remove-LooseVersion

Conversation

@mwcraig
Copy link
Copy Markdown
Member

@mwcraig mwcraig commented Jul 20, 2020

Description

This addresses part of #10578 by removing distutils.version.LooseVersion.

  • In the tests, packaging is added as a dependency and packaging.version.Version is used instead of LooseVersion. It does not seem problematic to me to add this as a test dependency.
  • In a couple of places (here and here) the version test was simple to replace.
  • One place I'm not sure how to handle: https://github.com/astropy/astropy/blob/master/astropy/utils/introspection.py#L153 . Writing a bit of code to do the check ourselves would be straightforward and avoid LooseVersion; alternatively, we could just move the import of LooseVersion inside of the function, which should remove the setuptools warnings.

@mwcraig
Copy link
Copy Markdown
Member Author

mwcraig commented Jul 20, 2020

@mhvk and @pllim -- here is the pull request I promised to take a stab at removing LooseVersion.

setup.cfg Outdated
coverage
skyfield>=1.20
sgp4>=2.3
packaging
Copy link
Copy Markdown
Member

@pllim pllim Jul 20, 2020

Choose a reason for hiding this comment

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

Shouldn't packaging be a runtime requirement now, like numpy and pyerfa?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't think so because it is only imported in the tests. Or at least that was the goal -- using packaging in the tests but not in the main package to avoid adding a new dependency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aha, I hadn't realized this would be just for testing - in that case we actually do not need to add a requirement at all, since pytest itself already requires packaging! (It must do its version tests in, e.g., pytest.importorskip with it...).

@pllim pllim added this to the v4.2 milestone Jul 20, 2020
@pllim pllim requested review from astrofrog and mhvk July 20, 2020 23:30
Copy link
Copy Markdown
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Always good to see actual code, since the worry about a dependency that I had is not warranted. Nice!

For introspection, I'm fine with going the easy route and simply move the import inside, with a comment on why. Alternatively, also fine with just seeing whether a simple use of the output of the regexp that is already there isn't good enough...

@mwcraig
Copy link
Copy Markdown
Member Author

mwcraig commented Jul 21, 2020

For introspection, I'm fine with going the easy route and simply move the import inside, with a comment on why. Alternatively, also fine with just seeing whether a simple use of the output of the regexp that is already there isn't good enough...

I think the regex works for getting the version number -- I don't want to write the code to do the comparison.

For now I've just moved the distutils import inside the function in introspection, but since pytest is already a hard requirement for astropy, and pytest requires packaging, couldn't we switch this to using packagin.version.Version too?

I had not realized that pytest requires packaging....

@pllim
Copy link
Copy Markdown
Member

pllim commented Jul 21, 2020

but since pytest is already a hard requirement for astropy

It shouldn't be though. Requiring it at runtime is a bug.

@mwcraig
Copy link
Copy Markdown
Member Author

mwcraig commented Jul 21, 2020

It shouldn't be though. Requiring it at runtime is a bug.

In that case the current fix should do the trick.

Copy link
Copy Markdown
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks all good to me!

Copy link
Copy Markdown
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Let's get this in. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants