Packaging with pyproject.toml (#180)

This commit is contained in:
Xuehai Pan
2022-12-05 19:56:00 +08:00
committed by GitHub
parent 90cca7c796
commit bc0ca6c308
18 changed files with 164 additions and 168 deletions

View File

@@ -39,15 +39,15 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: '3.x' python-version: '3.x'
- name: Install dependencies - name: Install dependencies
run: python -m pip install --upgrade setuptools wheel run: python -m pip install --upgrade pip setuptools build
- name: Build wheels - name: Build sdist and wheels
run: python setup.py sdist bdist_wheel run: python -m build
- name: Store wheels - name: Store wheels
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
path: dist path: dist
@@ -58,7 +58,7 @@ jobs:
if: github.event_name == 'release' && github.event.action == 'published' if: github.event_name == 'release' && github.event.action == 'published'
steps: steps:
- name: Download dists - name: Download dists
uses: actions/download-artifact@v2 uses: actions/download-artifact@v3
with: with:
name: artifact name: artifact
path: dist path: dist

View File

@@ -11,7 +11,7 @@ jobs:
matrix: matrix:
python-version: ['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@v3
- run: | - run: |
docker build -f bin/all-py.Dockerfile \ docker build -f bin/all-py.Dockerfile \
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \
@@ -23,7 +23,7 @@ jobs:
runs-on: runs-on:
ubuntu-latest ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- run: | - run: |
docker build -f bin/necessary-py.Dockerfile \ docker build -f bin/necessary-py.Dockerfile \
--build-arg PYTHON_VERSION='3.10' \ --build-arg PYTHON_VERSION='3.10' \

View File

@@ -13,9 +13,9 @@ jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-python@v2 - uses: actions/setup-python@v4
- run: pip install pre-commit - run: python -m pip install pre-commit
- run: pre-commit --version - run: python -m pre_commit --version
- run: pre-commit install - run: python -m pre_commit install
- run: pre-commit run --all-files - run: python -m pre_commit run --all-files

View File

@@ -169,9 +169,9 @@ class AntEnv(MujocoEnv, utils.EzPickle):
| `exclude_current_positions_from_observation`| **bool** | `True`| Whether or not to omit the x- and y-coordinates from observations. Excluding the position can serve as an inductive bias to induce position-agnostic behavior in policies | | `exclude_current_positions_from_observation`| **bool** | `True`| Whether or not to omit the x- and y-coordinates from observations. Excluding the position can serve as an inductive bias to induce position-agnostic behavior in policies |
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -128,9 +128,9 @@ class HalfCheetahEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -134,9 +134,9 @@ class HopperEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -208,9 +208,9 @@ class HumanoidEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -184,9 +184,9 @@ class HumanoidStandupEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -117,9 +117,9 @@ class InvertedDoublePendulumEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum) * v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -86,9 +86,9 @@ class InvertedPendulumEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum) * v1: max_time_steps raised to 1000 for robot based tasks (including inverted pendulum)
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -133,8 +133,8 @@ class PusherEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (not including reacher, which has a max_time_steps of 50). Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks (not including reacher, which has a max_time_steps of 50). Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -115,8 +115,8 @@ class ReacherEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks (not including reacher, which has a max_time_steps of 50). Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks (not including reacher, which has a max_time_steps of 50). Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -117,9 +117,9 @@ class SwimmerEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -139,9 +139,9 @@ class Walker2dEnv(MujocoEnv, utils.EzPickle):
## Version History ## Version History
* v4: all mujoco environments now use the mujoco bindings in mujoco>=2.1.3 * v4: All MuJoCo environments now use the MuJoCo bindings in mujoco >= 2.1.3
* v3: support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen) * v3: Support for `gymnasium.make` kwargs such as `xml_file`, `ctrl_cost_weight`, `reset_noise_scale`, etc. rgb rendering comes from tracking camera (so agent does not run away from screen)
* v2: All continuous control environments now use mujoco_py >= 1.50 * v2: All continuous control environments now use mujoco-py >= 1.50
* v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments. * v1: max_time_steps raised to 1000 for robot based tasks. Added reward_threshold to environments.
* v0: Initial versions release (1.0.0) * v0: Initial versions release (1.0.0)
""" """

View File

