-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[BEAM-3738] Enable py3 lint and cleanup tox.ini. #4877
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/bin/bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| # This script is used to remove generated files in previous Tox runs so that | ||
| # they are not picked up by tests. | ||
|
|
||
| set -e | ||
|
|
||
| for dir in apache_beam target/build; do | ||
| if [ -d "${dir}" ]; then | ||
| for ext in pyc c so; do | ||
| find ${dir} -type f -name "*.${ext}" -delete | ||
| done | ||
| fi | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,11 +113,8 @@ def get_version(): | |
| 'futures>=3.1.1,<4.0.0', | ||
| ] | ||
|
|
||
| REQUIRED_SETUP_PACKAGES = [ | ||
| 'nose>=1.0', | ||
| ] | ||
|
|
||
| REQUIRED_TEST_PACKAGES = [ | ||
| 'nose>=1.3.7', | ||
|
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. Why are we increasing the required version for nose?
Member
Author
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. tox.ini already required 1.3.7. I thought this would be a no-op.
Member
Author
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 also wanted to merge requirements. Now only setup.py has the nose requirement.
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. Sounds good. |
||
| 'pyhamcrest>=1.9,<2.0', | ||
| ] | ||
|
|
||
|
|
@@ -177,6 +174,9 @@ def generate_common_urns(): | |
| + '\n') | ||
| generate_common_urns() | ||
|
|
||
| python_requires = '>=2.7' | ||
| if os.environ.get('BEAM_EXPERIMENTAL_PY3') is None: | ||
| python_requires += ',<3.0' | ||
|
|
||
| setuptools.setup( | ||
| name=PACKAGE_NAME, | ||
|
|
@@ -202,9 +202,8 @@ def generate_common_urns(): | |
| 'apache_beam/utils/counters.py', | ||
| 'apache_beam/utils/windowed_value.py', | ||
| ]), | ||
| setup_requires=REQUIRED_SETUP_PACKAGES, | ||
| install_requires=REQUIRED_PACKAGES, | ||
| python_requires='>=2.7,<3.0', | ||
| python_requires=python_requires, | ||
| test_suite='nose.collector', | ||
| tests_require=REQUIRED_TEST_PACKAGES, | ||
| extras_require={ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,142 +17,107 @@ | |
|
|
||
| [tox] | ||
| # new environments will be excluded by default unless explicitly added to envlist. | ||
| # TODO (after BEAM-3671) add lint_py3 back in. | ||
| envlist = py27,py27gcp,py27cython,lint_py2,docs | ||
| envlist = py27,py27-{gcp,cython2,lint},py3-lint,docs | ||
| toxworkdir = {toxinidir}/target/.tox | ||
|
|
||
| [pycodestyle] | ||
| # Disable all errors and warnings except for the ones related to blank lines. | ||
| # pylint does not check the number of blank lines. | ||
| select = E3 | ||
|
|
||
| # Shared environment options. | ||
| [testenv] | ||
| # Set [] options for pip installation of apache-beam tarball. | ||
| extras = test | ||
| # Don't warn that these commands aren't installed. | ||
| whitelist_externals = | ||
| find | ||
| time | ||
|
|
||
| [testenv:py27] | ||
| # autocomplete_test depends on nose when invoked directly. | ||
| deps = | ||
| nose==1.3.7 | ||
| grpcio-tools==1.3.5 | ||
| whitelist_externals=find | ||
| commands = | ||
| python --version | ||
| pip --version | ||
| # Clean up all previous python generated files. | ||
| - find apache_beam -type f -name '*.pyc' -delete | ||
| pip install -e .[test] | ||
| {toxinidir}/run_tox_cleanup.sh | ||
| python apache_beam/examples/complete/autocomplete_test.py | ||
| python setup.py test | ||
| passenv = TRAVIS* | ||
| {toxinidir}/run_tox_cleanup.sh | ||
|
|
||
| [testenv:py27cython] | ||
| # This environment will fail in Jenkins if named "py27-cython". | ||
|
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. For my education, do you know why it fails?
Member
Author
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. No bleeding clue. Since I don't have ssh access I can't really debug it. |
||
| [testenv:py27-cython2] | ||
| # cython tests are only expected to work in linux (2.x and 3.x) | ||
| # If we want to add other platforms in the future, it should be: | ||
| # `platform = linux2|darwin|...` | ||
| # See https://docs.python.org/2/library/sys.html#sys.platform for platform codes | ||
| platform = linux2 | ||
| # autocomplete_test depends on nose when invoked directly. | ||
| deps = | ||
| nose==1.3.7 | ||
| grpcio-tools==1.3.5 | ||
| cython==0.25.2 | ||
| whitelist_externals= | ||
| find | ||
| time | ||
| cython==0.26.1 | ||
|
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. Curious why this version? Latest is 0.28.1.
Member
Author
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. This is the minimum version required by Side note: 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. +1 on a single requirements.txt file.
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. That is fair to not change the version in this PR. We should consider upgrading it. It would be nice to have a single source of truth. Although I do not see how pip-compile can update the Dockerfile. It is worth filing a JIRA for that.
Member
Author
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. pip-compile can generate requirements.txt from setup.py, and the docker image can pull that in. |
||
| commands = | ||
| python --version | ||
| pip --version | ||
| # Clean up all previous python generated files. | ||
| - find apache_beam -type f -name '*.pyc' -delete | ||
| # Clean up all previous cython generated files. | ||
| - find apache_beam -type f -name '*.c' -delete | ||
| - find apache_beam -type f -name '*.so' -delete | ||
| - find target/build -type f -name '*.c' -delete | ||
| - find target/build -type f -name '*.so' -delete | ||
| time pip install -e .[test] | ||
| {toxinidir}/run_tox_cleanup.sh | ||
| python apache_beam/examples/complete/autocomplete_test.py | ||
| python setup.py test | ||
| # Clean up all cython generated files. Ignore if deletion fails. | ||
| - find apache_beam -type f -name '*.c' -delete | ||
| - find apache_beam -type f -name '*.so' -delete | ||
| - find target/build -type f -name '*.c' -delete | ||
| - find target/build -type f -name '*.so' -delete | ||
| passenv = TRAVIS* | ||
| {toxinidir}/run_tox_cleanup.sh | ||
|
|
||
| [testenv:py27gcp] | ||
| # autocomplete_test depends on nose when invoked directly. | ||
| deps = | ||
| nose==1.3.7 | ||
| whitelist_externals=find | ||
| [testenv:py27-gcp] | ||
| extras = test,gcp | ||
| commands = | ||
| python --version | ||
| pip --version | ||
| pip install -e .[test,gcp] | ||
| # Clean up all previous python generated files. | ||
| - find apache_beam -type f -name '*.pyc' -delete | ||
| {toxinidir}/run_tox_cleanup.sh | ||
| python apache_beam/examples/complete/autocomplete_test.py | ||
| python setup.py test | ||
| passenv = TRAVIS* | ||
| {toxinidir}/run_tox_cleanup.sh | ||
|
|
||
| [testenv:lint_py2] | ||
| deps= | ||
| nose==1.3.7 | ||
| [testenv:py27-lint] | ||
| deps = | ||
| pycodestyle==2.3.1 | ||
| pylint==1.7.2 | ||
| future==0.16.0 | ||
| isort==4.2.15 | ||
| flake8==3.5.0 | ||
| whitelist_externals=time | ||
| commands = | ||
| python --version | ||
| pip --version | ||
| time pip install -e .[test] | ||
| time {toxinidir}/run_pylint.sh | ||
| passenv = TRAVIS* | ||
|
|
||
| [testenv:lint_py3] | ||
| deps= | ||
| nose==1.3.7 | ||
| [testenv:py3-lint] | ||
| deps = | ||
| pycodestyle==2.3.1 | ||
| pylint==1.7.2 | ||
| future==0.16.0 | ||
| isort==4.2.15 | ||
| flake8==3.5.0 | ||
| whitelist_externals=time | ||
| setenv = | ||
| BEAM_EXPERIMENTAL_PY3=1 | ||
| commands = | ||
| time pip install -e .[test] | ||
| python --version | ||
| pip --version | ||
| time {toxinidir}/run_mini_py3lint.sh | ||
| passenv = TRAVIS* | ||
|
|
||
|
|
||
| [testenv:docs] | ||
| deps= | ||
| nose==1.3.7 | ||
| grpcio-tools==1.3.5 | ||
| extras = test,gcp,docs | ||
| deps = | ||
| Sphinx==1.6.5 | ||
| sphinx_rtd_theme==0.2.4 | ||
| whitelist_externals=time | ||
| commands = | ||
| python --version | ||
| pip --version | ||
| time pip install -e .[test,gcp,docs] | ||
| time {toxinidir}/generate_pydoc.sh | ||
| passenv = TRAVIS* | ||
|
|
||
| [testenv:cover] | ||
| # This is not included in envlist which is defined in [tox]. | ||
| deps = | ||
| coverage==4.4.1 | ||
| nose==1.3.7 | ||
| whitelist_externals=find | ||
| commands = | ||
| python --version | ||
| pip --version | ||
| pip install -e .[test,gcp] | ||
| # Clean up all previous python generated files. | ||
| - find apache_beam -type f -name '*.pyc' -delete | ||
| {toxinidir}/run_tox_cleanup.sh | ||
| # Clean up previously collected data. | ||
| coverage erase | ||
| coverage run setup.py test | ||
| # Print coverage report to STDOUT | ||
| coverage report --skip-covered | ||
| # Generate report in xml format | ||
| coverage xml | ||
| passenv = TRAVIS* | ||
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.
Is not this required by setup, because test_suite references it?
Uh oh!
There was an error while loading. Please reload this page.
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.
Does it make sense to raise REQUIRED_PIP_VERSION = '7.0.0' to something a closer to the current 9.0.3 or do we leave that alone for now? Alternatively, should the process do pip install --upgrade pip?
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.
@aaltay setup_requires= lists packages required to run setup.py. I couldn't see why nose is required for that.
Specifying nose in the tests_require= keyword arg is sufficient.
@cclauss I would like to leave it alone in this PR, and I don't have any objection to raising the required version.
Note that creating a new virtualenv installs (at least for me) a version of pip that's newer than the system installed version (9.0.2 vs 9.0.1).
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.
Is there a reason for us to raise the required 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.
Python packaging has changed a lot in the past three years especially in relation to Python 3 requirements https://pip.pypa.io/en/stable/news We want to avoid compatibility issues in the migration to https://github.com/pypa/warehouse
Uh oh!
There was an error while loading. Please reload this page.
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.
The virtualenv does bring a pip but it can be upgraded by pip (bootstrapping).
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.
@cclauss Are you referring to a specific issue?
REQUIRED_PIP_VERSIONis just the minimum version we require, we are not force downgrading to that version. If there is a known issue in compatibility we can consider raising the minimum supported versionThere 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.
@udim Is it required to run
python setup.py test. If not we can drop it.