From 6b6d1317ce3753d541067dc0eab3040a312a446f Mon Sep 17 00:00:00 2001 From: Mark Towers Date: Tue, 25 Oct 2022 14:41:09 +0100 Subject: [PATCH] Remove support for Python 3.6 (#38) --- .github/workflows/build.yml | 2 +- .pre-commit-config.yaml | 5 ++--- docs/README.md | 2 +- gymnasium/core.py | 7 ------- gymnasium/wrappers/compatibility.py | 5 +---- py.Dockerfile | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- setup.py | 7 ++----- test_requirements.txt | 2 +- tests/envs/test_compatibility.py | 5 +---- 11 files changed, 12 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f01bf9d6..5e0a50aa7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 - run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ecb8b0331..e1aa4edd5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: isort args: ["--profile", "black"] - repo: https://github.com/pycqa/pydocstyle - rev: 6.1.1 # pick a git hash / tag to point to + rev: 6.1.1 hooks: - id: pydocstyle exclude: ^(gymnasium/envs/)|(tests/)|(docs/) @@ -40,8 +40,7 @@ repos: rev: v2.32.0 hooks: - id: pyupgrade - # TODO: remove `--keep-runtime-typing` option - args: ["--py36-plus", "--keep-runtime-typing"] + args: ["--py37-plus"] - repo: local hooks: - id: pyright diff --git a/docs/README.md b/docs/README.md index 341229d38..1e9e201ea 100644 --- a/docs/README.md +++ b/docs/README.md @@ -20,7 +20,7 @@ For Atari envs, add a Markdown file into `pages/environments/atari` then complet #### Non-Atari env -Ensure the environment is in Gymnasium (or your fork). Ensure that the environment's Python file has a properly formatted markdown docstring. Pip install Gymnasium (or your fork) then run `docs/scripts/gen_mds.py`. This will automatically generate an md page for the environment. Then complete the [other steps](#other-steps). +Ensure the environment is in Gymnasium (or your fork). Ensure that the environment's Python file has a properly formatted markdown docstring. Pip install Gymnasium (or your fork) then run `docs/scripts/gen_mds.py`. This will automatically generate a md page for the environment. Then complete the [other steps](#other-steps). #### Other steps diff --git a/gymnasium/core.py b/gymnasium/core.py index 64788adb5..bc9882f47 100644 --- a/gymnasium/core.py +++ b/gymnasium/core.py @@ -1,5 +1,4 @@ """Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper.""" -import sys from typing import ( TYPE_CHECKING, Any, @@ -16,17 +15,11 @@ import numpy as np from gymnasium import spaces -from gymnasium.logger import warn from gymnasium.utils import seeding if TYPE_CHECKING: from gymnasium.envs.registration import EnvSpec -if sys.version_info[0:2] == (3, 6): - warn( - "Gymnasium minimally supports python 3.6 as the python foundation not longer supports the version, please update your version to 3.7+" - ) - ObsType = TypeVar("ObsType") ActType = TypeVar("ActType") RenderFrame = TypeVar("RenderFrame") diff --git a/gymnasium/wrappers/compatibility.py b/gymnasium/wrappers/compatibility.py index 2be9009c8..89830d287 100644 --- a/gymnasium/wrappers/compatibility.py +++ b/gymnasium/wrappers/compatibility.py @@ -10,11 +10,8 @@ if sys.version_info >= (3, 8): from typing import Protocol, runtime_checkable -elif sys.version_info >= (3, 7): - from typing_extensions import Protocol, runtime_checkable else: - Protocol = object - runtime_checkable = lambda x: x # noqa: E731 + from typing_extensions import Protocol, runtime_checkable @runtime_checkable diff --git a/py.Dockerfile b/py.Dockerfile index 64a7f316e..dff8c6ced 100644 --- a/py.Dockerfile +++ b/py.Dockerfile @@ -26,6 +26,6 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.mujoco/mujoco210/bin" COPY . /usr/local/gymnasium/ WORKDIR /usr/local/gymnasium/ -RUN if [ "python:${PYTHON_VERSION}" = "python:3.6.15" ] ; then pip install .[box2d,classic_control,toy_text,other] pytest=="7.0.1" --no-cache-dir; else pip install .[testing] --no-cache-dir; fi +RUN pip install .[testing] --no-cache-dir ENTRYPOINT ["/usr/local/gymnasium/bin/docker_entrypoint"] diff --git a/pyproject.toml b/pyproject.toml index 7f3335be0..041bc28ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ strict = [ ] typeCheckingMode = "basic" -pythonVersion = "3.6" +pythonVersion = "3.7" pythonPlatform = "All" typeshedPath = "typeshed" enableTypeIgnoreComments = true diff --git a/requirements.txt b/requirements.txt index f3de807a0..5ba617a81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,6 @@ matplotlib>=3.0 box2d-py==2.3.5 pygame==2.1.0 ale-py~=0.8.0 -mujoco==2.2.0 +mujoco==2.2 mujoco_py<2.2,>=2.1 imageio>=2.14.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 9e044ec12..6ee411fb2 100644 --- a/setup.py +++ b/setup.py @@ -47,7 +47,7 @@ def get_version(): testing_group = set(extras.keys()) - {"accept-rom-license", "atari"} extras["testing"] = list( set(itertools.chain.from_iterable(map(lambda group: extras[group], testing_group))) -) + ["pytest==7.0.1", "gym==0.26.2"] +) + ["pytest==7.1.3", "gym==0.26.2"] # All dependency groups - accept rom license as requires user to run all_groups = set(extras.keys()) - {"accept-rom-license"} @@ -70,7 +70,7 @@ def get_version(): long_description=long_description, long_description_content_type="text/markdown", keywords=["Reinforcement Learning", "game", "RL", "AI", "gymnasium"], - python_requires=">=3.6", + python_requires=">=3.7", tests_require=extras["testing"], packages=[ package for package in find_packages() if package.startswith("gymnasium") @@ -90,12 +90,9 @@ def get_version(): "cloudpickle >= 1.2.0", "importlib_metadata >= 4.8.0; python_version < '3.10'", "gymnasium_notices >= 0.0.1", - "dataclasses == 0.8; python_version == '3.6'", ], classifiers=[ - # Python 3.6 is minimally supported (only with basic gymnasium environments and API) "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", diff --git a/test_requirements.txt b/test_requirements.txt index 0a488c30d..bfe601354 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -6,5 +6,5 @@ matplotlib>=3.0 imageio>=2.14.1 pygame==2.1.0 mujoco_py<2.2,>=2.1 -pytest==7.0.1 +pytest==7.1.3 gym==0.26.2 diff --git a/tests/envs/test_compatibility.py b/tests/envs/test_compatibility.py index d651579ac..9d0a09763 100644 --- a/tests/envs/test_compatibility.py +++ b/tests/envs/test_compatibility.py @@ -1,4 +1,3 @@ -import sys from typing import Any, Dict, Optional, Tuple import numpy as np @@ -81,9 +80,7 @@ def test_explicit(): def test_implicit(): old_env = LegacyEnvImplicit() - if sys.version_info >= (3, 7): - # We need to give up on typing in Python 3.6 - assert isinstance(old_env, LegacyEnv) + assert isinstance(old_env, LegacyEnv) env = EnvCompatibility(old_env, render_mode="rgb_array") assert env.observation_space == Discrete(1) assert env.action_space == Discrete(1)