Skip to content

Commit

Permalink
Official support for python 3.12 and code clean-up after EOLed Python…
Browse files Browse the repository at this point in the history
… 3.6 and 3.7. (#517)



Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
  • Loading branch information
ogrisel and hugovk authored Oct 13, 2023
1 parent 45dcb75 commit c6f8cd4
Show file tree
Hide file tree
Showing 69 changed files with 1,021 additions and 1,565 deletions.
95 changes: 0 additions & 95 deletions .github/scripts/flake8_diff.sh

This file was deleted.

60 changes: 25 additions & 35 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,34 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install flake8
- name: Install ruff
shell: bash
run: |
python -V
python -m pip install "flake8<6.0.0"
# XXX: flake8 --diff is deprecated, broken and was removed
# in flake8 6.0.0: we should instead black-ify the full repo
# and run a full flake8 check at each PR.
- name: Run flake8 on diff with upstream/master
python -m pip install ruff
- name: Run ruff
shell: bash
run: |
bash ./.github/scripts/flake8_diff.sh
ruff .
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# TODO: add "3.12-dev" to the list
python_version: [3.7, 3.8, 3.9, "3.10", "3.11", "pypy-3.9"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.9"]
exclude:
# Do not test all minor versions on all platforms, especially if they
# are not the oldest/newest supported versions
- os: windows-latest
python_version: 3.7
- os: windows-latest
python_version: 3.8
# as of 4/02/2020, psutil won't build under PyPy + Windows
- os: windows-latest
python_version: "pypy-3.9"
- os: macos-latest
python_version: 3.7
- os: macos-latest
python_version: 3.8
- os: macos-latest
Expand All @@ -56,11 +48,12 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- name: Install project and dependencies
shell: bash
run: |
Expand All @@ -72,11 +65,6 @@ jobs:
- name: Display Python version
shell: bash
run: python -c "import sys; print(sys.version)"
- name: Look for syntax errors/undefined names
shell: bash
run: |
python -m flake8 . --count --verbose --select=E901,E999,F821,F822,F823 \
--show-source --statistics
- name: Test with pytest
shell: bash
run: |
Expand All @@ -85,7 +73,7 @@ jobs:
coverage combine --append
coverage xml -i
- name: Publish coverage results
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand All @@ -101,9 +89,9 @@ jobs:
matrix:
python_version: ["3.10"]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install project and dependencies
Expand All @@ -119,9 +107,11 @@ jobs:
# FIXME ipv6-related failures on Ubuntu github actions CI
# https://github.com/dask/distributed/issues/4514
export DISABLE_IPV6=1
# test_decide_worker_coschedule_order_neighbors is skipped because of:
# https://github.com/dask/distributed/issues/8255
export PYTEST_ADDOPTS=("-m" "not avoid_ci" "-k" "not test_decide_worker_coschedule_order_neighbors")
# - test_decide_worker_coschedule_order_neighbors is skipped because of:
# https://github.com/dask/distributed/issues/8255
# - test_client_worker is skipped because it's a time-related test that
# randomly fails on CI but seems unrelated to cloudpickle.
export PYTEST_ADDOPTS=("-m" "not avoid_ci" "-k" "not test_decide_worker_coschedule_order_neighbors and not test_client_worker")
source ./.github/scripts/test_downstream_project.sh
joblib-downstream-build:
Expand All @@ -135,9 +125,9 @@ jobs:
matrix:
python_version: ["3.10"]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install project and dependencies
Expand All @@ -163,9 +153,9 @@ jobs:
matrix:
python_version: ["3.10"]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install downstream project and dependencies
Expand All @@ -188,9 +178,9 @@ jobs:
matrix:
python_version: ["3.11"]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install project and tests dependencies
Expand All @@ -204,7 +194,7 @@ jobs:
run: |
RAY_PACKAGE_DIR=$(python -c "import os, ray; print(os.path.dirname(ray.__file__), flush=True)")
cp cloudpickle/cloudpickle.py $RAY_PACKAGE_DIR/cloudpickle/cloudpickle.py
cp cloudpickle/compat.py $RAY_PACKAGE_DIR/cloudpickle/compat.py
rm -rf $RAY_PACKAGE_DIR/cloudpickle/compat.py
cp cloudpickle/cloudpickle_fast.py $RAY_PACKAGE_DIR/cloudpickle/cloudpickle_fast.py
- name: Fetch the Ray test suite from github
run: |
Expand Down
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
2.3.0 (development)
3.0.0 (development)
===================

- Officially support Python 3.12 and drop support for Python 3.6 and 3.7.
Dropping support for older Python versions made it possible to simplify the
code base signficantly, hopefully making it easier to contribute to and
maintain the project.
([PR #515](https://github.com/cloudpipe/cloudpickle/pull/515))

- Fix pickling of dataclasses and their instances.
([issue #386](https://github.com/cloudpipe/cloudpickle/issues/386),
[PR #513](https://github.com/cloudpipe/cloudpickle/pull/513))
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ that pickles such constructs **by value**.
Another case where the importability assumption is expected to break is when
developing a module in a distributed execution environment: the worker
processes may not have access to the said module, for example if they live on a
different machine than the process in which the module is being developed.
By itself, `cloudpickle` cannot detect such "locally importable" modules and
switch to serialization by value; instead, it relies on its default mode,
which is serialization by reference. However, since `cloudpickle 2.0.0`, one
can explicitly specify modules for which serialization by value should be used,
using the `register_pickle_by_value(module)`/`/unregister_pickle(module)` API:
different machine than the process in which the module is being developed. By
itself, `cloudpickle` cannot detect such "locally importable" modules and
switch to serialization by value; instead, it relies on its default mode, which
is serialization by reference. However, since `cloudpickle 2.0.0`, one can
explicitly specify modules for which serialization by value should be used,
using the
`register_pickle_by_value(module)`/`/unregister_pickle_by_value(module)` API:

```python
>>> import cloudpickle
Expand Down Expand Up @@ -130,14 +131,14 @@ Running the tests

or alternatively for a specific environment:

tox -e py37
tox -e py312


- With `py.test` to only run the tests for your current version of
- With `pytest` to only run the tests for your current version of
Python:

pip install -r dev-requirements.txt
PYTHONPATH='.:tests' py.test
PYTHONPATH='.:tests' pytest

History
-------
Expand Down
2 changes: 1 addition & 1 deletion ci/install_coverage_subprocess_pth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import os.path as op
from sysconfig import get_path

FILE_CONTENT = u"""\
FILE_CONTENT = """\
import coverage; coverage.process_startup()
"""

Expand Down
17 changes: 12 additions & 5 deletions cloudpickle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from cloudpickle.cloudpickle import * # noqa
from cloudpickle.cloudpickle_fast import CloudPickler, dumps, dump # noqa

# Conform to the convention used by python serialization libraries, which
# expose their Pickler subclass at top-level under the "Pickler" name.
Pickler = CloudPickler
__version__ = "3.0.0.dev0"

__version__ = '2.3.0.dev0'
__all__ = [ # noqa
"__version__",
"Pickler",
"CloudPickler",
"dumps",
"loads",
"dump",
"load",
"register_pickle_by_value",
"unregister_pickle_by_value",
]
Loading

0 comments on commit c6f8cd4

Please sign in to comment.