This is an automated email from the ASF dual-hosted git repository. rskraba pushed a commit to branch branch-1.9 in repository https://gitbox.apache.org/repos/asf/avro.git
commit a9f05b4f1a6316ffc5add33dbd2edf9012a093f3 Author: Michael A. Smith <[email protected]> AuthorDate: Wed Oct 9 16:32:42 2019 -0400 AVRO-2576: Fix Premature Import pycodestyle (#664) * AVRO-2445: Remove SimpleJSON License and Rat Excludes * AVRO-2576: Fix Premature Import pycodestyle * AVRO-2576: Run pycodestyle from setup for py2 * AVRO-2576: Fix and Ignore Lint Failures * AVRO-2576: Update Setuptools * AVRO-2576: Use Local pycodestyle If We Can * AVRO-2576: Run isort from setuptools * AVRO-2576: Include isort at setuptools time * AVRO-2576: Rat Exclude Python Setup Files --- LICENSE.txt | 25 -------------- lang/py/.gitignore | 3 +- lang/py/build.sh | 3 +- lang/py/setup.cfg | 4 +-- lang/py/setup.py | 50 +++++++++++++++++++++++++-- lang/py/src/avro/protocol.py | 1 + lang/py/src/avro/tether/tether_task_runner.py | 2 +- lang/py3/.gitignore | 1 + lang/py3/setup.cfg | 6 +++- lang/py3/setup.py | 9 ++++- pom.xml | 44 +++++++++++++---------- share/docker/Dockerfile | 13 +++++-- 12 files changed, 104 insertions(+), 57 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 4a89170..7e159a6 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -296,31 +296,6 @@ Copyright (C) 2006 Toni Ronkko | OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------------------- -License for simplejson used in the python implementation: - -Source from: https://github.com/simplejson/simplejson - -Copyright (c) 2006 Bob Ippolito - -| Permission is hereby granted, free of charge, to any person obtaining a copy of -| this software and associated documentation files (the "Software"), to deal in -| the Software without restriction, including without limitation the rights to -| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -| of the Software, and to permit persons to whom the Software is furnished to do -| so, subject to the following conditions: -| -| The above copyright notice and this permission notice shall be included in all -| copies or substantial portions of the Software. -| -| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -| SOFTWARE. - ----------------------------------------------------------------------- License for ivy-2.2.0.jar used in the python implementation: Apache License version 2.0 (see above) diff --git a/lang/py/.gitignore b/lang/py/.gitignore index 44d9b58..ef29019 100644 --- a/lang/py/.gitignore +++ b/lang/py/.gitignore @@ -1,4 +1,5 @@ +*.egg-info/ +.eggs/ build/ lib/ userlogs/ -*.egg-info/ diff --git a/lang/py/build.sh b/lang/py/build.sh index 662d854..33040d8 100755 --- a/lang/py/build.sh +++ b/lang/py/build.sh @@ -28,8 +28,7 @@ main() { for target; do case "$target" in lint) - ./setup.py isort - pycodestyle . + ./setup.py isort lint ;; test) ant test diff --git a/lang/py/setup.cfg b/lang/py/setup.cfg index dc07a1d..1f6fbfa 100644 --- a/lang/py/setup.cfg +++ b/lang/py/setup.cfg @@ -19,7 +19,7 @@ line_length = 150 known_third_party=zope [pycodestyle] +exclude = .eggs,build +ignore = E101,E111,E114,E121,E122,E124,E125,E126,E127,E128,E129,E201,E202,E203,E222,E226,E225,E231,E241,E251,E261,E262,E265,E266,E301,E302,E303,E305,E306,E402,E501,E701,E703,E704,E711,E722,W191,W291,W292,W293,W391,W503,W504,W601 max-line-length = 150 statistics = True -exclude = build -ignore = E101,E111,E114,E121,E122,E124,E125,E126,E127,E128,E129,E201,E202,E203,E222,E226,E225,E231,E241,E251,E261,E262,E265,E266,E301,E302,E303,E305,E306,E402,E501,E701,E703,E704,E711,W191,W291,W292,W293,W391,W503,W601 diff --git a/lang/py/setup.py b/lang/py/setup.py index 6902116..6063869 100755 --- a/lang/py/setup.py +++ b/lang/py/setup.py @@ -16,15 +16,61 @@ # See the License for the specific language governing permissions and # limitations under the License. + +import distutils.errors +import glob +import os +import subprocess + import setuptools +def _get_version(): + curdir = os.getcwd() + version_file = ("VERSION.txt" if os.path.isfile("VERSION.txt") + else os.path.join(curdir[:curdir.index("lang/py")], "share/VERSION.txt")) + with open(version_file) as verfile: + # To follow the naming convention defined by PEP 440 + # in the case that the version is like "x.y.z-SNAPSHOT" + return verfile.read().rstrip().replace("-", "+") + + +class LintCommand(setuptools.Command): + """Run pycodestyle on all your modules""" + description = __doc__ + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + # setuptools does not seem to make pycodestyle available + # in the pythonpath, so we do it ourselves. + try: + env = {'PYTHONPATH': next(glob.iglob('.eggs/pycodestyle-*.egg'))} + except StopIteration: + env = None # pycodestyle is already installed + p = subprocess.Popen(['python', '-m', 'pycodestyle', '.'], close_fds=True, env=env) + if p.wait(): + raise distutils.errors.DistutilsError("pycodestyle exited with a nonzero exit code.") + + setuptools.setup( name = 'avro', - version = '@AVRO_VERSION@', + version = _get_version(), packages = ['avro'], - package_dir = {'avro': 'src/avro'}, + package_dir = {'': 'src'}, scripts = ["./scripts/avro"], + setup_requires = [ + 'isort', + 'pycodestyle', + ], + cmdclass={ + "lint": LintCommand, + }, #include_package_data=True, package_data={'avro': ['LICENSE', 'NOTICE']}, diff --git a/lang/py/src/avro/protocol.py b/lang/py/src/avro/protocol.py index 20ce2d5..f5c333b 100644 --- a/lang/py/src/avro/protocol.py +++ b/lang/py/src/avro/protocol.py @@ -24,6 +24,7 @@ except ImportError: from md5 import md5 import json + from avro import schema # diff --git a/lang/py/src/avro/tether/tether_task_runner.py b/lang/py/src/avro/tether/tether_task_runner.py index 33d224a..b248ffd 100644 --- a/lang/py/src/avro/tether/tether_task_runner.py +++ b/lang/py/src/avro/tether/tether_task_runner.py @@ -96,7 +96,7 @@ class TaskRunnerResponder(ipc.Responder): def HTTPHandlerGen(runner): """ This is a class factory for the HTTPHandler. We need - a factory b\c we need a reference to the runner + a factory because we need a reference to the runner Parameters ----------------------------------------------------------------- diff --git a/lang/py3/.gitignore b/lang/py3/.gitignore index 777f026..9714b18 100644 --- a/lang/py3/.gitignore +++ b/lang/py3/.gitignore @@ -1,3 +1,4 @@ +.eggs/ avro/HandshakeRequest.avsc avro/HandshakeResponse.avsc avro/VERSION.txt diff --git a/lang/py3/setup.cfg b/lang/py3/setup.cfg index 108c740..89b17fe 100644 --- a/lang/py3/setup.cfg +++ b/lang/py3/setup.cfg @@ -42,6 +42,9 @@ package_dir = avro = avro include_package_data = true packages = avro +setup_requires = + isort + pycodestyle install_requires = zip_safe = true scripts = @@ -68,6 +71,7 @@ line_length = 150 known_third_party=zope [pycodestyle] +exclude = .eggs,build +ignore = E111,E114,E121,E122,E124,E127,E128,E129,E201,E202,E203,E221,E225,E231,E241,E261,E301,E302,E303,E305,E402,E701,E703,E722,W503,W504 max-line-length = 150 statistics = True -ignore = E111,E114,E121,E122,E124,E127,E128,E129,E201,E202,E203,E221,E225,E231,E241,E261,E301,E302,E303,E305,E402,E701,E703,W503 diff --git a/lang/py3/setup.py b/lang/py3/setup.py index 130ce18..20dd4e2 100755 --- a/lang/py3/setup.py +++ b/lang/py3/setup.py @@ -32,6 +32,7 @@ import distutils.errors import distutils.file_util import distutils.log import fnmatch +import glob import os import subprocess @@ -146,8 +147,14 @@ class LintCommand(setuptools.Command): pass def run(self): + # setuptools does not seem to make pycodestyle available + # in the pythonpath, so we do it ourselves. try: - subprocess.run(['pycodestyle', '.'], check=True) + env = {'PYTHONPATH': next(glob.iglob('.eggs/pycodestyle-*.egg'))} + except StopIteration: + env = None # pycodestyle is already installed + try: + subprocess.run(['python3', '-m', 'pycodestyle', '.'], env=env) except subprocess.CalledProcessError: raise distutils.errors.DistutilsError("pycodestyle exited with a nonzero exit code.") diff --git a/pom.xml b/pom.xml index bb4f8bc..631fa60 100644 --- a/pom.xml +++ b/pom.xml @@ -49,15 +49,15 @@ <!-- plugin versions --> <antrun-plugin.version>1.8</antrun-plugin.version> - <checkstyle-plugin.version>3.0.0</checkstyle-plugin.version> + <checkstyle-plugin.version>3.1.0</checkstyle-plugin.version> <enforcer-plugin.version>3.0.0-M2</enforcer-plugin.version> <extra-enforcer-rules.version>1.2</extra-enforcer-rules.version> <gpg-plugin.version>1.6</gpg-plugin.version> - <javadoc-plugin.version>3.1.0</javadoc-plugin.version> + <javadoc-plugin.version>3.1.1</javadoc-plugin.version> <maven-plugin-plugin.version>3.6.0</maven-plugin-plugin.version> <rat.version>0.13</rat.version> <source-plugin.version>3.0.1</source-plugin.version> - <spotless-maven-plugin.version>1.21.1</spotless-maven-plugin.version> + <spotless-maven-plugin.version>1.25.1</spotless-maven-plugin.version> </properties> <modules> @@ -290,6 +290,7 @@ <!-- build or test files (some are generated files that we commit as-is for testing purposes) --> <exclude>**/*.log</exclude> <exclude>**/*.rej</exclude> + <exclude>**/*.egg-info/**</exclude> <exclude>build/**</exclude> <exclude>doc/build/**</exclude> <exclude>lang/java/archetypes/**</exclude> @@ -301,7 +302,6 @@ <exclude>lang/perl/pm_to_blib</exclude> <exclude>lang/perl/blib/**/.exists</exclude> <exclude>lang/py/build/**</exclude> - <exclude>lang/py3/avro_python3.egg-info/**</exclude> <exclude>lang/ruby/Gemfile.lock</exclude> <exclude>lang/ruby/avro.gemspec</exclude> <exclude>lang/ruby/.gem/**</exclude> @@ -351,36 +351,42 @@ <exclude>lang/csharp/Avro.sln</exclude> <!-- visual studio --> <!-- build-related files --> <exclude>**/README.md</exclude> - <exclude>BUILD.md</exclude> - <exclude>.travis.yml</exclude> <exclude>**/VERSION.txt</exclude> <exclude>**/dependency-reduced-pom.xml</exclude> + <exclude>.travis.yml</exclude> + <exclude>BUILD.md</exclude> + <exclude>lang/c/src/avro-c.pc.in</exclude> + <exclude>lang/csharp/**/bin/Release/**/Avro.xml</exclude> + <exclude>lang/csharp/TestResult.xml</exclude> + <exclude>lang/csharp/src/apache/*/obj/**</exclude> + <exclude>lang/java/archetypes/avro-service-archetype/src/test/integration/projects/basic/goal.txt</exclude> + <exclude>lang/java/mapred/userlogs/**</exclude> + <exclude>lang/java/tools/userlogs/**</exclude> + <exclude>lang/js/coverage/**</exclude> + <exclude>lang/js/test/mocha.opts</exclude> <exclude>lang/perl/.shipit</exclude> - <exclude>lang/perl/inc/Module/Install/*.pm</exclude> - <exclude>lang/perl/inc/Module/Install.pm</exclude> - <exclude>lang/perl/Makefile*</exclude> <exclude>lang/perl/META.yml</exclude> <exclude>lang/perl/MYMETA.yml</exclude> + <exclude>lang/perl/Makefile*</exclude> + <exclude>lang/perl/inc/Module/Install.pm</exclude> + <exclude>lang/perl/inc/Module/Install/*.pm</exclude> + <exclude>lang/py/.eggs/**</exclude> + <exclude>lang/py/build/**</exclude> + <exclude>lang/py/dist/**</exclude> <exclude>lang/py/userlogs/**</exclude> - <exclude>lang/c/src/avro-c.pc.in</exclude> + <exclude>lang/py3/.eggs/**</exclude> + <exclude>lang/py3/build/**</exclude> + <exclude>lang/py3/dist/**</exclude> <exclude>lang/ruby/Manifest</exclude> - <exclude>lang/java/tools/userlogs/**</exclude> - <exclude>lang/java/mapred/userlogs/**</exclude> - <exclude>lang/java/archetypes/avro-service-archetype/src/test/integration/projects/basic/goal.txt</exclude> - <exclude>lang/js/test/mocha.opts</exclude> - <exclude>lang/csharp/TestResult.xml</exclude> - <exclude>lang/csharp/src/apache/*/obj/**</exclude> - <exclude>lang/csharp/**/bin/Release/**/Avro.xml</exclude> - <exclude>lang/js/coverage/**</exclude> <!-- text documentation files --> <exclude>CHANGES.txt</exclude> <exclude>DIST_README.txt</exclude> <exclude>lang/perl/Changes</exclude> <exclude>lang/c/README.maintaining_win32.txt</exclude> <exclude>lang/c/docs/index.txt</exclude> + <exclude>.github/PULL_REQUEST_TEMPLATE.md</exclude> <exclude>lang/java/archetypes/avro-service-archetype/src/test/integration/projects/basic/archetype.properties</exclude> <!-- used to generate user projects --> <!-- files and directories covered by LICENSE.txt --> - <exclude>lang/py/lib/simplejson/**</exclude> <exclude>lang/c/jansson/**</exclude> <exclude>lang/c/src/avro/msinttypes.h</exclude> <exclude>lang/c/src/avro/msstdint.h</exclude> diff --git a/share/docker/Dockerfile b/share/docker/Dockerfile index c6944ce..726d321 100644 --- a/share/docker/Dockerfile +++ b/share/docker/Dockerfile @@ -53,7 +53,6 @@ RUN apt-get -qq update && \ g++ \ gcc \ git \ - isort \ libboost-all-dev \ libfontconfig1-dev \ libfreetype6-dev \ @@ -69,14 +68,14 @@ RUN apt-get -qq update && \ php5.6-gmp \ pycodestyle \ python \ - python-isort \ python-pip \ python-setuptools \ python-snappy \ python-wheel \ - python3-isort \ python3-pip \ python3-setuptools \ + python3-snappy \ + python3-wheel \ rake \ ruby \ ruby-dev \ @@ -98,6 +97,14 @@ RUN curl -L https://cpanmin.us | perl - --self-upgrade && \ # Install PHPUnit RUN wget -O /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-5.6.phar && chmod +x /usr/local/bin/phpunit +# Install Python2 packages +RUN python2 -m pip install --upgrade pip setuptools \ + && python2 -m pip install zstandard + +# Install Python3 packages +RUN python3 -m pip install --upgrade pip setuptools \ + && python3 -m pip install zstandard + # Install Ruby modules RUN gem install echoe yajl-ruby multi_json snappy
