Skip to content
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

2022 CI + Benchmarking refresh #126

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@ version: 2.1
workflows:
workflow:
jobs:
- test_python_34
- test:
matrix:
parameters:
python_version: ["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
python_version: ["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
- test_pypy:
matrix:
parameters:
python_version: ["2.7", "3.7", "3.8"]
python_version: ["2.7", "3.7", "3.8", "3.9"]
- lint-rst

jobs:
# `cimg/python` doesn't support Python 3.4,
# but old `circleci/python` is still around!
test_python_34:
steps:
- checkout
- run:
name: Test
command: python setup.py test
docker:
- image: circleci/python:3.4

test:
parameters:
python_version:
Expand All @@ -24,7 +36,7 @@ jobs:
name: Test
command: python setup.py test
docker:
- image: circleci/python:<<parameters.python_version>>
- image: cimg/python:<<parameters.python_version>>

test_pypy:
parameters:
Expand Down Expand Up @@ -54,4 +66,4 @@ jobs:
. venv/bin/activate
rst-lint --encoding=utf-8 README.rst
docker:
- image: circleci/python:3.10
- image: cimg/python:3.11
4 changes: 2 additions & 2 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'
python-version: '3.11'

- run: |
pip install packaging
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.10'
python-version: '3.11'

- name: Build sdist
run: python setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ciso8601
``ciso8601`` converts `ISO 8601`_ or `RFC 3339`_ date time strings into Python datetime objects.

Since it's written as a C module, it is much faster than other Python libraries.
Tested with cPython 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10.
Tested with cPython 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11.

**Note:** ciso8601 doesn't support the entirety of the ISO 8601 spec, `only a popular subset`_.

Expand Down
21 changes: 12 additions & 9 deletions benchmarking/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ RUN apt-get update && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update

# Install the other dependencies
RUN apt-get install -y git curl gcc build-essential

# Install tzdata non-iteractively
# https://stackoverflow.com/questions/44331836/apt-get-install-tzdata-noninteractive/44333806#44333806
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata

# Install the Python versions
RUN apt install -y python python-dev && \
apt install -y python3.5 python3.5-dev python3.5-venv && \
apt install -y python3.6 python3.6-dev python3.6-venv && \
RUN apt install -y python2 python2-dev && \
apt install -y python3.7 python3.7-dev python3.7-venv && \
apt install -y python3.8 python3.8-dev python3.8-venv && \
apt install -y python3.9 python3.9-dev python3.9-venv && \
apt install -y python3.10 python3.10-dev python3.10-venv

# Install the other dependencies
RUN apt-get install -y git curl gcc build-essential
apt install -y python3.10 python3.10-dev python3.10-venv && \
apt install -y python3.11 python3.11-dev python3.11-venv

# Make Python 3.10 the default `python`
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 10
# Make Python 3.11 the default `python`
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 10

# Get pip
RUN python -m ensurepip --upgrade
Expand Down
5 changes: 4 additions & 1 deletion benchmarking/format_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re

from collections import defaultdict, UserDict
from packaging import version as version_parse

import pytablewriter

Expand Down Expand Up @@ -64,9 +65,11 @@ def format_used_module_versions(module_versions_used):
if len(versions) == 1:
results.append(f"{module}=={next(iter(versions.keys()))}")
else:
results.append(", ".join([f"{module}=={version} (on Python {', '.join(sorted(py_versions))})" for version, py_versions in versions.items()]))
results.append(", ".join([f"{module}=={version} (on Python {', '.join(version_sort(py_versions))})" for version, py_versions in versions.items()]))
return results

def version_sort(versions):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, it was sorting alphanumerically, resulting in "3.10, 3.11, 3.9..." instead of "3.7...3.11".

return [str(v) for v in sorted([version_parse.parse(v) for v in versions])]

def relative_slowdown(subject, comparison):
most_modern_common_version = next(iter(sorted(set(subject.keys()).intersection(set(comparison)), reverse=True)), None)
Expand Down
22 changes: 17 additions & 5 deletions benchmarking/perform_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
"python-dateutil": ("import dateutil.parser", "dateutil.parser.parse('{timestamp}')"),
"iso8601": ("import iso8601", "iso8601.parse_date('{timestamp}')"),
"isodate": ("import isodate", "isodate.parse_datetime('{timestamp}')"),
"maya": ("import maya", "maya.parse('{timestamp}').datetime()"),
"pendulum": ("from pendulum.parsing import parse_iso8601", "parse_iso8601('{timestamp}')"),
"PySO8601": ("import PySO8601", "PySO8601.parse('{timestamp}')"),
"str2date": ("from str2date import str2date", "str2date('{timestamp}')"),
}

if os.name != "nt" and (sys.version_info.major, sys.version_info.minor) < (3, 9):
if (sys.version_info.major, sys.version_info.minor) >= (3, 11):
# Python 3.11 added full ISO 8601 parsing
ISO_8601_MODULES["datetime (builtin)"] = ("from datetime import datetime", "datetime.fromisoformat('{timestamp}')")

if os.name != "nt":
# udatetime doesn't support Windows.
ISO_8601_MODULES["udatetime"] = ("import udatetime", "udatetime.from_string('{timestamp}')")

Expand All @@ -40,7 +43,7 @@
# zulu v2.0.0+ no longer supports Python < 3.6
ISO_8601_MODULES["zulu"] = ("import zulu", "zulu.parse('{timestamp}')")

if (sys.version_info.major, sys.version_info.minor) != (3, 6) and (sys.version_info.major, sys.version_info.minor) != (3, 10):
if (sys.version_info.major, sys.version_info.minor) != (3, 6) and (sys.version_info.major, sys.version_info.minor) <= (3, 9):
# iso8601utils installs enum34, which messes with tox in Python 3.6
# https://stackoverflow.com/q/43124775
# https://github.com/silverfernsys/iso8601utils/pull/5
Expand All @@ -49,9 +52,16 @@
ISO_8601_MODULES["iso8601utils"] = ("from iso8601utils import parsers", "parsers.datetime('{timestamp}')")

if (sys.version_info.major, sys.version_info.minor) != (3, 4):
# arrow no longer supports Python 3.4
# `arrow` no longer supports Python 3.4
ISO_8601_MODULES["arrow"] = ("import arrow", "arrow.get('{timestamp}').datetime")
# moment is built on `times`, which is built on `arrow`, which no longer supports Python 3.4

if sys.version_info.major >= 3:
# `maya` uses a version of `regex` which no longer supports Python 2
ISO_8601_MODULES["maya"] = ("import maya", "maya.parse('{timestamp}').datetime()")

if (sys.version_info.major, sys.version_info.minor) >= (3, 5):
# `moment` is built on `times`, which is built on `arrow`, which no longer supports Python 3.4
# `moment` uses a version of `regex` which no longer supports Python 2
ISO_8601_MODULES["moment"] = ("import moment", "moment.date('{timestamp}').date")

class Result:
Expand Down Expand Up @@ -132,6 +142,8 @@ def write_module_versions(filepath):
module_version_writer = csv.writer(fout, delimiter=",", quotechar='"', lineterminator="\n")
module_version_writer.writerow([sys.version_info.major, sys.version_info.minor])
for module, (_setup, _stmt) in sorted(ISO_8601_MODULES.items(), key=lambda x: x[0].lower()):
if module == "datetime (builtin)":
continue
module_version_writer.writerow([module, get_module_version(module)])

def run_tests(timestamp, results_directory, compare_to):
Expand Down
11 changes: 6 additions & 5 deletions benchmarking/tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py310,py39,py38,py37,py36,py35,py34,py27
envlist = py311,py310,py39,py38,py37,py36,py35,py34,py27
setupdir=..

[testenv]
Expand All @@ -21,17 +21,18 @@ deps=
# https://github.com/silverfernsys/iso8601utils/issues/6
iso8601utils; python_version != '3.6' and python_version != '3.10'
isodate
maya
; `maya` uses a version of `regex` which no longer supports Python 2
maya; python_version > '3'
metomi-isodatetime; python_version >= '3.5'
; `moment` is built on `times`, which is built on `arrow`, which no longer supports Python 3.4
moment; python_version != '3.4'
; `moment` uses a version of `regex` which no longer supports Python 2
moment; python_version >= '3.5'
pendulum
pyso8601
python-dateutil
str2date
; `udatetime` doesn't support Windows
; `udatetime` doesn't compile on Python 3.9 (https://github.com/freach/udatetime/issues/32)
udatetime; os_name != 'nt' and python_version < '3.9'
udatetime; os_name != 'nt'
; `zulu` v2.0.0+ no longer supports Python < 3.6
zulu; python_version >= '3.6'
pytz
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {py27,py34,py35,py36,py37,py38,py39}-caching_{enabled,disabled}
envlist = {py27,py34,py35,py36,py37,py38,py39,py310,py311}-caching_{enabled,disabled}

[testenv]
setenv =
Expand Down