@@ -1,3 +1,113 @@
# Package ######################################################################
[build-system]
requires = ["setuptools >= 61.0.0"]
build-backend = "setuptools.build_meta"
[project]
name = "gymnasium"
description = "A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)."
readme = "README.md"
requires-python = ">= 3.7"
authors = [{ name = "Farama Foundation", email = "contact@farama.org" }]
license = { text = "MIT License" }
keywords = ["Reinforcement Learning", "game", "RL", "AI", "gymnasium"]
classifiers = [
"Development Status :: 4 - Beta", # change to `5 - Production/Stable` when ready
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
]
dependencies = [
"numpy >=1.21.0",
"jax-jumpy >=0.2.0",
"cloudpickle >=1.2.0",
"importlib-metadata >=4.8.0; python_version < '3.10'",
"typing-extensions >=4.3.0; python_version == '3.7'",
"gymnasium-notices >=0.0.1",
"shimmy >=0.1.0,<1.0",
]
dynamic = ["version"]
[project.optional-dependencies]
# Update dependencies in `all` if any are added or removed
atari = ["shimmy[atari] >=0.1.0,<1.0"]
accept-rom-license = ["autorom[accept-rom-license] ~=0.4.2"]
box2d = ["box2d-py ==2.3.5", "pygame ==2.1.3.dev8", "swig ==4.*"]
classic-control = ["pygame ==2.1.3.dev8"]
classic_control = ["pygame ==2.1.3.dev8"] # kept for backward compatibility
mujoco-py = ["mujoco-py >=2.1,<2.2"]
mujoco_py = ["mujoco-py >=2.1,<2.2"] # kept for backward compatibility
mujoco = ["mujoco >=2.3.0", "imageio >=2.14.1"]
toy-text = ["pygame ==2.1.3.dev8"]
toy_text = ["pygame ==2.1.3.dev8"] # kept for backward compatibility
jax = ["jax ==0.3.20", "jaxlib ==0.3.20"]
other = [
"lz4 >=3.1.0",
"opencv-python >=3.0",
"matplotlib >=3.0",
"moviepy >=1.0.0",
"tensorflow >=2.1.0",
"torch >=1.0.0",
]
all = [
# All dependencies above except accept-rom-license
# NOTE: No need to manually remove the duplicates, setuptools automatically does that.
# atari
"shimmy[atari] >=0.1.0,<1.0",
# box2d
"box2d-py ==2.3.5",
"pygame ==2.1.3.dev8",
"swig ==4.*",
# classic-control
"pygame ==2.1.3.dev8",
# mujoco-py
"mujoco-py >=2.1,<2.2",
# mujoco
"mujoco >=2.3.0",
"imageio >=2.14.1",
# toy-text
"pygame ==2.1.3.dev8",
# jax
"jax ==0.3.20",
"jaxlib ==0.3.20",
# other
"lz4 >=3.1.0",
"opencv-python >=3.0",
"matplotlib >=3.0",
"moviepy >=1.0.0",
"tensorflow >=2.1.0",
"torch >=1.0.0",
]
testing = ["pytest ==7.1.3"]
[project.urls]
Homepage = "https://farama.org"
Repository = "https://github.com/Farama-Foundation/Gymnasium"
Documentation = "https://gymnasium.farama.org"
"Bug Report" = "https://github.com/Farama-Foundation/Gymnasium/issues"
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
include = ["gymnasium", "gymnasium.*"]
[tool.setuptools.package-data]
gymnasium = [
"envs/mujoco/assets/*.xml",
"envs/classic_control/assets/*.png",
"envs/toy_text/font/*.ttf",
"envs/toy_text/img/*.png",
"py.typed",
]
# Linters and Test tools ####################################################### # Linters and Test tools #######################################################
[tool.black] [tool.black]
@@ -7,6 +117,7 @@ safe = true
atomic = true atomic = true
profile = "black" profile = "black"
src_paths = ["gymnasium", "tests", "docs/scripts"] src_paths = ["gymnasium", "tests", "docs/scripts"]
extra_standard_library = ["typing_extensions"]
indent = 4 indent = 4
lines_after_imports = 2 lines_after_imports = 2
multi_line_output = 3 multi_line_output = 3

View File

