Skip to content

Commit

Permalink
Makes build/CI work with Python 3.9 (#152)
Browse files Browse the repository at this point in the history
Updates CI configuration, tox configuration, requirements, and README.
Specifically adds more information around `tox`, upgrading
`pip`/`setuptools`, and using `venv` for this.  Also adds `tox` to the
requirements file to immediately make it available.

Also removes 2.7/3.4/3.5 as these are very much past end of life.
Updates `requirements.txt` to pick up updates for things like `pytest`
whose older versions don't work on 3.9.

Fixes a test `__str__` implementation to work in Python 3.9.
  • Loading branch information
almann committed Jun 16, 2021
1 parent 661ae6b commit 4490c86
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
language: python
dist: xenial
dist: bionic
matrix:
include:
- python: "2.7"
- python: "3.4"
- python: "3.5"
- python: "3.6"
- python: "3.7"
- python: "pypy"
# https://github.com/travis-ci/travis-ci/issues/9542
# pypy3 < 6.0.0 fails due to discrepancies with decimal...
#- python: "pypy3"
- python: "3.8"
- python: "3.9"
- python: "pypy3"
install:
- "pip install --upgrade setuptools"
- "pip install -r requirements.txt"
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ for Python.
[![Build Status](https://travis-ci.org/amzn/ion-python.svg?branch=master)](https://travis-ci.org/amzn/ion-python)
[![Documentation Status](https://readthedocs.org/projects/ion-python/badge/?version=latest)](https://ion-python.readthedocs.io/en/latest/?badge=latest)

This package is designed to work with **Python 2.7+** and **Python 3.4+**
This package is designed to work with **Python 3.6+**

## Getting Started

Expand Down Expand Up @@ -52,6 +52,8 @@ It is recommended to use `venv` to create a clean environment to build/test Ion
$ python3 -m venv ./venv
...
$ . venv/bin/activate
$ pip install -U pip
$ pip install -U setuptools
$ pip install -r requirements.txt
$ pip install -e .
```
Expand All @@ -66,16 +68,19 @@ $ python setup.py test
In order to verify that all platforms we support work with Ion Python, we use a combination
of [tox](http://tox.readthedocs.io/en/latest/) with [pyenv](https://github.com/yyuu/pyenv).

We recommend that you use tox within a virtual environment to isolate from whatever is in the system
installed Python (`requirements.txt` installs `tox`).

Install relevant versions of Python:

```
$ for V in 2.7.16 3.4.10 3.5.7 3.6.8 3.7.3 pypy2.7-7.1.1 pypy3.6-7.1.1; do pyenv install $V; done
$ for V in 3.6.13 3.7.10 3.8.10 3.9.5 pypy3.7-7.3.5; do pyenv install $V; done
```

Once you have these installations, add them as a local `pyenv` configuration

```
$ pyenv local 2.7.16 3.4.10 3.5.7 3.6.8 3.7.3 pypy2.7-7.1.1 pypy3.6-7.1.1
$ pyenv local 3.6.13 3.7.10 3.8.10 3.9.5 pypy3.7-7.3.5
```

Assuming you have `pyenv` properly set up (making sure `pyenv init` is evaluated into your shell),
Expand All @@ -85,14 +90,14 @@ you can now run `tox`:
# Run tox for all versions of python which executes py.test.
$ tox
# Run tox for just Python 2.7 and 3.5.
$ tox -e py27,py35
# Run tox for just Python 3.8 and 3.9.
$ tox -e py38,py39
# Run tox for a specific version and run py.test with high verbosity
$ tox -e py27 -- py.test -vv
$ tox -e py39 -- py.test -vv
# Run tox for a specific version and just the virtual env REPL.
$ tox -e py27 -- python
$ tox -e py39 -- python
```

## TODO
Expand Down
17 changes: 14 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
appdirs==1.4.4
attrs==21.2.0
distlib==0.3.2
filelock==3.0.12
iniconfig==1.1.1
jsonconversion==0.2.12
packaging==20.9
pluggy==0.13.1
py==1.10.0
pytest==2.9.2
pytest-runner==2.8
six==1.15.0
pyparsing==2.4.7
pytest==6.2.4
pytest-runner==5.3.1
six==1.16.0
toml==0.10.2
tox==3.23.1
virtualenv==20.4.7
2 changes: 1 addition & 1 deletion tests/test_core_multimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class _P(record('pairs', 'expected_all_values', 'expected_single_value', 'expected_total_len')):
def __str__(self):
return self.desc
return '{name}'.format(name=self.pairs)


ALL_DATA = _P(
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[tox]
envlist = py27,py34,py35,py36,py37,pypy2,pypy3
envlist = py36,py37,py38,py39,pypy3

[testenv]
requires= pip >= 21.1.2
setuptools >= 57.0.0
deps=-rrequirements.txt
commands={posargs:py.test}

0 comments on commit 4490c86

Please sign in to comment.