Skip to content
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

The great toxification (part 4) #4120

Merged
merged 3 commits into from Oct 17, 2017

Conversation

stephenfin
Copy link
Contributor

Subject: Clean up requirements

Clean up requirements (test-reqs.txt, setup.py) to ensure virtualenv and non-virtualenv builds are identical

Feature or Bugfix

  • Feature

Purpose

To paraphrase the Zen of Python (import this):

tox is one honking great idea -- let's use more of it!

Start modernizing the test infrastructure that's using make and other hand-crafted tools by replacing them with tox-based derivatives.

This is part four.

Detail

This is a multi-step process, with the end goal of completely removing the Makefile and running everything through tox. The first fours steps of these can be done in parallel, but combined they block the final two.

  1. Make tox a little more friendly by enabling extras like coverage, test profiling etc. by default, and closing gaps with the current Makefile targets such as PyLint and building docs in particular formats
  2. Replace/remove custom tooling found in utils in favor of modern alternatives like flake8
  3. Centralize as much configuration as possible inside setup.cfg and tox.ini, to avoid polluting the top level directory.
  4. Clean up requirements (test-reqs.txt, setup.py) to ensure virtualenv and non-virtualenv builds are identical (this change)

The remaining two steps are blocked by the above:

  1. Switch CIs to use tox instead of the Makefile, and update CONTRIBUTING.rst to refer to tox. Deprecate the Makefile
  2. (Bonus) Integrate codecov.io to make use of the coverage stats we now have

Relates

  • N/A

@stephenfin stephenfin force-pushed the the-great-toxification-4 branch 2 times, most recently from aa0217b to c845424 Compare October 5, 2017 10:09
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

Basically LGTM, but it seems all tests are failed. could you check it please?

setup.py Outdated
@@ -63,25 +63,27 @@
':python_version<"3.5"': [
'typing'
],
':python_version<"3.4"': [
'enum34'
Copy link
Member

Choose a reason for hiding this comment

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

Hmm? Why did you add this to dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used in the Sphinx source, though currently surrounded by a try-except ImportError. I figured we should just make it a requirement so we can remove that try-except. Did I misinterpret something?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it's not dependency. It is used to inspect user's program on autodoc module when the program uses enum. So it is not requirements of Sphinx itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll add it to tests instead so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait - we distribute autodoc as part of Sphinx. Therefore shouldn't we provide all the dependencies for that module with Sphinx?

Copy link
Member

Choose a reason for hiding this comment

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

autodoc uses enum only if it is installed. It means autodoc imports it only if the target program uses it. So enum34 is a requirement of target program.
In other words, it is not "requirements", but also "optional".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll move this to test so

'websupport': [
'sqlalchemy>=0.9',
'whoosh>=2.0',
],
'test': [
'pytest',
'mock', # it would be better for 'test:python_version in 2.7'
'simplejson', # better: 'test:platform_python_implementation=="PyPy"'
Copy link
Member

Choose a reason for hiding this comment

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

+1; now pypy provides optimized json package :-)

@stephenfin stephenfin force-pushed the the-great-toxification-4 branch 6 times, most recently from 5a68613 to 4eb1407 Compare October 5, 2017 19:09
@stephenfin
Copy link
Contributor Author

Basically LGTM, but it seems all tests are failed. could you check it please?

This is done now

.travis.yml Outdated
- pip install -r test-reqs.txt
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then python3.6 -m pip install mypy typed-ast; fi
- pip install .[test,websupport]
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then python3.6 -m pip install mypy typed-ast flake8; fi
Copy link
Member

Choose a reason for hiding this comment

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

Is it okay to execute flake8 only with python3.6? Once I saw a blog article saying flake8 should be executed with all interpreters. Please let me know if you know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good point, but I don't think it's something to worry about too much for now. Part 5 will introduce tox-travis so we'll have a chance to completely rework what jobs we run and maybe use flake8 on Py2.7 too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've modified this now so it'll build against all versions of Python

@tk0miya
Copy link
Member

tk0miya commented Oct 9, 2017

@shimizukawa I need your help for this. Could you review this please?

Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

LGTM with nits

requires.append('colorama>=0.3.5')

if sys.version_info < (3, 5):
requires.append('typing')
Copy link
Member

Choose a reason for hiding this comment

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

I think this removing lines means 'drop support pip-1.5.6'.
Maybe such environment is very rare nowadays, however it would be better if it is indicated on CHANGES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shimizukawa I've refrained from touching CHANGES because it causes merge conflicts and you guys usually do it. Should I do this or can I simply call it out in the commit message as I've done and leave the CHANGES update to maintainers?

On a side note, have you seen reno? Is this something you might be open to using in Sphinx in a future release?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I'll update CHANGES on merging.

This version is silly old and anyone that's _still_ using this is not
going to be building Sphinx from source. Simply remove it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Simply installing packages will ensure that most of the dependencies in
'setup.py' are installed, meaning 'test-reqs.txt' need only contain
those necessary for testing.

The only notable change is that the 'simplejson' module is dropped from
the requirements list. This included as a dependency for the PyPy
target, but it appears that this is not necessary today (though it may
have been when the target was added in 2011).

This retains 'setup.py test' which, as noted in the tox docs [1], is
sometimes expected for downstream distribution testing. We may wish to
find a way to synchronize requirements between 'test-reqs.txt' and this
section in the future, but that's work for another day.

[1] https://tox.readthedocs.io/en/latest/example/basic.html#integration-with-setup-py-test-command

Signed-off-by: Stephen Finucane <stephen@that.guru>
We were never really using this file for its specified purpose [1]. Now
that we have everything cleanly organized in 'setup.py', there really
isn't any reason to keep it around. Remove it.

[1] https://caremad.io/posts/2013/07/setup-vs-requirement/

Signed-off-by: Stephen Finucane <stephen@that.guru>
@stephenfin
Copy link
Contributor Author

I've resolved the merge conflict. In the process, I realized that there's actually no reason whatsoever to keep test-req.txt around so I've removed it. We weren't really using it for it's true purpose so getting rid of it seemed like the thing to do.

@stephenfin
Copy link
Contributor Author

@tk0miya @shimizukawa Is there anything more I need to do for this?

@tk0miya
Copy link
Member

tk0miya commented Oct 17, 2017

It seems all review are passed now. So I'll merge this tonight (in JST)

@tk0miya tk0miya merged commit cfa2eff into sphinx-doc:master Oct 17, 2017
@tk0miya
Copy link
Member

tk0miya commented Oct 17, 2017

Merged! Thank you for your contribution!

@stephenfin
Copy link
Contributor Author

Lovely. Thanks for the reviews, @tk0miya 😄

@stephenfin stephenfin deleted the the-great-toxification-4 branch October 18, 2017 08:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants