Browse Source

setup.py to pyprpoject.toml (#295)

Co-authored-by: Mark Towers <mark.m.towers@gmail.com>
Jet 2 years ago
parent
commit
52e41dfae8
2 changed files with 74 additions and 78 deletions
  1. 66 9
      pyproject.toml
  2. 8 69
      setup.py

+ 66 - 9
pyproject.toml

@@ -1,5 +1,69 @@
-[tool.pyright]
+# Package ######################################################################
+
+[build-system]
+requires = ["setuptools >= 61.0.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "minigrid"
+description = "Minimalistic gridworld reinforcement learning environments."
+readme = "README.md"
+requires-python = ">= 3.7, < 3.11"
+authors = [{ name = "Farama Foundation", email = "contact@farama.org" }]
+license = { text = "MIT License" }
+keywords = ["Memory, Environment, Agent, RL, 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",
+    'Intended Audience :: Science/Research',
+    'Topic :: Scientific/Engineering :: Artificial Intelligence',
+]
+dependencies = [
+    "numpy>=1.18.0",
+    "gymnasium>=0.26",
+    "matplotlib>=3.0",
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+testing = [
+    "pytest>=7.0.1",
+    "pytest-mock>=3.10.0",
+]
+
+[project.urls]
+Homepage = "https://farama.org"
+Repository = "https://minigrid.farama.org/"
+Documentation = "https://minigrid.farama.org/"
+"Bug Report" = "https://github.com/Farama-Foundation/Minigrid/issues"
+
+[project.entry-points."gymnasium.envs"]
+__root__ = "minigrid.__init__:register_minigrid_envs"
+
+[tool.setuptools]
+include-package-data = true
+
+[tool.setuptools.packages.find]
+include = ["minigrid"]
+
+# Linters and Test tools #######################################################
 
+[tool.black]
+safe = true
+
+[tool.isort]
+atomic = true
+profile = "black"
+append_only = true
+src_paths = ["minigrid", "tests"]
+add_imports = [ "from __future__ import annotations" ]
+
+[tool.pyright]
 include = [
     "minigrid/**",
 ]
@@ -9,9 +73,7 @@ exclude = [
     "**/__pycache__",
 ]
 
-strict = [
-
-]
+strict = []
 
 typeCheckingMode = "basic"
 pythonVersion = "3.7"
@@ -35,8 +97,3 @@ reportPrivateImportUsage = "none"
 
 [tool.pytest.ini_options]
 filterwarnings = ['ignore:.*step API.*:DeprecationWarning'] # TODO: to be removed when old step API is removed
-
-[tool.isort]
-profile = "black"
-add_imports = [ "from __future__ import annotations" ]
-append_only = true

+ 8 - 69
setup.py

@@ -1,84 +1,23 @@
-"""Setups up the Minigrid module."""
+"""Setups the project."""
 
 from __future__ import annotations
 
-from setuptools import find_packages, setup
+import pathlib
 
+from setuptools import setup
 
-def get_description():
-    """Gets the description from the readme."""
-    with open("README.md") as fh:
-        long_description = ""
-        header_count = 0
-        for line in fh:
-            if line.startswith("##"):
-                header_count += 1
-            if header_count < 2:
-                long_description += line
-            else:
-                break
-    return header_count, long_description
+CWD = pathlib.Path(__file__).absolute().parent
 
 
 def get_version():
     """Gets the minigrid version."""
-    path = "minigrid/__init__.py"
-    with open(path) as file:
-        lines = file.readlines()
+    path = CWD / "minigrid" / "__init__.py"
+    content = path.read_text()
 
-    for line in lines:
+    for line in content.splitlines():
         if line.startswith("__version__"):
             return line.strip().split()[-1].strip().strip('"')
     raise RuntimeError("bad version data in __init__.py")
 
 
-def get_requirements():
-    """Gets the description from the readme."""
-    with open("requirements.txt") as reqs_file:
-        reqs = reqs_file.readlines()
-    return reqs
-
-
-def get_tests_requirements():
-    """Gets the description from the readme."""
-    with open("test_requirements.txt") as test_reqs_file:
-        test_reqs = test_reqs_file.readlines()
-    return test_reqs
-
-
-# pytest is pinned to 7.0.1 as this is last version for python 3.6
-extras = {"testing": get_tests_requirements()}
-
-version = get_version()
-header_count, long_description = get_description()
-
-setup(
-    name="Minigrid",
-    version=version,
-    author="Farama Foundation",
-    author_email="contact@farama.org",
-    description="Minimalistic gridworld reinforcement learning environments",
-    url="https://minigrid.farama.org/",
-    license="Apache",
-    license_files=("LICENSE",),
-    long_description=long_description,
-    long_description_content_type="text/markdown",
-    keywords=["Memory, Environment, Agent, RL, Gymnasium"],
-    python_requires=">=3.7, <3.11",
-    packages=[package for package in find_packages() if package.startswith("minigrid")],
-    include_package_data=True,
-    install_requires=get_requirements(),
-    classifiers=[
-        "Development Status :: 5 - Production/Stable",
-        "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.7",
-        "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",
-        "Programming Language :: Python :: 3.10",
-    ],
-    extras_require=extras,
-    entry_points={
-        "gymnasium.envs": ["__root__ = minigrid.__init__:register_minigrid_envs"]
-    },
-    tests_require=extras["testing"],
-)
+setup(name="minigrid", version=get_version())