@@ -1,15 +0,0 @@
numpy>=1.21.0
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'
typing_extensions==4.3.0; python_version == '3.7'
opencv-python>=3.0
lz4>=3.1.0
matplotlib>=3.0
box2d-py==2.3.5
pygame==2.1.3.dev8
ale-py~=0.8.0
mujoco>=2.3.0
mujoco_py<2.2,>=2.1
imageio>=2.14.1

106
setup.py
View File

@@ -1,112 +1,22 @@
"""Setups the project.""" """Setups the project."""
import itertools
from typing import Dict, List
from setuptools import find_packages, setup import pathlib
from setuptools import setup
def get_description(): CWD = pathlib.Path(__file__).absolute().parent
"""Gets the description from the readme."""
with open("README.md") as file:
long_description = ""
header_count = 0
for line in file:
if line.startswith("##"):
header_count += 1
if header_count < 2:
long_description += line
else:
break
return header_count, long_description
def get_version(): def get_version():
"""Gets the gymnasium version.""" """Gets the gymnasium version."""
path = "gymnasium/__init__.py" path = CWD / "gymnasium" / "__init__.py"
with open(path) as file: content = path.read_text()
lines = file.readlines()
for line in lines: for line in content.splitlines():
if line.startswith("__version__"): if line.startswith("__version__"):
return line.strip().split()[-1].strip().strip('"') return line.strip().split()[-1].strip().strip('"')
raise RuntimeError("bad version data in __init__.py") raise RuntimeError("bad version data in __init__.py")
# Environment-specific dependencies. setup(name="gymnasium", version=get_version())
extras: Dict[str, List[str]] = {
"atari": ["shimmy[atari]>=0.1.0,<1.0"],
"accept-rom-license": ["autorom[accept-rom-license]~=0.4.2"],
"box2d": ["box2d-py==2.3.5", "pygame==2.1.0", "swig==4.*"],
"classic_control": ["pygame==2.1.0"],
"mujoco_py": ["mujoco_py<2.2,>=2.1"],
"mujoco": ["mujoco>=2.3.0", "imageio>=2.14.1"],
"toy_text": ["pygame==2.1.0"],
"jax": ["jax==0.3.20", "jaxlib==0.3.20"],
"other": [
"lz4>=3.1.0",
"opencv-python>=3.0",
"matplotlib>=3.0",
"moviepy>=1.0.0",
"tensorflow>=2.1.0",
"torch>=1.0.0",
],
}
# All dependency groups - accept rom license as requires user to run
all_groups = set(extras.keys()) - {"accept-rom-license"}
extras["all"] = list(
set(itertools.chain.from_iterable(map(lambda group: extras[group], all_groups)))
)
extras["testing"] = [
"pytest==7.1.3",
]
version = get_version()
header_count, long_description = get_description()
setup(
name="Gymnasium",
version=version,
author="Farama Foundation",
author_email="contact@farama.org",
description="A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym)",
url="https://gymnasium.farama.org/",
license="MIT",
license_files=("LICENSE",),
long_description=long_description,
long_description_content_type="text/markdown",
keywords=["Reinforcement Learning", "game", "RL", "AI", "gymnasium"],
python_requires=">=3.7",
tests_require=extras["testing"],
packages=[
package for package in find_packages() if package.startswith("gymnasium")
],
package_data={
"gymnasium": [
"envs/mujoco/assets/*.xml",
"envs/classic_control/assets/*.png",
"envs/toy_text/font/*.ttf",
"envs/toy_text/img/*.png",
"py.typed",
]
},
include_package_data=True,
install_requires=[
"numpy >= 1.21.0",
"jax-jumpy >= 0.2.0",
"cloudpickle >= 1.2.0",
"importlib_metadata >= 4.8.0; python_version < '3.10'",
"gymnasium_notices >= 0.0.1",
"shimmy>=0.1.0, <1.0",
],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
],
extras_require=extras,
zip_safe=False,
)

View File

@@ -1,10 +0,0 @@
box2d-py==2.3.5
lz4>=3.1.0
opencv-python>=3.0
mujoco>=2.3.0
matplotlib>=3.0
imageio>=2.14.1
pygame==2.1.3.dev8
mujoco_py<2.2,>=2.1
pytest==7.1.3
gym==0.26.2