-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Migrate scripts to python 3 #14798
Migrate scripts to python 3 #14798
Conversation
Opened small PR: #14900 |
System tests running in docker are using the same virtual environment as the host. If version of python in the virtual environment is not available in the guest, it will use the default in the system, that is so far Python 2.
jenkins, test this again to see if python 3 is already available in workers |
Great stuff, fantastic to see some more Python 3 adoption! Is the plan to switch over from Python 2 to Python 3, or to support both at the same time? If it's the former, there's a lot of changes in the PR that aren't really necessary (I assume those were introduced by
While these changes don't really hurt, it makes the diff quite a bit larger than it could be, and the code itself is not quite as readable. If it helps, I can open a PR that removes these unnecessary changes (again, assuming you don't plan to support running the tests with Python 2 going forward). |
Ignore the OSX packaging job. The OSX packaging build needs to be disabled/removed until there's a more powerful worker available. It doesn't have enough memory to complete the build. |
jenkins, test this again please |
Opened PR with the squashed changes to prepare the backport to 7.x #16302 |
x-pack/metricbeat did fail on travis on Checking beats-ci and travis-ci, it looks like each testsuite did succeed at least once. |
build: | ||
context: ./_meta | ||
args: | ||
APPSEARCH_VERSION: ${APPSEARCH_VERSION:-7.5.0} |
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 default version should be 8.0.0-SNAPSHOT, so to test against the app-search master branch.
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.
Appsearch version is set to 7.5.0 also in master, we will review it as a follow up.
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.
LGTM. No changes needed - just pointing out my own typo.
// platforms. So do verify the version with python.exe --version. | ||
// | ||
// Setting up a python virtual environment on a network drive does not work | ||
// well. So if this applies to your development environment set PYTHON_EXE |
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.
// well. So if this applies to your development environment set PYTHON_EXE | |
// well. So if this applies to your development environment set PYTHON_ENV |
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.
Fixed in #16364, where I am also adding a changelog entry for this.
Several changes in test and tools code to migrate to Python 3 and stop supporting Python 2. From now on, Python 3 is required to run tests and many make and mage targets. Switch over to `python3 -m venv` instead of `virtualenv`. It's the recommended way to create virtual Python environments in 3.4 and above. Remove any direct references to python to always allow a specific python binary or version to be used with the PYTHON_EXE environmet variable. Use python3 in the shebang for python scripts. python is going to be reserved for python2 in Ubuntu, and PEP394 mentions that python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3. Update documentation to reflect these changes and add information about the use of Python for beats development. Prepare the tests for checks based on the local ip, this IP can be [::1] if ipv4 is not available or 127.0.1.1 in some machines, as in the newer Travis images. Change checks based on sys.platform, as the values for linux have changed in Python 3. Several assertions in tests have been adapted to its newer versions. Some flaky tests that are more flaky with Python 3 have been fixed or skipped. Replace use of nosetests with mage wrapper in script for Windows CI workers. Mage manages their own python virtual environments, this is preferred to directly call python commands. (cherry picked from 9375fb9) Co-authored-by: Noémi Ványi <[email protected]> Co-authored-by: Benjamin Wohlwend <[email protected]> Co-authored-by: Michael Madden <[email protected]> Co-authored-by: Andrew Kroh <[email protected]>
Since the migration to Python 3 (#14798) these scripts fail in environments not configured with unicode locales with this error. We saw this in the new jenkins pipelines, and can be reproduced at least on Linux running make check with LANG=C.
Since the migration to Python 3 (elastic#14798) these scripts fail in environments not configured with unicode locales with this error. We saw this in the new jenkins pipelines, and can be reproduced at least on Linux running make check with LANG=C. (cherry picked from commit c2f6358)
Several changes in test and tools code to migrate to Python 3 and stop supporting Python 2. From now on, Python 3 is required to run tests and many make and mage targets. Switch over to `python3 -m venv` instead of `virtualenv`. It's the recommended way to create virtual Python environments in 3.4 and above. Remove any direct references to python to always allow a specific python binary or version to be used with the PYTHON_EXE environmet variable. Use python3 in the shebang for python scripts. python is going to be reserved for python2 in Ubuntu, and PEP394 mentions that python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3. Update documentation to reflect these changes and add information about the use of Python for beats development. Prepare the tests for checks based on the local ip, this IP can be [::1] if ipv4 is not available, or 127.0.1.1 in some machines, as in the latest Ubuntu images used in Travis. Change checks based on sys.platform, as the values for linux have changed in Python 3. Several assertions in tests have been adapted to its newer versions. Some flaky tests that are more flaky with Python 3 have been fixed or skipped. Replace use of nosetests with mage wrapper in script for Windows CI workers. Mage manages their own python virtual environments, this is preferred to directly call python commands. Co-authored-by: Noémi Ványi <[email protected]> Co-authored-by: Benjamin Wohlwend <[email protected]> Co-authored-by: Michael Madden <[email protected]> Co-authored-by: Andrew Kroh <[email protected]>
Since the migration to Python 3 (elastic#14798) these scripts fail in environments not configured with unicode locales with this error. We saw this in the new jenkins pipelines, and can be reproduced at least on Linux running make check with LANG=C.
PR to identify and fix issues with python 3.
If you want to help:
feature/python3
as base branchHow to use Python 3 locally:
If Python 3 is not the default in your system you may need to:
build/python-env
andbuild/ve
directories, or just runmake clean
)Issues:
Log of changes that we may consider to revert before merging:
PYTHON_EXE
env varmake check
from the root directorycheck
to thetest
stage in Travis so failures there don't block other jobs so we can see their problems.Log of issues identified/done:
requirements.txt
2to3
toolfuturize
python3
in the shebang for python scripts.python
is going to be reserved forpython2
in Ubuntu, and PEP394 mentions thatpython
should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3 Update script shebangs to python3 #15701virtualenv
withpython3 -m venv
and get rid ofPYTHON_EXE
. Use 'python3 -m venv' instead of virtualenv #15754make check
Fix make check for python 3 #15226 @mikemadden42dev-tools/generate_notice.py
:dev-tools/generate_notice.py
@jsorianodev-tools/generate_notice.py
: migrate it to magecheck
is run in a previouscheck
stage Revert changes in travis for the migration to python 3 #15817fields.asciidoc
makesmake check
to randomly fail on Jenkins Use JSON string for dictionary example #15898 @jsorianodev-tools/cherrypick_pr
Migrate cherrypick_pr to Python 3 #14900 Remove leftover encode from cherrypick_pr #14929 @kvchConsider keeping support also with Python 2 if some CI environment cannot be upgradedFailed to connect: x509: certificate is valid for 127.0.0.1, not 127.0.1.1
(probably similar to Listen explicitly on localhost on heartbeat TCP tests #15583) Regenerate test certificates to include 127.0.1.1 #15591 @jsorianoAssertionError: '0o640' != '0640'
Migrate Filebeat integration tests to Python3 #15030'bool' object is not iterable
,a bytes-like object is required, not 'str'
,'float' object cannot be interpreted as an integer
). Migrate Filebeat integration tests to Python3 #15030ValueError: can't have unbuffered text I/O
Migrate Filebeat integration tests to Python3 #15030AttributeError: 'str' object has no attribute 'decode'
Migrate Filebeat integration tests to Python3 #15030ImportError: No module named http.server
Migrate Auditbeat, Heartbeat and Metricbeat to Python3 #15111 @kvchobjects not equal: actual(string(127.0.1.1)) != expected(string(127.0.0.1))
Listen explicitly on localhost on heartbeat TCP tests #15583 @jsorianoa bytes-like object is required, not 'str'
) Migrate Auditbeat, Heartbeat and Metricbeat to Python3 #15111 @kvchtest connected UDP IPv4 flow
(needs cherry-pick to branch Socket dataset: Workaround for bogus dereference in kernel 5.x #15771) fix backport as part of Update python3 fix auditbeat and dashboards #15807ImportError: No module named cli.command
(from compose.cli.command import get_project
)ImportError: No module named request
(import urllib.request
, was autogenerated by2to3
)AttributeError: 'Test' object has no attribute 'assertNotRegexpMatches'
Migrate Auditbeat, Heartbeat and Metricbeat to Python3 #15111TypeError: Unicode-objects must be encoded before hashing
TypeError: 'str' does not support the buffer interface
Migrate Functionbeat to Python3 #14901 @kvchmake docs
- to be removed @jsoriano Remove docs build from travis #15816Docker build fails in travisbeats/Vagrantfile
Line 85 in b74e19c
To do when build is green, before merging:
Fixes #5950.