Skip to content

Stop using bundled pytest version - #5694

Merged
bsipocz merged 17 commits into
astropy:masterfrom
astrofrog:remove-bundled-pytest
May 10, 2017
Merged

bsipocz merged 17 commits into
astropy:masterfrom
astrofrog:remove-bundled-pytest

Conversation

@astrofrog

@astrofrog astrofrog commented Jan 13, 2017 •

Copy link
Copy Markdown
Member

As described in #5509, we should probably remove the bundled version of pytest. If we decide to do this, this PR is a WIP to do it.

This replaces the pytest in astropy.tests.helper by the standalone one to make sure the import still works. I've tested a couple of affiliated packages and they work fine with this, i.e. the pytest 3.x issues we had in the core were due to the custom plugins, but most affiliated packages don't have that issue. So I don't think we need to keep the bundled version temporarily or anything, I think it might just be fine this way. However, it would help if different affiliated package maintainers could verify this.

Adding a deprecation warning for the pytest import from astropy.tests.helper isn't easy to do, but I'm not convinced it's really needed since we need to import pytest in astropy.tests.helper anyway, so we won't be removing that import.

Things that still need to be done:

EDIT: Also see #5678, #5697

Edit: close #5974

@bsipocz

bsipocz commented Jan 13, 2017

Copy link
Copy Markdown
Member

@astrofrog - Will astropy formally add pytest to the requirements? @larrybradley raised this in
astropy/photutils#491 (comment) to have as a guidance for photutils.

@astrofrog

Copy link
Copy Markdown
Member Author

@bsipocz - if we do do this (and we've by no means made that decision) then we'll add py.test as a formal requirement to run the test suite (not to just use astropy)

@pllim

pllim commented Jan 18, 2017

Copy link
Copy Markdown
Member

I opened a PR against this PR at astrofrog#63 for some stuff that might be useful but did not make it into #5688, as a reminder if nothing else. FYI.

@bsipocz

bsipocz commented Jan 18, 2017

Copy link
Copy Markdown
Member

Without extra hacks (e.g. using ASTROPY_USE_SYSTEM_PYTEST or similar), it seems that before this makes it into release, affiliates are stuck with the bundled version, as it is already imported to the pytest namespace by the time the tests get to the point of importing the system pytest.

e.g. here astropy/photutils#491

@astrofrog
astrofrog force-pushed the remove-bundled-pytest branch from e4dcacd to beae79f Compare January 19, 2017 17:44
@astrofrog

Copy link
Copy Markdown
Member Author

@mhvk - any idea what the failures are due to here? Seems to be using pytest 2.7.2, but not sure why that would cause the errors shown.

@mhvk

mhvk commented Jan 19, 2017

Copy link
Copy Markdown
Contributor

@astrofrog - I did change DocTestTextFilePlus to use a feature that was common to the bundled pytest and pytest 3.x, but which may well have made it incompatible with earlier versions. Indeed, @pllim found that she had to fix pytest to >=3 to avoid getting pytest 2.7 being pulled in. Perhaps it is easiest to do that here too? See 07ef877

@astrofrog

Copy link
Copy Markdown
Member Author

@mhvk - indeed, the bundled version is 2.8 and on Python 3.3, pytest 2.7 is installed, so I guess our infrastructure only works for 2.8+. I'll make sure to mention that in the requirements now for testing when updating the docs.

Comment thread .travis.yml Outdated
- source ci-helpers/travis/setup_conda_$TRAVIS_OS_NAME.sh

# Workaround for Python 3.3, for which pytest 2.8 or greater is not available
- if [[ $PYTHON_VERSION == 3.3 ]] then;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

3.3 ]] then; --> 3.3 ]]; then

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.

Ugh, I always get that wrong. Thanks!

@astrofrog
astrofrog force-pushed the remove-bundled-pytest branch 3 times, most recently from 1e2cb84 to 131258d Compare January 20, 2017 09:23
@astrofrog

Copy link
Copy Markdown
Member Author

So one option here is to actually still remove the bundled pytest and just import the built-in one into astropy.tests.helper - that way the import will still work, but affiliated packages will still need to make sure that their tests pass with pytest 3.x. However since all the plugins have been fixed here, there might not actually be anything to fix in affiliated packages. For now, I've done this here so that we can test different affiliated packages with this branch.

In addition, I've removed the workaround from #811 to check whether the bug has been fixed.

@astrofrog

Copy link
Copy Markdown
Member Author

Looks like the problem reported in #811 for which we had a workaround has been fixed for a couple of years (pytest-dev/pytest#112), so I think it's safe to remove the workaround.

@astrofrog
astrofrog force-pushed the remove-bundled-pytest branch from 6d91cd3 to cbdd7c4 Compare January 20, 2017 12:52
@astrofrog astrofrog changed the title WIP: stop using bundled pytest version Stop using bundled pytest version Jan 20, 2017
@astrofrog

Copy link
Copy Markdown
Member Author

This is ready for feedback!

Comment thread astropy/utils/tests/test_console.py Outdated
from ...extern.six import next
from ...extern.six.moves import range

import pytest

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

