Remove support for Python 3.6 (#38)

This commit is contained in:
Mark Towers
2022-10-25 14:41:09 +01:00
committed by GitHub
parent 71485eccde
commit 6b6d1317ce
11 changed files with 12 additions and 29 deletions

View File

@@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] python-version: ['3.7', '3.8', '3.9', '3.10']
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: | - run: |

View File

@@ -27,7 +27,7 @@ repos:
- id: isort - id: isort
args: ["--profile", "black"] args: ["--profile", "black"]
- repo: https://github.com/pycqa/pydocstyle - repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1 # pick a git hash / tag to point to rev: 6.1.1
hooks: hooks:
- id: pydocstyle - id: pydocstyle
exclude: ^(gymnasium/envs/)|(tests/)|(docs/) exclude: ^(gymnasium/envs/)|(tests/)|(docs/)
@@ -40,8 +40,7 @@ repos:
rev: v2.32.0 rev: v2.32.0
hooks: hooks:
- id: pyupgrade - id: pyupgrade
# TODO: remove `--keep-runtime-typing` option args: ["--py37-plus"]
args: ["--py36-plus", "--keep-runtime-typing"]
- repo: local - repo: local
hooks: hooks:
- id: pyright - id: pyright

View File

@@ -20,7 +20,7 @@ For Atari envs, add a Markdown file into `pages/environments/atari` then complet
#### Non-Atari env #### 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 #### Other steps

View File

@@ -1,5 +1,4 @@
"""Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper.""" """Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper."""
import sys
from typing import ( from typing import (
TYPE_CHECKING, TYPE_CHECKING,
Any, Any,
@@ -16,17 +15,11 @@ from typing import (
import numpy as np import numpy as np
from gymnasium import spaces from gymnasium import spaces
from gymnasium.logger import warn
from gymnasium.utils import seeding from gymnasium.utils import seeding
if TYPE_CHECKING: if TYPE_CHECKING:
from gymnasium.envs.registration import EnvSpec 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") ObsType = TypeVar("ObsType")
ActType = TypeVar("ActType") ActType = TypeVar("ActType")
RenderFrame = TypeVar("RenderFrame") RenderFrame = TypeVar("RenderFrame")

View File

@@ -10,11 +10,8 @@ from gymnasium.utils.step_api_compatibility import (
if sys.version_info >= (3, 8): if sys.version_info >= (3, 8):
from typing import Protocol, runtime_checkable from typing import Protocol, runtime_checkable
elif sys.version_info >= (3, 7):
from typing_extensions import Protocol, runtime_checkable
else: else:
Protocol = object from typing_extensions import Protocol, runtime_checkable
runtime_checkable = lambda x: x # noqa: E731
@runtime_checkable @runtime_checkable

View File

@@ -26,6 +26,6 @@ ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/root/.mujoco/mujoco210/bin"
COPY . /usr/local/gymnasium/ COPY . /usr/local/gymnasium/
WORKDIR /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"] ENTRYPOINT ["/usr/local/gymnasium/bin/docker_entrypoint"]

View File

@@ -15,7 +15,7 @@ strict = [
] ]
typeCheckingMode = "basic" typeCheckingMode = "basic"
pythonVersion = "3.6" pythonVersion = "3.7"
pythonPlatform = "All" pythonPlatform = "All"
typeshedPath = "typeshed" typeshedPath = "typeshed"
enableTypeIgnoreComments = true enableTypeIgnoreComments = true

View File

@@ -10,6 +10,6 @@ matplotlib>=3.0
box2d-py==2.3.5 box2d-py==2.3.5
pygame==2.1.0 pygame==2.1.0
ale-py~=0.8.0 ale-py~=0.8.0
mujoco==2.2.0 mujoco==2.2
mujoco_py<2.2,>=2.1 mujoco_py<2.2,>=2.1
imageio>=2.14.1 imageio>=2.14.1

View File

@@ -47,7 +47,7 @@ extras = {
testing_group = set(extras.keys()) - {"accept-rom-license", "atari"} testing_group = set(extras.keys()) - {"accept-rom-license", "atari"}
extras["testing"] = list( extras["testing"] = list(
set(itertools.chain.from_iterable(map(lambda group: extras[group], testing_group))) 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 dependency groups - accept rom license as requires user to run
all_groups = set(extras.keys()) - {"accept-rom-license"} all_groups = set(extras.keys()) - {"accept-rom-license"}
@@ -70,7 +70,7 @@ setup(
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
keywords=["Reinforcement Learning", "game", "RL", "AI", "gymnasium"], keywords=["Reinforcement Learning", "game", "RL", "AI", "gymnasium"],
python_requires=">=3.6", python_requires=">=3.7",
tests_require=extras["testing"], tests_require=extras["testing"],
packages=[ packages=[
package for package in find_packages() if package.startswith("gymnasium") package for package in find_packages() if package.startswith("gymnasium")
@@ -90,12 +90,9 @@ setup(
"cloudpickle >= 1.2.0", "cloudpickle >= 1.2.0",
"importlib_metadata >= 4.8.0; python_version < '3.10'", "importlib_metadata >= 4.8.0; python_version < '3.10'",
"gymnasium_notices >= 0.0.1", "gymnasium_notices >= 0.0.1",
"dataclasses == 0.8; python_version == '3.6'",
], ],
classifiers=[ classifiers=[
# Python 3.6 is minimally supported (only with basic gymnasium environments and API)
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",

View File

@@ -6,5 +6,5 @@ matplotlib>=3.0
imageio>=2.14.1 imageio>=2.14.1
pygame==2.1.0 pygame==2.1.0
mujoco_py<2.2,>=2.1 mujoco_py<2.2,>=2.1
pytest==7.0.1 pytest==7.1.3
gym==0.26.2 gym==0.26.2

View File

@@ -1,4 +1,3 @@
import sys
from typing import Any, Dict, Optional, Tuple from typing import Any, Dict, Optional, Tuple
import numpy as np import numpy as np
@@ -81,9 +80,7 @@ def test_explicit():
def test_implicit(): def test_implicit():
old_env = LegacyEnvImplicit() old_env = LegacyEnvImplicit()
if sys.version_info >= (3, 7): assert isinstance(old_env, LegacyEnv)
# We need to give up on typing in Python 3.6
assert isinstance(old_env, LegacyEnv)
env = EnvCompatibility(old_env, render_mode="rgb_array") env = EnvCompatibility(old_env, render_mode="rgb_array")
assert env.observation_space == Discrete(1) assert env.observation_space == Discrete(1)
assert env.action_space == Discrete(1) assert env.action_space == Discrete(1)