10000 setup.py test as test entry point. by anntzer · Pull Request #8135 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

setup.py test as test entry point. #8135

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

Closed
wants to merge 2 commits into from

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Feb 23, 2017

This is a proof of concept that python setup.py test can be used as
entry point to the test suite.

python setup.py test will build matplotlib and run pytest locally.
There is no need to install matplotlib in a venv, setup.py test
apparently handles PYTHONPATH itself (and even the mpl_toolkits
namespace package seems to be handled properly). (In my opinion, this
is an unexpected big plus.)

The test section of setup.cfg had to be renamed to test_build as
it is otherwise interpreted as an option passed to setup.py test,
which it is not, right now. It may be advantageous to make

setup.py test --local-freetype=true

"work", but this would require more refactoring as setupext is
currently imported, and thus the choice of whether to use a local
freetype done, at the top of setup.py, before we know whether we are
going to run the test suite. This needs to be
documented.

Arguments to pytest are passed as

python setup.py test -a "$PYTEST_ARGS"

(as setup.py will swallow unspecified arguments itself).

The remaining setups in tests.py are setting the recursion limit and
turning on some deprecation warnings. I think the former can be
implemented as a local pytest plugin, and the latter as a session-scoped
fixture.

If we switch to this method, the CI scripts would need to be adjusted as
well.

The implementation is essentially copy-pasted from
http://doc.pytest.org/en/latest/goodpractices.html#manual-integration.

attn @tacaswell @phobson @QuLogic @Kojoley

@jenshnielsen
Copy link
Member

Looks cool. The main reason we removed support for setup.py test earlier was that it relied on test_requires which as far as I recalled relied on easy_install to install test dependencies as eggs which resulted in a number of issues

@anntzer
Copy link
Contributor Author
anntzer commented Feb 23, 2017

Yes, I explicitly do no want to use test_requires. But not declaring test_requires is no worse than the current situation, where test dependencies must be installed manually anyways (may be worth declaring an extra_requires so that one can do pip install matplotlib[test_requires] though).

@dopplershift
Copy link
Contributor

👍 to extra_requires.

@anntzer
Copy link
Contributor Author
anntzer commented Feb 24, 2017

The test failure is actually spurious (well, I didn't touch the command run by travis).

I think the first actionable items are

  • Add an extra_requires for test dependencies (can be done independently of this PR).
  • Move the code in tests.py (deprecation warnings and recursion limit) to something pytest can handle. The first one can either be a global fixture, or perhaps just applied as side-effect in conftest.py. The second one probably needs to become a local pytest plugin? (Not sure.) I think this item is required if we want to make setup.py test the "official" test runner (which does have some advantages, as mentioned above).

@QuLogic
Copy link
Member
QuLogic commented Feb 24, 2017

TBH, I don't see the point in keeping either of those. We've fixed the warnings and they aren't visible anyway (need to install pytest-warnings to show them at the end of the test run; maybe should add that to docs). The recursion limit thing is something that hasn't been triggered on CI yet.

@anntzer
Copy link
Contributor Author
anntzer commented Feb 24, 2017

I moved the local_freetype option back into the test section of setup.cfg (by introducing a do-nothing flag, documented as not to use, on the test command). Ultimately I'd like to move it out but that would require more in-depth changes to the architecture of the setup script (basically, only populate the extension list and check the entries when the build_ext command parses its options).

At that point (if this works for other people too) I think we need to decide whether to push this forward as the preferred entry point, and, if so, write the relevant documentation and update the CI scripts (although there's probably some value to keep at least one CI instance to test that the installed version works too).

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 24, 2017
@QuLogic
Copy link
Member
QuLogic commented May 15, 2017

Fixes #2175.

@anntzer anntzer mentioned this pull request May 19, 2017
6 tasks
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Aug 29, 2017
This is a proof of concept that `python setup.py test` can be used as
entry point to the test suite.

`python setup.py test` will build matplotlib and run `pytest` locally.
There is no need to install matplotlib in a venv, `setup.py test`
apparently handles `PYTHONPATH` itself (and even the `mpl_toolkits`
namespace package seems to be handled properly).  (In my opinion, this
is an unexpected big plus.)

The `test` section of `setup.cfg` had to be renamed to `test_build` as
it is otherwise interpreted as an option passed to `setup.py test`,
which it is not, right now.  It may be advantageous to make

    setup.py test --local-freetype=true

"work", but this would require more refactoring as `setupext` is
currently imported, and thus the choice of whether to use a local
freetype done, at the top of `setup.py`, before we know whether we are
going to run the test suite.  This needs to be
documented.

Arguments to `pytest` are passed as

    python setup.py test -a "$PYTEST_ARGS"

(as `setup.py` will swallow unspecified arguments itself).

The remaining setups in `tests.py` are setting the recursion limit and
turning on some deprecation warnings.  I think the former can be
implemented as a local pytest plugin, and the latter as a session-scoped
fixture.

If we switch to this method, the CI scripts would need to be adjusted as
well.

The implementation is essentially copy-pasted from
http://doc.pytest.org/en/latest/goodpractices.html#manual-integration.
If we did not overrider install_dists, setup.py test would install
dependencies using easy_install, which we definitely do not want.
@anntzer anntzer modified the milestones: needs sorting, unassigned Feb 15, 2018
@anntzer
Copy link
Contributor Author
anntzer commented Oct 5, 2018

Closing as I think that the general python ecosystem is moving towards tox for this kind of things, but we can always reopen if needed...

@anntzer anntzer closed this Oct 5, 2018
@anntzer anntzer deleted the setup.py-test branch October 5, 2018 12:53
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.

5 participants
0