From 649a474788b4dd4a7e0de1fcb9e894aeef3b7b4e Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Wed, 11 Oct 2023 16:54:44 -0700 Subject: [PATCH] Migrate to pyproject.toml. PiperOrigin-RevId: 572726851 Change-Id: Iad254df70d15c962a5e58c8caf82b32530d26b06 --- python/MANIFEST.in | 3 +- python/make_sdist.sh | 6 +-- python/make_sdist_requirements.txt | 16 +++++++ python/pyproject.toml | 58 +++++++++++++++++++++++ python/setup.py | 75 +++--------------------------- 5 files changed, 84 insertions(+), 74 deletions(-) create mode 100644 python/pyproject.toml diff --git a/python/MANIFEST.in b/python/MANIFEST.in index b13b0582..a55f15f1 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -1,4 +1,3 @@ include LICENSE *.md -recursive-include mujoco *.h *.cc *.mm CMakeLists.txt Simulate*.cmake -recursive-include cmake *.cmake +recursive-include mujoco *.h *.cc *.mm CMakeLists.txt *.cmake recursive-include mujoco/mjpython mjpython.* Info.plist diff --git a/python/make_sdist.sh b/python/make_sdist.sh index 71cc5272..1466cb3d 100755 --- a/python/make_sdist.sh +++ b/python/make_sdist.sh @@ -50,13 +50,13 @@ export PYTHONPATH="${old_pythonpath}" cp "${package_dir}"/../LICENSE . # Copy over CMake scripts. -mkdir cmake -cp "${package_dir}"/../cmake/*.cmake cmake +mkdir mujoco/cmake +cp "${package_dir}"/../cmake/*.cmake mujoco/cmake # Copy over Simulate source code. cp -r "${package_dir}"/../simulate mujoco -python setup.py sdist --formats=gztar +python -m build . --sdist tar -tf dist/mujoco-*.tar.gz popd diff --git a/python/make_sdist_requirements.txt b/python/make_sdist_requirements.txt index 11376359..91f7bdb8 100644 --- a/python/make_sdist_requirements.txt +++ b/python/make_sdist_requirements.txt @@ -1,6 +1,22 @@ absl-py==2.0.0 \ --hash=sha256:9a28abb62774ae4e8edbe2dd4c49ffcd45a6a848952a5eccc6a49f3f0fc1e2f3 +build==1.0.3 \ + --hash=sha256:589bf99a67df7c9cf07ec0ac0e5e2ea5d4b37ac63301c4986d1acb126aa83f8f pip==23.2.1 \ --hash=sha256:7ccf472345f20d35bdc9d1841ff5f313260c2c33fe417f48c30ac46cccabf5be setuptools==68.2.2 \ --hash=sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a + +# Transitive dependencies of build +colorama==0.4.6; platform_system == 'Windows' \ + --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 +importlib-metadata==6.8.0; python_version < '3.10' \ + --hash=sha256:3ebb78df84a805d7698245025b975d9d67053cd94c79245ba4b3eb694abe68bb +packaging==23.2 \ + --hash=sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7 +pyproject_hooks==1.0.0 \ + --hash=sha256:283c11acd6b928d2f6a7c73fa0d01cb2bdc5f07c57a2eeb6e83d5e56b97976f8 +tomli==2.0.1; python_version < '3.11' \ + --hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc +zipp==3.17.0; python_version < '3.10' \ + --hash=sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31 diff --git a/python/pyproject.toml b/python/pyproject.toml new file mode 100644 index 00000000..c9c0b204 --- /dev/null +++ b/python/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "mujoco" +version = "2.3.8" +authors = [ + {name = "Google DeepMind", email = "mujoco@deepmind.com"}, +] +description = "MuJoCo Physics Simulator" +requires-python = ">=3.8" +license = {text = "Apache License 2.0"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering", +] +dependencies = [ + "absl-py", + "glfw", + "numpy", + "pyopengl", +] +dynamic = ["readme", "scripts"] + +[project.urls] +Homepage = "https://github.com/google-deepmind/mujoco" +Documentation = "https://mujoco.readthedocs.io/en/2.3.8" +Repository = "https://github.com/google-deepmind/mujoco" +Changelog = "https://mujoco.readthedocs.io/en/2.3.8/changelog.html" + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.packages.find] +include = ["mujoco*"] +exclude = [ + "mujoco.codegen", + "mujoco.mjpython", +] + +[tool.setuptools.package-data] +mujoco = [ + "libmujoco.*.dylib", + "libmujoco*.so.*", + "mujoco.dll", + "include/mujoco/*.h", +] diff --git a/python/setup.py b/python/setup.py index 0025b2b9..bc1934bb 100644 --- a/python/setup.py +++ b/python/setup.py @@ -27,13 +27,9 @@ import sys import sysconfig import setuptools -from setuptools import find_packages -from setuptools import setup from setuptools.command import build_ext from setuptools.command import install_scripts -__version__ = '2.3.8' - MUJOCO_CMAKE = 'MUJOCO_CMAKE' MUJOCO_CMAKE_ARGS = 'MUJOCO_CMAKE_ARGS' MUJOCO_PATH = 'MUJOCO_PATH' @@ -242,7 +238,8 @@ class BuildCMakeExtension(build_ext.build_ext): """Check for CMake.""" cmake = os.environ.get(MUJOCO_CMAKE, 'cmake') build_cfg = 'Debug' if self.debug else 'Release' - cmake_module_path = os.path.join(os.path.dirname(__file__), 'cmake') + cmake_module_path = os.path.join( + os.path.dirname(__file__), 'mujoco', 'cmake') cmake_args = [ f'-DPython3_ROOT_DIR:PATH={sys.prefix}', f'-DPython3_EXECUTABLE:STRING={sys.executable}', @@ -334,41 +331,9 @@ class InstallScripts(install_scripts.install_scripts): else: self.outfiles.append(oldfile) - -def find_data_files(package_dir, patterns): - """Recursively finds files whose names match the given shell patterns.""" - paths = set() - for directory, _, filenames in os.walk(package_dir): - for pattern in patterns: - for filename in fnmatch.filter(filenames, pattern): - # NB: paths must be relative to the package directory. - relative_dirpath = os.path.relpath(directory, package_dir) - paths.add(os.path.join(relative_dirpath, filename)) - return list(paths) - -SETUP_KWARGS = dict( - name='mujoco', - version=__version__, - author='Google DeepMind', - author_email='mujoco@deepmind.com', - description='MuJoCo Physics Simulator', +setuptools.setup( long_description=get_long_description(), long_description_content_type='text/markdown', - url='https://github.com/google-deepmind/mujoco', - license='Apache License 2.0', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: Apache Software License', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Topic :: Scientific/Engineering', - ], cmdclass=dict( build_ext=BuildCMakeExtension, install_scripts=InstallScripts, @@ -384,35 +349,7 @@ SETUP_KWARGS = dict( CMakeExtension('mujoco._simulate'), CMakeExtension('mujoco._structs'), ], - python_requires='>=3.8', - install_requires=[ - 'absl-py', - 'glfw', - 'numpy', - 'pyopengl', - ], - tests_require=[ - 'absl-py', - 'glfw', - 'numpy', - 'pyopengl', - ], - test_suite='mujoco', - packages=find_packages(), - package_data={ - 'mujoco': - find_data_files( - package_dir='mujoco', - patterns=[ - 'libmujoco.*.dylib', - 'libmujoco*.so.*', - 'mujoco.dll', - 'include/mujoco/*.h', - ]), - }, + scripts=[ + 'mujoco/mjpython/mjpython.py' + ] if platform.system() == 'Darwin' else [], ) - -if platform.system() == 'Darwin': - SETUP_KWARGS['scripts'] = ['mujoco/mjpython/mjpython.py'] - -setup(**SETUP_KWARGS)