Skip to content

Commit 734bd4b

Browse files
Rewrite setup (#2865)
* Updated testing requirements based off extra["testing"] * Updated setup to check the version is valid, added testing and all dependency groups and collects the requirements from requirements.txt to keep everything standardized. * Updated requirements.txt based on the current minimum gym requirements.txt to work * Updated requirements.txt based on the current minimum gym requirements.txt to work * Updated test_requirements.txt based on the current gym full testing requirements * Pre-commit updates * Add integer check for the `n` parameter * The type of self.spaces is an Iterable which is absorbed by the tuple. * Simplifies the environment checker to two files, env_checker.py and passive_env_checker.py with a new wrapper env_checker.py * Adds the passive environment checker on `gym.make` * Ignore the `check_env` warn parameter * Ignore the `check_env` warn parameter * Use the `data_equivalence` function * Remove env_checker PR changes * Move pip install pytest and mock to py 3.6 * Update setup.py and requirements.txt
1 parent 134de4a commit 734bd4b

File tree

4 files changed

+61
-55
lines changed

4 files changed

+61
-55
lines changed

py.Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/.mujoco/mujoco210/bin
1414
COPY . /usr/local/gym/
1515
WORKDIR /usr/local/gym/
1616

17-
RUN if [ python:$PYTHON_VERSION = "python:3.6.15" ] ; then pip install .[box2d,classic_control,toy_text,other] ; else pip install .[noatari] ; fi
18-
RUN pip install -r test_requirements.txt
17+
RUN if [ python:$PYTHON_VERSION = "python:3.6.15" ] ; then pip install .[box2d,classic_control,toy_text,other] pytest mock ; else pip install .[testing] ; fi
1918

2019
ENTRYPOINT ["/usr/local/gym/bin/docker_entrypoint"]

requirements.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
ale-py~=0.7.5
2-
opencv-python>=3.0
3-
box2d-py==2.3.5
4-
scipy>=1.4.1
51
numpy>=1.18.0
6-
pyglet>=1.4.0
72
cloudpickle>=1.2.0
3+
importlib_metadata>=4.8.0; python_version < '3.10'
4+
gym_notices>=0.0.4
5+
dataclasses==0.8; python_version == '3.6'
6+
opencv-python>=3.0
87
lz4>=3.1.0
8+
matplotlib>=3.0
9+
box2d-py==2.3.5
910
pygame==2.1.0
11+
ale-py~=0.7.5
12+
mujoco==2.2.0
13+
mujoco_py<2.2,>=2.1
14+
imageio>=2.14.1

setup.py

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""Setups the project."""
22
import itertools
3-
import os.path
4-
import sys
3+
import re
54

65
from setuptools import find_packages, setup
76

8-
# Don't import gym module here, since deps may not be installed
9-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "gym"))
10-
from version import VERSION # noqa:E402
7+
with open("gym/version.py") as file:
8+
full_version = file.read()
9+
assert (
10+
re.match(r'VERSION = "\d\.\d+\.\d+"\n', full_version).group(0) == full_version
11+
), f"Unexpected version: {full_version}"
12+
VERSION = re.search(r"\d\.\d+\.\d+", full_version).group(0)
1113

1214
# Environment-specific dependencies.
1315
extras = {
@@ -17,29 +19,20 @@
1719
"classic_control": ["pygame==2.1.0"],
1820
"mujoco_py": ["mujoco_py<2.2,>=2.1"],
1921
"mujoco": ["mujoco==2.2.0", "imageio>=2.14.1"],
20-
"toy_text": ["pygame==2.1.0", "scipy>=1.4.1"],
22+
"toy_text": ["pygame==2.1.0"],
2123
"other": ["lz4>=3.1.0", "opencv-python>=3.0", "matplotlib>=3.0"],
2224
}
2325

24-
# Meta dependency groups.
25-
nomujoco_blacklist = {"mujoco_py", "mujoco", "accept-rom-license", "atari"}
26-
nomujoco_groups = set(extras.keys()) - nomujoco_blacklist
27-
28-
extras["nomujoco"] = list(
29-
itertools.chain.from_iterable(map(lambda group: extras[group], nomujoco_groups))
30-
)
31-
32-
noatari_blacklist = {"accept-rom-license", "atari"}
33-
noatari_groups = set(extras.keys()) - noatari_blacklist
34-
extras["noatari"] = list(
35-
itertools.chain.from_iterable(map(lambda group: extras[group], noatari_groups))
36-
)
37-
38-
all_blacklist = {"accept-rom-license"}
39-
all_groups = set(extras.keys()) - all_blacklist
26+
# Testing dependency groups.
27+
testing_group = set(extras.keys()) - {"accept-rom-license", "atari"}
28+
extras["testing"] = list(
29+
set(itertools.chain.from_iterable(map(lambda group: extras[group], testing_group)))
30+
) + ["pytest", "mock"]
4031

32+
# All dependency groups - accept rom license as requires user to run
33+
all_groups = set(extras.keys()) - {"accept-rom-license"}
4134
extras["all"] = list(
42-
itertools.chain.from_iterable(map(lambda group: extras[group], all_groups))
35+
set(itertools.chain.from_iterable(map(lambda group: extras[group], all_groups)))
4336
)
4437

4538
# Uses the readme as the description on PyPI
@@ -55,25 +48,31 @@
5548
break
5649

5750
setup(
58-
name="gym",
59-
version=VERSION,
60-
description="Gym: A universal API for reinforcement learning environments",
61-
url="https://www.gymlibrary.ml/",
6251
author="Gym Community",
6352
author_email="jkterry@umd.edu",
53+
classifiers=[
54+
# Python 3.6 is minimally supported (only with basic gym environments and API)
55+
"Programming Language :: Python :: 3",
56+
"Programming Language :: Python :: 3.6",
57+
"Programming Language :: Python :: 3.7",
58+
"Programming Language :: Python :: 3.8",
59+
"Programming Language :: Python :: 3.9",
60+
"Programming Language :: Python :: 3.10",
61+
],
62+
description="Gym: A universal API for reinforcement learning environments",
63+
extras_require=extras,
64+
install_requires=[
65+
"numpy >= 1.18.0",
66+
"cloudpickle >= 1.2.0",
67+
"importlib_metadata >= 4.8.0; python_version < '3.10'",
68+
"gym_notices >= 0.0.4",
69+
"dataclasses == 0.8; python_version == '3.6'",
70+
],
6471
license="MIT",
65-
packages=[package for package in find_packages() if package.startswith("gym")],
66-
zip_safe=False,
6772
long_description=long_description,
6873
long_description_content_type="text/markdown",
69-
install_requires=[
70-
"numpy>=1.18.0",
71-
"cloudpickle>=1.2.0",
72-
"importlib_metadata>=4.8.0; python_version < '3.10'",
73-
"gym_notices>=0.0.4",
74-
"dataclasses==0.8; python_version == '3.6'",
75-
],
76-
extras_require=extras,
74+
name="gym",
75+
packages=[package for package in find_packages() if package.startswith("gym")],
7776
package_data={
7877
"gym": [
7978
"envs/mujoco/assets/*.xml",
@@ -83,14 +82,9 @@
8382
"py.typed",
8483
]
8584
},
86-
tests_require=["pytest", "mock"],
8785
python_requires=">=3.6",
88-
classifiers=[
89-
"Programming Language :: Python :: 3",
90-
"Programming Language :: Python :: 3.6",
91-
"Programming Language :: Python :: 3.7",
92-
"Programming Language :: Python :: 3.8",
93-
"Programming Language :: Python :: 3.9",
94-
"Programming Language :: Python :: 3.10",
95-
],
86+
tests_require=extras["testing"],
87+
url="https://www.gymlibrary.ml/",
88+
version=VERSION,
89+
zip_safe=False,
9690
)

test_requirements.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
lz4~=3.1
2-
pytest~=6.2
1+
box2d-py==2.3.5
2+
lz4>=3.1.0
3+
opencv-python>=3.0
4+
mujoco==2.2.0
5+
matplotlib>=3.0
6+
imageio>=2.14.1
7+
pygame==2.1.0
8+
mujoco_py<2.2,>=2.1
9+
pytest
10+
mock

0 commit comments

Comments
 (0)