diff --git a/setup.py b/.flake8 similarity index 82% rename from setup.py rename to .flake8 index 14491434..0ce4adb0 100644 --- a/setup.py +++ b/.flake8 @@ -1,5 +1,4 @@ -# Copyright 2020,2021 Sony Corporation. -# Copyright 2021 Sony Group Corporation. +# Copyright 2024 Sony Group Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import setup - -setup() +[flake8] +max-line-length = 120 +extend-ignore = E203,E701 +filename = "*.py" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 08959d90..71b77975 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -177,4 +177,4 @@ jobs: pip install -r requirements.txt - name: check pydoc format with docformat run: | - docformatter --exclude build --check --config setup.cfg . \ No newline at end of file + docformatter --exclude build --check --config pyproject.toml . diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a9547db6..10a09339 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,7 +20,7 @@ jobs: pip install -r deploy_requirements.txt - name: Build release distributions run: | - python setup.py bdist_wheel + python -m build --wheel - name: Temporarily upload release distribution uses: actions/upload-artifact@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 483f8929..72675223 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -106,7 +106,7 @@ You can run tests with the following command. ```sh cd -python setup.py test +pytest ``` #### Evaluating the algorithm @@ -145,5 +145,5 @@ Use docformatter to properly format the pydoc written in each python files. Run docformatter as follows: ```sh -docformatter --exclude build --i --config setup.cfg . +docformatter --exclude build --i --config pyproject.toml . ``` \ No newline at end of file diff --git a/bin/insert_copyright b/bin/insert_copyright index 90bdc534..7fd73e54 100755 --- a/bin/insert_copyright +++ b/bin/insert_copyright @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2021,2022 Sony Group Corporation. +# Copyright 2021,2022,2023,2024 Sony Group Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import re import subprocess _exclude_dirs = ['external', '.git'] -_insert_file_regex = re.compile('.*.(py|cfg|ini|sh)') +_insert_file_regex = re.compile('.*.(py|cfg|ini|sh|toml|flake8)') _header_extract_regex = re.compile('# Copyright \\d{4}.*? limitations under the License.', re.DOTALL) _shebang_extract_regex = re.compile('#!.+') _date_extract_regex = re.compile('(\\d{4}-\\d{2}-\\d{2})') diff --git a/deploy_requirements.txt b/deploy_requirements.txt index 358f8fa1..ab77f0f6 100644 --- a/deploy_requirements.txt +++ b/deploy_requirements.txt @@ -1,3 +1,4 @@ -setuptools +setuptools >= 61.0.0 wheel numpy>=1.17 +build diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..cc3fc41d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,139 @@ +# Copyright 2024 Sony Group Corporation. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +requires = [ + "setuptools >= 61.0.0", + "wheel", + "pytest-runner" +] +build-backend = "setuptools.build_meta" + +[project] +name = "nnabla_rl" +authors = [ + { name = "Sony Group Corporation" } +] +maintainers = [ + { name = "Yu Ishihara" }, + { name = "Shunichi Sekiguchi" }, + { name = "Takayoshi Takayanagi" }, +] +description = "Deep reinforcement learning library built on top of Neural Network Libraries" +license = {file = "LICENSE"} +readme = "README.md" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Operating System :: POSIX :: Linux" +] +keywords = [ + "deep learning", + "artificial intelligence", + "machine learning", + "neural network" +] +requires-python = ">=3.8" +dynamic = ["version"] +dependencies = [ + "nnabla >= 1.17, != 1.18.0", + "numpy >= 1.17", + "gym < 0.26.0", + "opencv-python", + "packaging", + "tqdm", + "gymnasium" +] + +[project.urls] +Homepage = "https://github.com/sony/nnabla-rl" +Repository = "https://github.com/sony/nnabla-rl" +Documentation = "https://nnabla-rl.readthedocs.io/en/latest/" + +[project.optional-dependencies] +render = ["pyglet >= 1.4.0"] +dev = [ + "flake8", + "pylint", + "pytest", + "pytest-cov", + "mypy != 1.11.0", + "typing-extensions", + "isort", + "autopep8", + "docformatter" +] +deploy = [ + "setuptools >= 61.0.0", + "wheel", + "build", + "twine" +] +doc = ["sphinx", "sphinx_rtd_theme"] +test = [ + "pytest", + "pytest-cov", + "mock" +] + +[tool.setuptools.dynamic] +version = {attr = "nnabla_rl.__version__"} + +[tool.setuptools.packages.find] +exclude = [ + "bin*", + "docs*", + "examples*", + "interactive-demos", + "reproductions*", + "tests*", + "test_resources*", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = "-s" + +[tool.autopep8] +max_line_length = 120 +recursive = true + +[tool.isort] +line_length = 120 +honor_noqa = true +known_first_party = ["nnabla"] +skip_glob = ["external"] + +[tool.mypy] +python_version = 3.8 +ignore_missing_imports = true +no_implicit_optional = true +warn_unused_configs = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_return_any = true +warn_unreachable = true +files = ["nnabla_rl"] + +[tool.docformatter] +recursive = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cceef4bc..00000000 --- a/setup.cfg +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright 2020,2021 Sony Corporation. -# Copyright 2021,2022,2023,2024 Sony Group Corporation. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -[metadata] -name = nnabla_rl -version = attr: nnabla_rl.__version__ -author = Yu Ishihara, Sony Group Corporation -description = Deep reinforcement learning library built on top of Neural Network Libraries -license = Apache License 2.0 -url = https://github.com/sony/nnabla-rl -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Education - Intended Audience :: Science/Research - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Artificial Intelligence - License :: OSI Approved :: Apache Software License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Operating System :: POSIX :: Linux -keywords = deep learning artificial intelligence machine learning neural network -python_requires = >=3.8 - -[options] -packages = find: -setup_requires = pytest-runner -install_requires = - nnabla>=1.17,!=1.18.0 - numpy>=1.17 - gym<0.26.0 - opencv-python - packaging - tqdm - gymnasium -scripts = - bin/check_best_iteration - bin/compile_results - bin/evaluate_algorithm - bin/insert_copyright - bin/plot_result - bin/train_with_seeds - bin/test_reproductions -test_suite = tests -tests_require = pytest; pytest-cov; mock - -[options.extras_require] -render = pyglet>=1.4.0 -dev = flake8; pylint; pytest; pytest-cov; mypy; typing-extensions; isort; autopep8; docformatter -deploy = setuptools; wheel; twine -doc = sphinx; sphinx_rtd_theme - -[options.packages.find] -exclude = - examples - reproductions - tests - -[aliases] -test=pytest - -[tool:pytest] -addopts=-s - -[pep8] -max-line-length=120 -recursive=true - -[isort] -line_length=120 -honor_noqa=True -known_first_party=nnabla -skip_glob=external - -[mypy] -# See https://mypy.readthedocs.io/en/stable/config_file.html for detail description of each configuration -python_version = 3.8 -ignore_missing_imports = True -no_implicit_optional = True -warn_unused_configs = True -warn_redundant_casts = True -warn_unused_ignores = True -warn_return_any = True -warn_unreachable = True -files = nnabla_rl - -[flake8] -max-line-length=120 -filename=*.py - -[docformatter] -recursive = true \ No newline at end of file