diff --git a/.travis.yml b/.travis.yml index c56f43f6dc0..a3171ff7061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -166,12 +166,6 @@ jobs: go: $TRAVIS_GO_VERSION stage: test - # Docs - - os: linux - env: TARGETS="docs" - go: $TRAVIS_GO_VERSION - stage: test - # Kubernetes - os: linux install: deploy/kubernetes/.travis/setup.sh @@ -199,7 +193,6 @@ jobs: retries: true update: true packages: - - python-virtualenv - libpcap-dev - xsltproc - libxml2-utils @@ -218,16 +211,22 @@ addons: config: retries: true update: true + sources: + - deadsnakes packages: - - python-virtualenv - libpcap-dev - xsltproc - libxml2-utils - libsystemd-journal-dev - librpm-dev + # From deadsnakes PPA + - python3.6 + - python3.6-venv before_install: + - if [ x$TRAVIS_DIST = xtrusty ]; then sudo ln -sf python3.6 /usr/bin/python3; fi - python --version + - python3 --version - umask 022 - chmod -R go-w $GOPATH/src/github.com/elastic/beats # Docker-compose installation diff --git a/Makefile b/Makefile index c8421ffc800..8567031ad1e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat PROJECTS=libbeat $(BEATS) PROJECTS_ENV=libbeat filebeat metricbeat PYTHON_ENV?=$(BUILD_DIR)/python-env -VIRTUALENV_PARAMS?= +PYTHON_EXE?=python3 +PYTHON_ENV_EXE=${PYTHON_ENV}/bin/$(notdir ${PYTHON_EXE}) +VENV_PARAMS?= FIND=find . -type f -not -path "*/vendor/*" -not -path "*/build/*" -not -path "*/.git/*" GOLINT=golint GOLINT_REPO=golang.org/x/lint/golint @@ -88,8 +90,8 @@ clean-vendor: .PHONY: check check: python-env @$(foreach var,$(PROJECTS) dev-tools $(PROJECTS_XPACK_MAGE),$(MAKE) -C $(var) check || exit 1;) - @# Checks also python files which are not part of the beats - @$(FIND) -name *.py -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false) + @$(FIND) -name *.py -name *.py -not -path "*/build/*" -not -path "*/vendor/*" -exec $(PYTHON_ENV)/bin/autopep8 -d --max-line-length 120 {} \; | (! grep . -q) || (echo "Code differs from autopep8's style" && false) + @$(FIND) -name *.py -not -path "*/build/*" -not -path "*/vendor/*" | xargs $(PYTHON_ENV)/bin/pylint --py3k -E || (echo "Code is not compatible with Python 3" && false) @# Validate that all updates were committed @$(MAKE) update @$(MAKE) check-headers @@ -136,13 +138,13 @@ docs: .PHONY: notice notice: python-env @echo "Generating NOTICE" - @$(PYTHON_ENV)/bin/python dev-tools/generate_notice.py . + @${PYTHON_ENV_EXE} dev-tools/generate_notice.py . # Sets up the virtual python environment .PHONY: python-env python-env: - @test -d $(PYTHON_ENV) || virtualenv $(VIRTUALENV_PARAMS) $(PYTHON_ENV) - @$(PYTHON_ENV)/bin/pip install -q --upgrade pip autopep8==1.3.5 six + @test -d $(PYTHON_ENV) || ${PYTHON_EXE} -m venv $(VENV_PARAMS) $(PYTHON_ENV) + @$(PYTHON_ENV)/bin/pip install -q --upgrade pip autopep8==1.3.5 pylint==2.4.4 @# Work around pip bug. See: https://github.com/pypa/pip/issues/4464 @find $(PYTHON_ENV) -type d -name dist-packages -exec sh -c "echo dist-packages > {}.pth" ';' diff --git a/Vagrantfile b/Vagrantfile index 68792c791a6..b7cc6f03523 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -24,8 +24,8 @@ # freebsd and openbsd # ------------------- # - Use gmake instead of make. -# - Folder syncing doesn't work well. Consider copying the files into the box or -# cloning the project inside the box. +# - Folder syncing doesn't work well. Consider copying the files into the box +# or cloning the project inside the box. ### # Read the branch's Go version from the .go-version file. @@ -82,27 +82,14 @@ if (-Not (Get-Command "choco" -ErrorAction SilentlyContinue)) { choco feature disable -n=showDownloadProgress if (-Not (Get-Command "python" -ErrorAction SilentlyContinue)) { - echo "Installing python2" - choco install python2 -y -r + echo "Installing python 3" + choco install python -y -r --version 3.8.1.20200110 refreshenv - $env:PATH = "$env:PATH;C:\\Python27;C:\\Python27\\Scripts" + $env:PATH = "$env:PATH;C:\\Python38;C:\\Python38\\Scripts" } -if (-Not (Get-Command "pip" -ErrorAction SilentlyContinue)) { - echo "Installing pip" - Invoke-WebRequest https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py - python get-pip.py -U --force-reinstall 2>&1 | %{ "$_" } - rm get-pip.py - Invoke-WebRequest -} else { - echo "Updating pip" - python -m pip install --upgrade pip 2>&1 | %{ "$_" } -} - -if (-Not (Get-Command "virtualenv" -ErrorAction SilentlyContinue)) { - echo "Installing virtualenv" - python -m pip install virtualenv 2>&1 | %{ "$_" } -} +echo "Updating pip" +python -m pip install --upgrade pip 2>&1 | %{ "$_" } if (-Not (Get-Command "git" -ErrorAction SilentlyContinue)) { echo "Installing git" @@ -113,6 +100,9 @@ if (-Not (Get-Command "gcc" -ErrorAction SilentlyContinue)) { echo "Installing mingw (gcc)" choco install mingw -y -r } + +echo "Setting PYTHON_ENV in VM to point to C:\\beats-python-env." +[System.Environment]::SetEnvironmentVariable("PYTHON_ENV", "C:\\beats-python-env", [System.EnvironmentVariableTarget]::Machine) SCRIPT # Provisioning for Unix/Linux @@ -129,7 +119,7 @@ def linuxGvmProvision(arch="amd64") return <