Skip to content

Commit

Permalink
Update to python3
Browse files Browse the repository at this point in the history
add python-env to make targets
  • Loading branch information
simitt committed Feb 20, 2020
1 parent a6a05e3 commit 44a39f8
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 30 deletions.
5 changes: 2 additions & 3 deletions .ci/docker/golang-mage/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ RUN git clone https://github.com/magefile/mage \
&& go get github.com/elastic/apm-server/vendor/golang.org/x/tools/cmd/goimports

RUN apt-get update -y -qq \
&& apt-get install -y -qq python-pip \
&& rm -rf /var/lib/apt/lists/* \
&& pip install virtualenv
&& apt-get install -y -qq python3 python3-pip python3-venv \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /go
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ MAINTAINER Nicolas Ruflin <[email protected]>
RUN set -x && \
apt-get update && \
apt-get install -y --no-install-recommends \
netcat python-pip virtualenv && \
netcat python3 python3-pip python3-venv && \
apt-get clean

RUN pip install --upgrade setuptools
ENV PYTHON_ENV=/tmp/python-env

RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools

# Setup work environment
ENV APM_SERVER_PATH /go/src/github.com/elastic/apm-server
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ES_SUPERUSER_PASS?=changeme

# updates beats updates the framework part and go parts of beats
.PHONY: update-beats
update-beats: govendor
update-beats: python-env govendor
rm -rf vendor/github.com/elastic/beats
@govendor fetch github.com/elastic/beats/...@$(BEATS_VERSION)
@govendor fetch github.com/elastic/beats/libbeat/generator/fields@$(BEATS_VERSION)
Expand Down Expand Up @@ -140,7 +140,7 @@ staticcheck:
check-deps: test-deps golint staticcheck

.PHONY: check-full
check-full: check-deps check
check-full: python-env check-deps check
@# Validate that all updates were committed
@$(MAKE) update
@$(MAKE) check
Expand All @@ -164,7 +164,7 @@ apm-docs: ## @build Builds the documentation for APM Server and APM Overview


.PHONY: update-beats-docs
update-beats-docs:
update-beats-docs: python-env
@python script/copy-docs.py
@$(MAKE) docs

Expand Down Expand Up @@ -198,7 +198,7 @@ import-dashboards:
echo "APM loads dashboards via Kibana, not the APM Server"

.PHONY: check-changelogs
check-changelogs: ## @testing Checks the changelogs for certain branches.
check-changelogs: python-env ## @testing Checks the changelogs for certain branches.
@python script/check_changelogs.py

.PHONY: rm-empty-folders
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ in the same directory with the name apm-server.
make
```

You also need to create all files needed by the APM Server by running the additional command below.
You also need to create all files needed by the APM Server by running the additional command below.

```
make update
```
Note that this requires to have `virtualenv` installed. Make sure that `virtualenv` creates Python2
environment, otherwise specify `PYTHON_EXE` variable pointed at Python2 executable.
Note that this requires to have `python >= 3.7` and `venv` installed.

### Run

Expand Down Expand Up @@ -97,7 +96,7 @@ See [releases](RELEASES.md) for an APM Server release checklist.

## Update Dependencies

The `apm-server` has two types of dependencies,
The `apm-server` has two types of dependencies,
the Golang packages managed with *Govendor* and a dependency to the *Beats Framework*.

### Govendor
Expand Down Expand Up @@ -127,9 +126,9 @@ BEATS_VERSION=f240148065af94d55c5149e444482b9635801f27 make update-beats
```
### Go-elasticsearch client Update

It is important to keep the used [go-elasticsearch client](https://github.com/elastic/go-elasticsearch) in sync with the according major version.
It is important to keep the used [go-elasticsearch client](https://github.com/elastic/go-elasticsearch) in sync with the according major version.
We also recommend to use the latest available client for minor versions.
Since APM Server does not yet support go modules, you can update the dependency using govendor, e.g. by running:
Since APM Server does not yet support go modules, you can update the dependency using govendor, e.g. by running:
```
git clone --branch v7.4.1 https://github.com/elastic/go-elasticsearch.git $GOPATH/src/github.com/elastic/go-elasticsearch/v7
govendor add github.com/elastic/go-elasticsearch/v7/^
Expand Down
8 changes: 4 additions & 4 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ While developing new tests or troubleshooting test failures, it is handy to run
example from within an editor, while still allowing all dependencies to run in containers. To accomplish this:

* Run `make build-image start-environment` to start docker containers for the Elastic Stack.
* Run `PYTHON_EXE=python2.7 make python-env` to build a python virtualenv
* Run `PYTHON_EXE=python3 make python-env` to build a python virtualenv
* Run `make apm-server.test` to (re)build the executable used to run the apm-server
* Run tests using the `run-system-tests` target, eg:
```
Expand All @@ -39,9 +39,9 @@ For insights about test-coverage, run `make coverage-report`. The test coverage
## Snapshot-Testing
Some tests make use of the concept of _snapshot_ or _approvals testing_. If running tests leads to changed snapshots, you can use the `approvals` tool to update the snapshots.
Following workflow is intended:
* Run `make update` to create the `approvals` binary that supports reviewing changes.
* Run `make update` to create the `approvals` binary that supports reviewing changes.
* Run `make unit` to create a `*.received.json` file for every newly created or changed snapshot.
* Run `./approvals` to review and interactively accept the changes.
* Run `./approvals` to review and interactively accept the changes.

## Benchmarking

Expand All @@ -55,7 +55,7 @@ A good way to present your results is by using `benchcmp`.
With your changes in the current working tree, do:

```
$ go get -u golang.org/x/tools/cmd/benchcmp
$ go get -u golang.org/x/tools/cmd/benchcmp
$ make bench > new.txt
$ git checkout master
$ make bench > old.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/version.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// doc-branch can be: master, 8.0, 8.1, etc.
:doc-branch: master
:go-version: 1.13.7
:python: 2.7.9
:python: 3.7
:docker: 1.12
:docker-compose: 1.11

Expand Down
2 changes: 1 addition & 1 deletion script/are_kibana_saved_objects_updated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from __future__ import print_function

Expand Down
2 changes: 1 addition & 1 deletion script/check_changelogs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import io
import hashlib
Expand Down
2 changes: 1 addition & 1 deletion script/copy-docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from __future__ import print_function
import os
Expand Down
2 changes: 1 addition & 1 deletion script/generate_notice_overrides.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Generate data used to put the correct revision information in NOTICE.TXT.
"""
Expand Down
2 changes: 1 addition & 1 deletion script/is_beats_updated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from __future__ import print_function

Expand Down
2 changes: 1 addition & 1 deletion script/jenkins/check-changelogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -exuo pipefail
docker run --rm \
-v "$PWD":/usr/src/myapp \
-w /usr/src/myapp python:3.6.8-alpine \
sh -c 'pip install requests; python script/check_changelogs.py'
sh -c 'pip3 install requests; python3 script/check_changelogs.py'
1 change: 1 addition & 0 deletions script/payload-compare.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
from uuid import uuid4
from collections import defaultdict
import json
Expand Down
2 changes: 1 addition & 1 deletion script/renamed_fields.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# python renamed_fields.py > ../docs/field-name-changes.asciidoc
# python3 renamed_fields.py > ../docs/field-name-changes.asciidoc
import yaml


Expand Down
2 changes: 1 addition & 1 deletion script/update_govendor_deps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
Update dependencies of the given govendor'd package. For https://github.com/elastic/apm-server/issues/450.
Expand Down
7 changes: 5 additions & 2 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ MAINTAINER Nicolas Ruflin <[email protected]>
RUN set -x && \
apt-get update && \
apt-get install -y --no-install-recommends \
netcat python-pip virtualenv && \
netcat python3 python3-pip python3-venv && \
apt-get clean

RUN pip install --upgrade setuptools
ENV PYTHON_ENV=/tmp/python-env

RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools

# Setup work environment
ENV APMSERVER_PATH /go/src/github.com/elastic/apm-server
Expand Down

0 comments on commit 44a39f8

Please sign in to comment.