move this up to the standard library imports (nit picking but I couldn't resist as you had this fixed everywhere else)

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.

Fixed

@bsipocz

bsipocz commented Jan 20, 2017

Copy link
Copy Markdown
Member

LGTM, thanks @astrofrog!

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a small comment about six import but I see that its import locations are mixed up everywhere anyway. I guess we can worry about it in 3 years when we stop Python 2 support. Nothing some grep and sed can't fix.

I really appreciate all the other import clean-ups!

Before merge, someone needs to carefully inspect all the PR test logs to make sure tests are running as expected (no missing doctest, etc) using the appropriate versions (no sneaky pytest 2.7). Also make sure any remaining warnings are expected.

from .. import Constant
from ...units import Quantity as Q
from ...tests.helper import pytest
from ...extern import six

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change is unrelated to pytest. Also personally, I prefer to group six with __future__ for easy removal when we stop Python 2 support, as they both are for the same purpose.

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.

Fixed

@astrofrog
astrofrog force-pushed the remove-bundled-pytest branch from 2676332 to a02992b Compare May 9, 2017 22:00
@astrofrog

Copy link
Copy Markdown
Member Author

I've rebased this - @bsipocz would you be happy to review this? (to make sure I didn't mess anything up during rebase)

@astrofrog

Copy link
Copy Markdown
Member Author

As discussed with @eteq and @Cadair, we should add pytest as a runtime dependency for Astropy 2.0 to make things completely backward compatible. This actually makes sense anyway since Astropy provides pytest plugins which do have a dependency on pytest.

In future (e.g. Astropy 3.0) we could then consider removing pytest from the dependencies but as @Cadair pointed out, we could even keep it indefinitely.

In any case, once this is merged we should send an email to astropy-dev to explain this change.

@eteq

eteq commented May 9, 2017

Copy link
Copy Markdown
Member

To add just a bit more to #5694 (comment), the argument for keeping it as a runtime dependency is primarily that we are providing plugins for pytest, so we should consider it a dependency. Although maybe we should call it an "optional dependency"?

(Doesn't hold this up, just recording some of the discussion)

@eteq eteq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One minor change suggested, but otherwise looks good (with the discussion referenced above in mind)

Comment thread setup.py Outdated

setup_requires = ['numpy>=' + astropy.__minimum_numpy_version__]
install_requires = ['numpy>=' + astropy.__minimum_numpy_version__]
install_requires = ['pytest', 'numpy>=' + astropy.__minimum_numpy_version__]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be pytest>2.8 instead of just pytest? The minversion in setup.cfg I think is not known by setup.py so e.g. a pip install won't update it as needed.

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.

Yep, fixed!

@astrofrog
astrofrog force-pushed the remove-bundled-pytest branch from 18cb93a to e68015d Compare May 9, 2017 23:00
@bsipocz

bsipocz commented May 10, 2017

Copy link
Copy Markdown
Member

Who wants to have the honours to push the green button? @astrofrog?

@astrofrog

Copy link
Copy Markdown
Member Author

I think for big PRs it's best if it's not the author that merges, so feel free to do it :)

@bsipocz
bsipocz merged commit 611c487 into astropy:master May 10, 2017
@bsipocz

bsipocz commented May 10, 2017

Copy link
Copy Markdown
Member

🎉

Big thanks to @astrofrog to make this happen.

@bsipocz

bsipocz commented Jun 3, 2017

Copy link
Copy Markdown
Member

I wonder whether this will need a what's new entry?

@pllim

pllim commented Jun 5, 2017

Copy link
Copy Markdown
Member

I wonder whether this will need a what's new entry?

This is equivalent to things like "dropping package x.x support", right? IMHO, if we don't put those in "what's new", I don't think it is needed here.

@bsipocz

bsipocz commented Jun 5, 2017

Copy link
Copy Markdown
Member

Well, I would argue that this is very much different. While it doesn't have any effect on the simple user, it may have huge impact on packages that use the previously recommended way of using the bundled version directly from astropy, so it's more like a significant API change than just dropping a version support for something ancient. What I couldn't decide who the target audience for the "what's new". I expect maintainers to look at the full changelog and astropy-dev lists rather than the "what's new", but is that a good enough assumption?

@Cadair

Cadair commented Jun 5, 2017

Copy link
Copy Markdown
Member

putting something like "astropy now depends on external pytest, this will be installed by default" shouldn't confuse the less technical users.

@bsipocz

bsipocz commented Jun 5, 2017 •

Copy link
Copy Markdown
Member

But that wouldn't ring a bell for me as a maintainer either :) Anyway, as I said having just the changelog and the astropy-dev e-mail is probably enough.

@mhvk

mhvk commented Jun 6, 2017

Copy link
Copy Markdown
Contributor

Maintainers like @olebole already unbundled pytest (in fact, one of the reasons we knew the version we used was getting rather old...). But perhaps he can still comment on what he would generally look at.

@olebole

olebole commented Jun 6, 2017

Copy link
Copy Markdown
Member

I would recommend to have a statement like the one suggested by @Cadair here -- for a new version I usually check the Changelog for things like this when creating a Debian release.
However, in my "affiliated-package-maintainer" role (for python-cpl), I would usually ignore this; I would just install the newest version and RTFM only if there is a problem. So, maybe this should be sent to the affiliated mailing list as well (and maybe that mailing list could be promoted a bit as being useful for all developers of packages dependent on astropy).

saimn added a commit to saimn/astropy that referenced this pull request Oct 13, 2017
Bundled pytest was removed in v2.0 (astropy#5694) so it must now be imported
directly.
@astrofrog
astrofrog deleted the remove-bundled-pytest branch November 14, 2018 15:28
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.

Make ASTROPY_USE_SYSTEM_PYTEST configurable

8 participants