savoji commited on
Commit
43c3e5d
·
verified ·
1 Parent(s): 67240eb

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/__init__.py +14 -0
  2. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/dep_util.py +14 -0
  3. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/errors.py +108 -0
  4. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/extension.py +258 -0
  5. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/support.py +134 -0
  6. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_bdist_rpm.py +127 -0
  7. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build.py +49 -0
  8. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_clib.py +134 -0
  9. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_ext.py +628 -0
  10. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_py.py +196 -0
  11. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_clean.py +45 -0
  12. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_cmd.py +107 -0
  13. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_config_cmd.py +87 -0
  14. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_core.py +130 -0
  15. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_dist.py +552 -0
  16. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_extension.py +117 -0
  17. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_file_util.py +95 -0
  18. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_install_data.py +74 -0
  19. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_log.py +12 -0
  20. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_modified.py +126 -0
  21. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_spawn.py +141 -0
  22. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_sysconfig.py +319 -0
  23. project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_util.py +243 -0
  24. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_scene/0_scene_config.yaml +20 -0
  25. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/0_scene_config.yaml +20 -0
  26. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/1_scene_config.yaml +20 -0
  27. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/2_scene_config.yaml +20 -0
  28. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/3_scene_config.yaml +20 -0
  29. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/4_scene_config.yaml +20 -0
  30. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/5_scene_config.yaml +20 -0
  31. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene.yaml +19 -0
  32. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene_shelf.yaml +28 -0
  33. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene_shelf_box.yaml +28 -0
  34. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/10_scene_config.yaml +298 -0
  35. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/13_scene_config.yaml +298 -0
  36. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/18_scene_config.yaml +298 -0
  37. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/6_scene_config.yaml +298 -0
  38. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/8_scene_config.yaml +298 -0
  39. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__init__.py +27 -0
  40. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/__init__.cpython-310.pyc +0 -0
  41. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/object_pick_env.cpython-310.pyc +0 -0
  42. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/random_obstacle_reach_env.cpython-310.pyc +0 -0
  43. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/scene_generator_env.cpython-310.pyc +0 -0
  44. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/shelf_env.cpython-310.pyc +0 -0
  45. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/ms2/__init__.py +0 -0
  46. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/object_pick_env.py +426 -0
  47. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/object_pick_env.yaml +21 -0
  48. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/random_obstacle_reach_env.py +482 -0
  49. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/scene_generator_env.py +583 -0
  50. project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/shelf_env.py +173 -0
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/__init__.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import importlib
2
+ import sys
3
+
4
+ __version__, _, _ = sys.version.partition(' ')
5
+
6
+
7
+ try:
8
+ # Allow Debian and pkgsrc (only) to customize system
9
+ # behavior. Ref pypa/distutils#2 and pypa/distutils#16.
10
+ # This hook is deprecated and no other environments
11
+ # should use it.
12
+ importlib.import_module('_distutils_system_mod')
13
+ except ImportError:
14
+ pass
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/dep_util.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+
3
+ from . import _modified
4
+
5
+
6
+ def __getattr__(name):
7
+ if name not in ['newer', 'newer_group', 'newer_pairwise']:
8
+ raise AttributeError(name)
9
+ warnings.warn(
10
+ "dep_util is Deprecated. Use functions from setuptools instead.",
11
+ DeprecationWarning,
12
+ stacklevel=2,
13
+ )
14
+ return getattr(_modified, name)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/errors.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Exceptions used by the Distutils modules.
3
+
4
+ Distutils modules may raise these or standard exceptions,
5
+ including :exc:`SystemExit`.
6
+ """
7
+
8
+ # compiler exceptions aliased for compatibility
9
+ from .compilers.C.errors import CompileError as CompileError
10
+ from .compilers.C.errors import Error as _Error
11
+ from .compilers.C.errors import LibError as LibError
12
+ from .compilers.C.errors import LinkError as LinkError
13
+ from .compilers.C.errors import PreprocessError as PreprocessError
14
+ from .compilers.C.errors import UnknownFileType as _UnknownFileType
15
+
16
+ CCompilerError = _Error
17
+ UnknownFileError = _UnknownFileType
18
+
19
+
20
+ class DistutilsError(Exception):
21
+ """The root of all Distutils evil."""
22
+
23
+ pass
24
+
25
+
26
+ class DistutilsModuleError(DistutilsError):
27
+ """Unable to load an expected module, or to find an expected class
28
+ within some module (in particular, command modules and classes)."""
29
+
30
+ pass
31
+
32
+
33
+ class DistutilsClassError(DistutilsError):
34
+ """Some command class (or possibly distribution class, if anyone
35
+ feels a need to subclass Distribution) is found not to be holding
36
+ up its end of the bargain, ie. implementing some part of the
37
+ "command "interface."""
38
+
39
+ pass
40
+
41
+
42
+ class DistutilsGetoptError(DistutilsError):
43
+ """The option table provided to 'fancy_getopt()' is bogus."""
44
+
45
+ pass
46
+
47
+
48
+ class DistutilsArgError(DistutilsError):
49
+ """Raised by fancy_getopt in response to getopt.error -- ie. an
50
+ error in the command line usage."""
51
+
52
+ pass
53
+
54
+
55
+ class DistutilsFileError(DistutilsError):
56
+ """Any problems in the filesystem: expected file not found, etc.
57
+ Typically this is for problems that we detect before OSError
58
+ could be raised."""
59
+
60
+ pass
61
+
62
+
63
+ class DistutilsOptionError(DistutilsError):
64
+ """Syntactic/semantic errors in command options, such as use of
65
+ mutually conflicting options, or inconsistent options,
66
+ badly-spelled values, etc. No distinction is made between option
67
+ values originating in the setup script, the command line, config
68
+ files, or what-have-you -- but if we *know* something originated in
69
+ the setup script, we'll raise DistutilsSetupError instead."""
70
+
71
+ pass
72
+
73
+
74
+ class DistutilsSetupError(DistutilsError):
75
+ """For errors that can be definitely blamed on the setup script,
76
+ such as invalid keyword arguments to 'setup()'."""
77
+
78
+ pass
79
+
80
+
81
+ class DistutilsPlatformError(DistutilsError):
82
+ """We don't know how to do something on the current platform (but
83
+ we do know how to do it on some platform) -- eg. trying to compile
84
+ C files on a platform not supported by a CCompiler subclass."""
85
+
86
+ pass
87
+
88
+
89
+ class DistutilsExecError(DistutilsError):
90
+ """Any problems executing an external program (such as the C
91
+ compiler, when compiling C files)."""
92
+
93
+ pass
94
+
95
+
96
+ class DistutilsInternalError(DistutilsError):
97
+ """Internal inconsistencies or impossibilities (obviously, this
98
+ should never be seen if the code is working!)."""
99
+
100
+ pass
101
+
102
+
103
+ class DistutilsTemplateError(DistutilsError):
104
+ """Syntax error in a file list template."""
105
+
106
+
107
+ class DistutilsByteCompileError(DistutilsError):
108
+ """Byte compile error."""
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/extension.py ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """distutils.extension
2
+
3
+ Provides the Extension class, used to describe C/C++ extension
4
+ modules in setup scripts."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import os
9
+ import warnings
10
+ from collections.abc import Iterable
11
+
12
+ # This class is really only used by the "build_ext" command, so it might
13
+ # make sense to put it in distutils.command.build_ext. However, that
14
+ # module is already big enough, and I want to make this class a bit more
15
+ # complex to simplify some common cases ("foo" module in "foo.c") and do
16
+ # better error-checking ("foo.c" actually exists).
17
+ #
18
+ # Also, putting this in build_ext.py means every setup script would have to
19
+ # import that large-ish module (indirectly, through distutils.core) in
20
+ # order to do anything.
21
+
22
+
23
+ class Extension:
24
+ """Just a collection of attributes that describes an extension
25
+ module and everything needed to build it (hopefully in a portable
26
+ way, but there are hooks that let you be as unportable as you need).
27
+
28
+ Instance attributes:
29
+ name : string
30
+ the full name of the extension, including any packages -- ie.
31
+ *not* a filename or pathname, but Python dotted name
32
+ sources : Iterable[string | os.PathLike]
33
+ iterable of source filenames (except strings, which could be misinterpreted
34
+ as a single filename), relative to the distribution root (where the setup
35
+ script lives), in Unix form (slash-separated) for portability. Can be any
36
+ non-string iterable (list, tuple, set, etc.) containing strings or
37
+ PathLike objects. Source files may be C, C++, SWIG (.i), platform-specific
38
+ resource files, or whatever else is recognized by the "build_ext" command
39
+ as source for a Python extension.
40
+ include_dirs : [string]
41
+ list of directories to search for C/C++ header files (in Unix
42
+ form for portability)
43
+ define_macros : [(name : string, value : string|None)]
44
+ list of macros to define; each macro is defined using a 2-tuple,
45
+ where 'value' is either the string to define it to or None to
46
+ define it without a particular value (equivalent of "#define
47
+ FOO" in source or -DFOO on Unix C compiler command line)
48
+ undef_macros : [string]
49
+ list of macros to undefine explicitly
50
+ library_dirs : [string]
51
+ list of directories to search for C/C++ libraries at link time
52
+ libraries : [string]
53
+ list of library names (not filenames or paths) to link against
54
+ runtime_library_dirs : [string]
55
+ list of directories to search for C/C++ libraries at run time
56
+ (for shared extensions, this is when the extension is loaded)
57
+ extra_objects : [string]
58
+ list of extra files to link with (eg. object files not implied
59
+ by 'sources', static library that must be explicitly specified,
60
+ binary resource files, etc.)
61
+ extra_compile_args : [string]
62
+ any extra platform- and compiler-specific information to use
63
+ when compiling the source files in 'sources'. For platforms and
64
+ compilers where "command line" makes sense, this is typically a
65
+ list of command-line arguments, but for other platforms it could
66
+ be anything.
67
+ extra_link_args : [string]
68
+ any extra platform- and compiler-specific information to use
69
+ when linking object files together to create the extension (or
70
+ to create a new static Python interpreter). Similar
71
+ interpretation as for 'extra_compile_args'.
72
+ export_symbols : [string]
73
+ list of symbols to be exported from a shared extension. Not
74
+ used on all platforms, and not generally necessary for Python
75
+ extensions, which typically export exactly one symbol: "init" +
76
+ extension_name.
77
+ swig_opts : [string]
78
+ any extra options to pass to SWIG if a source file has the .i
79
+ extension.
80
+ depends : [string]
81
+ list of files that the extension depends on
82
+ language : string
83
+ extension language (i.e. "c", "c++", "objc"). Will be detected
84
+ from the source extensions if not provided.
85
+ optional : boolean
86
+ specifies that a build failure in the extension should not abort the
87
+ build process, but simply not install the failing extension.
88
+ """
89
+
90
+ # When adding arguments to this constructor, be sure to update
91
+ # setup_keywords in core.py.
92
+ def __init__(
93
+ self,
94
+ name: str,
95
+ sources: Iterable[str | os.PathLike[str]],
96
+ include_dirs: list[str] | None = None,
97
+ define_macros: list[tuple[str, str | None]] | None = None,
98
+ undef_macros: list[str] | None = None,
99
+ library_dirs: list[str] | None = None,
100
+ libraries: list[str] | None = None,
101
+ runtime_library_dirs: list[str] | None = None,
102
+ extra_objects: list[str] | None = None,
103
+ extra_compile_args: list[str] | None = None,
104
+ extra_link_args: list[str] | None = None,
105
+ export_symbols: list[str] | None = None,
106
+ swig_opts: list[str] | None = None,
107
+ depends: list[str] | None = None,
108
+ language: str | None = None,
109
+ optional: bool | None = None,
110
+ **kw, # To catch unknown keywords
111
+ ):
112
+ if not isinstance(name, str):
113
+ raise TypeError("'name' must be a string")
114
+
115
+ # handle the string case first; since strings are iterable, disallow them
116
+ if isinstance(sources, str):
117
+ raise TypeError(
118
+ "'sources' must be an iterable of strings or PathLike objects, not a string"
119
+ )
120
+
121
+ # now we check if it's iterable and contains valid types
122
+ try:
123
+ self.sources = list(map(os.fspath, sources))
124
+ except TypeError:
125
+ raise TypeError(
126
+ "'sources' must be an iterable of strings or PathLike objects"
127
+ )
128
+
129
+ self.name = name
130
+ self.include_dirs = include_dirs or []
131
+ self.define_macros = define_macros or []
132
+ self.undef_macros = undef_macros or []
133
+ self.library_dirs = library_dirs or []
134
+ self.libraries = libraries or []
135
+ self.runtime_library_dirs = runtime_library_dirs or []
136
+ self.extra_objects = extra_objects or []
137
+ self.extra_compile_args = extra_compile_args or []
138
+ self.extra_link_args = extra_link_args or []
139
+ self.export_symbols = export_symbols or []
140
+ self.swig_opts = swig_opts or []
141
+ self.depends = depends or []
142
+ self.language = language
143
+ self.optional = optional
144
+
145
+ # If there are unknown keyword options, warn about them
146
+ if len(kw) > 0:
147
+ options = [repr(option) for option in kw]
148
+ options = ', '.join(sorted(options))
149
+ msg = f"Unknown Extension options: {options}"
150
+ warnings.warn(msg)
151
+
152
+ def __repr__(self):
153
+ return f'<{self.__class__.__module__}.{self.__class__.__qualname__}({self.name!r}) at {id(self):#x}>'
154
+
155
+
156
+ def read_setup_file(filename): # noqa: C901
157
+ """Reads a Setup file and returns Extension instances."""
158
+ from distutils.sysconfig import _variable_rx, expand_makefile_vars, parse_makefile
159
+ from distutils.text_file import TextFile
160
+ from distutils.util import split_quoted
161
+
162
+ # First pass over the file to gather "VAR = VALUE" assignments.
163
+ vars = parse_makefile(filename)
164
+
165
+ # Second pass to gobble up the real content: lines of the form
166
+ # <module> ... [<sourcefile> ...] [<cpparg> ...] [<library> ...]
167
+ file = TextFile(
168
+ filename,
169
+ strip_comments=True,
170
+ skip_blanks=True,
171
+ join_lines=True,
172
+ lstrip_ws=True,
173
+ rstrip_ws=True,
174
+ )
175
+ try:
176
+ extensions = []
177
+
178
+ while True:
179
+ line = file.readline()
180
+ if line is None: # eof
181
+ break
182
+ if _variable_rx.match(line): # VAR=VALUE, handled in first pass
183
+ continue
184
+
185
+ if line[0] == line[-1] == "*":
186
+ file.warn(f"'{line}' lines not handled yet")
187
+ continue
188
+
189
+ line = expand_makefile_vars(line, vars)
190
+ words = split_quoted(line)
191
+
192
+ # NB. this parses a slightly different syntax than the old
193
+ # makesetup script: here, there must be exactly one extension per
194
+ # line, and it must be the first word of the line. I have no idea
195
+ # why the old syntax supported multiple extensions per line, as
196
+ # they all wind up being the same.
197
+
198
+ module = words[0]
199
+ ext = Extension(module, [])
200
+ append_next_word = None
201
+
202
+ for word in words[1:]:
203
+ if append_next_word is not None:
204
+ append_next_word.append(word)
205
+ append_next_word = None
206
+ continue
207
+
208
+ suffix = os.path.splitext(word)[1]
209
+ switch = word[0:2]
210
+ value = word[2:]
211
+
212
+ if suffix in (".c", ".cc", ".cpp", ".cxx", ".c++", ".m", ".mm"):
213
+ # hmm, should we do something about C vs. C++ sources?
214
+ # or leave it up to the CCompiler implementation to
215
+ # worry about?
216
+ ext.sources.append(word)
217
+ elif switch == "-I":
218
+ ext.include_dirs.append(value)
219
+ elif switch == "-D":
220
+ equals = value.find("=")
221
+ if equals == -1: # bare "-DFOO" -- no value
222
+ ext.define_macros.append((value, None))
223
+ else: # "-DFOO=blah"
224
+ ext.define_macros.append((value[0:equals], value[equals + 2 :]))
225
+ elif switch == "-U":
226
+ ext.undef_macros.append(value)
227
+ elif switch == "-C": # only here 'cause makesetup has it!
228
+ ext.extra_compile_args.append(word)
229
+ elif switch == "-l":
230
+ ext.libraries.append(value)
231
+ elif switch == "-L":
232
+ ext.library_dirs.append(value)
233
+ elif switch == "-R":
234
+ ext.runtime_library_dirs.append(value)
235
+ elif word == "-rpath":
236
+ append_next_word = ext.runtime_library_dirs
237
+ elif word == "-Xlinker":
238
+ append_next_word = ext.extra_link_args
239
+ elif word == "-Xcompiler":
240
+ append_next_word = ext.extra_compile_args
241
+ elif switch == "-u":
242
+ ext.extra_link_args.append(word)
243
+ if not value:
244
+ append_next_word = ext.extra_link_args
245
+ elif suffix in (".a", ".so", ".sl", ".o", ".dylib"):
246
+ # NB. a really faithful emulation of makesetup would
247
+ # append a .o file to extra_objects only if it
248
+ # had a slash in it; otherwise, it would s/.o/.c/
249
+ # and append it to sources. Hmmmm.
250
+ ext.extra_objects.append(word)
251
+ else:
252
+ file.warn(f"unrecognized argument '{word}'")
253
+
254
+ extensions.append(ext)
255
+ finally:
256
+ file.close()
257
+
258
+ return extensions
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/support.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Support code for distutils test cases."""
2
+
3
+ import itertools
4
+ import os
5
+ import pathlib
6
+ import shutil
7
+ import sys
8
+ import sysconfig
9
+ import tempfile
10
+ from distutils.core import Distribution
11
+
12
+ import pytest
13
+ from more_itertools import always_iterable
14
+
15
+
16
+ @pytest.mark.usefixtures('distutils_managed_tempdir')
17
+ class TempdirManager:
18
+ """
19
+ Mix-in class that handles temporary directories for test cases.
20
+ """
21
+
22
+ def mkdtemp(self):
23
+ """Create a temporary directory that will be cleaned up.
24
+
25
+ Returns the path of the directory.
26
+ """
27
+ d = tempfile.mkdtemp()
28
+ self.tempdirs.append(d)
29
+ return d
30
+
31
+ def write_file(self, path, content='xxx'):
32
+ """Writes a file in the given path.
33
+
34
+ path can be a string or a sequence.
35
+ """
36
+ pathlib.Path(*always_iterable(path)).write_text(content, encoding='utf-8')
37
+
38
+ def create_dist(self, pkg_name='foo', **kw):
39
+ """Will generate a test environment.
40
+
41
+ This function creates:
42
+ - a Distribution instance using keywords
43
+ - a temporary directory with a package structure
44
+
45
+ It returns the package directory and the distribution
46
+ instance.
47
+ """
48
+ tmp_dir = self.mkdtemp()
49
+ pkg_dir = os.path.join(tmp_dir, pkg_name)
50
+ os.mkdir(pkg_dir)
51
+ dist = Distribution(attrs=kw)
52
+
53
+ return pkg_dir, dist
54
+
55
+
56
+ class DummyCommand:
57
+ """Class to store options for retrieval via set_undefined_options()."""
58
+
59
+ def __init__(self, **kwargs):
60
+ vars(self).update(kwargs)
61
+
62
+ def ensure_finalized(self):
63
+ pass
64
+
65
+
66
+ def copy_xxmodule_c(directory):
67
+ """Helper for tests that need the xxmodule.c source file.
68
+
69
+ Example use:
70
+
71
+ def test_compile(self):
72
+ copy_xxmodule_c(self.tmpdir)
73
+ self.assertIn('xxmodule.c', os.listdir(self.tmpdir))
74
+
75
+ If the source file can be found, it will be copied to *directory*. If not,
76
+ the test will be skipped. Errors during copy are not caught.
77
+ """
78
+ shutil.copy(_get_xxmodule_path(), os.path.join(directory, 'xxmodule.c'))
79
+
80
+
81
+ def _get_xxmodule_path():
82
+ source_name = 'xxmodule.c' if sys.version_info > (3, 9) else 'xxmodule-3.8.c'
83
+ return os.path.join(os.path.dirname(__file__), source_name)
84
+
85
+
86
+ def fixup_build_ext(cmd):
87
+ """Function needed to make build_ext tests pass.
88
+
89
+ When Python was built with --enable-shared on Unix, -L. is not enough to
90
+ find libpython<blah>.so, because regrtest runs in a tempdir, not in the
91
+ source directory where the .so lives.
92
+
93
+ When Python was built with in debug mode on Windows, build_ext commands
94
+ need their debug attribute set, and it is not done automatically for
95
+ some reason.
96
+
97
+ This function handles both of these things. Example use:
98
+
99
+ cmd = build_ext(dist)
100
+ support.fixup_build_ext(cmd)
101
+ cmd.ensure_finalized()
102
+
103
+ Unlike most other Unix platforms, Mac OS X embeds absolute paths
104
+ to shared libraries into executables, so the fixup is not needed there.
105
+ """
106
+ if os.name == 'nt':
107
+ cmd.debug = sys.executable.endswith('_d.exe')
108
+ elif sysconfig.get_config_var('Py_ENABLE_SHARED'):
109
+ # To further add to the shared builds fun on Unix, we can't just add
110
+ # library_dirs to the Extension() instance because that doesn't get
111
+ # plumbed through to the final compiler command.
112
+ runshared = sysconfig.get_config_var('RUNSHARED')
113
+ if runshared is None:
114
+ cmd.library_dirs = ['.']
115
+ else:
116
+ if sys.platform == 'darwin':
117
+ cmd.library_dirs = []
118
+ else:
119
+ name, equals, value = runshared.partition('=')
120
+ cmd.library_dirs = [d for d in value.split(os.pathsep) if d]
121
+
122
+
123
+ def combine_markers(cls):
124
+ """
125
+ pytest will honor markers as found on the class, but when
126
+ markers are on multiple subclasses, only one appears. Use
127
+ this decorator to combine those markers.
128
+ """
129
+ cls.pytestmark = [
130
+ mark
131
+ for base in itertools.chain([cls], cls.__bases__)
132
+ for mark in getattr(base, 'pytestmark', [])
133
+ ]
134
+ return cls
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_bdist_rpm.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.bdist_rpm."""
2
+
3
+ import os
4
+ import shutil # noqa: F401
5
+ import sys
6
+ from distutils.command.bdist_rpm import bdist_rpm
7
+ from distutils.core import Distribution
8
+ from distutils.tests import support
9
+
10
+ import pytest
11
+ from test.support import requires_zlib
12
+
13
+ SETUP_PY = """\
14
+ from distutils.core import setup
15
+ import foo
16
+
17
+ setup(name='foo', version='0.1', py_modules=['foo'],
18
+ url='xxx', author='xxx', author_email='xxx')
19
+
20
+ """
21
+
22
+
23
+ @pytest.fixture(autouse=True)
24
+ def sys_executable_encodable():
25
+ try:
26
+ sys.executable.encode('UTF-8')
27
+ except UnicodeEncodeError:
28
+ pytest.skip("sys.executable is not encodable to UTF-8")
29
+
30
+
31
+ mac_woes = pytest.mark.skipif(
32
+ "not sys.platform.startswith('linux')",
33
+ reason='spurious sdtout/stderr output under macOS',
34
+ )
35
+
36
+
37
+ @pytest.mark.usefixtures('save_env')
38
+ @pytest.mark.usefixtures('save_argv')
39
+ @pytest.mark.usefixtures('save_cwd')
40
+ class TestBuildRpm(
41
+ support.TempdirManager,
42
+ ):
43
+ @mac_woes
44
+ @requires_zlib()
45
+ @pytest.mark.skipif("not shutil.which('rpm')")
46
+ @pytest.mark.skipif("not shutil.which('rpmbuild')")
47
+ def test_quiet(self):
48
+ # let's create a package
49
+ tmp_dir = self.mkdtemp()
50
+ os.environ['HOME'] = tmp_dir # to confine dir '.rpmdb' creation
51
+ pkg_dir = os.path.join(tmp_dir, 'foo')
52
+ os.mkdir(pkg_dir)
53
+ self.write_file((pkg_dir, 'setup.py'), SETUP_PY)
54
+ self.write_file((pkg_dir, 'foo.py'), '#')
55
+ self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py')
56
+ self.write_file((pkg_dir, 'README'), '')
57
+
58
+ dist = Distribution({
59
+ 'name': 'foo',
60
+ 'version': '0.1',
61
+ 'py_modules': ['foo'],
62
+ 'url': 'xxx',
63
+ 'author': 'xxx',
64
+ 'author_email': 'xxx',
65
+ })
66
+ dist.script_name = 'setup.py'
67
+ os.chdir(pkg_dir)
68
+
69
+ sys.argv = ['setup.py']
70
+ cmd = bdist_rpm(dist)
71
+ cmd.fix_python = True
72
+
73
+ # running in quiet mode
74
+ cmd.quiet = True
75
+ cmd.ensure_finalized()
76
+ cmd.run()
77
+
78
+ dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
79
+ assert 'foo-0.1-1.noarch.rpm' in dist_created
80
+
81
+ # bug #2945: upload ignores bdist_rpm files
82
+ assert ('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm') in dist.dist_files
83
+ assert ('bdist_rpm', 'any', 'dist/foo-0.1-1.noarch.rpm') in dist.dist_files
84
+
85
+ @mac_woes
86
+ @requires_zlib()
87
+ # https://bugs.python.org/issue1533164
88
+ @pytest.mark.skipif("not shutil.which('rpm')")
89
+ @pytest.mark.skipif("not shutil.which('rpmbuild')")
90
+ def test_no_optimize_flag(self):
91
+ # let's create a package that breaks bdist_rpm
92
+ tmp_dir = self.mkdtemp()
93
+ os.environ['HOME'] = tmp_dir # to confine dir '.rpmdb' creation
94
+ pkg_dir = os.path.join(tmp_dir, 'foo')
95
+ os.mkdir(pkg_dir)
96
+ self.write_file((pkg_dir, 'setup.py'), SETUP_PY)
97
+ self.write_file((pkg_dir, 'foo.py'), '#')
98
+ self.write_file((pkg_dir, 'MANIFEST.in'), 'include foo.py')
99
+ self.write_file((pkg_dir, 'README'), '')
100
+
101
+ dist = Distribution({
102
+ 'name': 'foo',
103
+ 'version': '0.1',
104
+ 'py_modules': ['foo'],
105
+ 'url': 'xxx',
106
+ 'author': 'xxx',
107
+ 'author_email': 'xxx',
108
+ })
109
+ dist.script_name = 'setup.py'
110
+ os.chdir(pkg_dir)
111
+
112
+ sys.argv = ['setup.py']
113
+ cmd = bdist_rpm(dist)
114
+ cmd.fix_python = True
115
+
116
+ cmd.quiet = True
117
+ cmd.ensure_finalized()
118
+ cmd.run()
119
+
120
+ dist_created = os.listdir(os.path.join(pkg_dir, 'dist'))
121
+ assert 'foo-0.1-1.noarch.rpm' in dist_created
122
+
123
+ # bug #2945: upload ignores bdist_rpm files
124
+ assert ('bdist_rpm', 'any', 'dist/foo-0.1-1.src.rpm') in dist.dist_files
125
+ assert ('bdist_rpm', 'any', 'dist/foo-0.1-1.noarch.rpm') in dist.dist_files
126
+
127
+ os.remove(os.path.join(pkg_dir, 'dist', 'foo-0.1-1.noarch.rpm'))
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.build."""
2
+
3
+ import os
4
+ import sys
5
+ from distutils.command.build import build
6
+ from distutils.tests import support
7
+ from sysconfig import get_config_var, get_platform
8
+
9
+
10
+ class TestBuild(support.TempdirManager):
11
+ def test_finalize_options(self):
12
+ pkg_dir, dist = self.create_dist()
13
+ cmd = build(dist)
14
+ cmd.finalize_options()
15
+
16
+ # if not specified, plat_name gets the current platform
17
+ assert cmd.plat_name == get_platform()
18
+
19
+ # build_purelib is build + lib
20
+ wanted = os.path.join(cmd.build_base, 'lib')
21
+ assert cmd.build_purelib == wanted
22
+
23
+ # build_platlib is 'build/lib.platform-cache_tag[-pydebug]'
24
+ # examples:
25
+ # build/lib.macosx-10.3-i386-cpython39
26
+ plat_spec = f'.{cmd.plat_name}-{sys.implementation.cache_tag}'
27
+ if get_config_var('Py_GIL_DISABLED'):
28
+ plat_spec += 't'
29
+ if hasattr(sys, 'gettotalrefcount'):
30
+ assert cmd.build_platlib.endswith('-pydebug')
31
+ plat_spec += '-pydebug'
32
+ wanted = os.path.join(cmd.build_base, 'lib' + plat_spec)
33
+ assert cmd.build_platlib == wanted
34
+
35
+ # by default, build_lib = build_purelib
36
+ assert cmd.build_lib == cmd.build_purelib
37
+
38
+ # build_temp is build/temp.<plat>
39
+ wanted = os.path.join(cmd.build_base, 'temp' + plat_spec)
40
+ assert cmd.build_temp == wanted
41
+
42
+ # build_scripts is build/scripts-x.x
43
+ wanted = os.path.join(
44
+ cmd.build_base, f'scripts-{sys.version_info.major}.{sys.version_info.minor}'
45
+ )
46
+ assert cmd.build_scripts == wanted
47
+
48
+ # executable is os.path.normpath(sys.executable)
49
+ assert cmd.executable == os.path.normpath(sys.executable)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_clib.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.build_clib."""
2
+
3
+ import os
4
+ from distutils.command.build_clib import build_clib
5
+ from distutils.errors import DistutilsSetupError
6
+ from distutils.tests import missing_compiler_executable, support
7
+
8
+ import pytest
9
+
10
+
11
+ class TestBuildCLib(support.TempdirManager):
12
+ def test_check_library_dist(self):
13
+ pkg_dir, dist = self.create_dist()
14
+ cmd = build_clib(dist)
15
+
16
+ # 'libraries' option must be a list
17
+ with pytest.raises(DistutilsSetupError):
18
+ cmd.check_library_list('foo')
19
+
20
+ # each element of 'libraries' must a 2-tuple
21
+ with pytest.raises(DistutilsSetupError):
22
+ cmd.check_library_list(['foo1', 'foo2'])
23
+
24
+ # first element of each tuple in 'libraries'
25
+ # must be a string (the library name)
26
+ with pytest.raises(DistutilsSetupError):
27
+ cmd.check_library_list([(1, 'foo1'), ('name', 'foo2')])
28
+
29
+ # library name may not contain directory separators
30
+ with pytest.raises(DistutilsSetupError):
31
+ cmd.check_library_list(
32
+ [('name', 'foo1'), ('another/name', 'foo2')],
33
+ )
34
+
35
+ # second element of each tuple must be a dictionary (build info)
36
+ with pytest.raises(DistutilsSetupError):
37
+ cmd.check_library_list(
38
+ [('name', {}), ('another', 'foo2')],
39
+ )
40
+
41
+ # those work
42
+ libs = [('name', {}), ('name', {'ok': 'good'})]
43
+ cmd.check_library_list(libs)
44
+
45
+ def test_get_source_files(self):
46
+ pkg_dir, dist = self.create_dist()
47
+ cmd = build_clib(dist)
48
+
49
+ # "in 'libraries' option 'sources' must be present and must be
50
+ # a list of source filenames
51
+ cmd.libraries = [('name', {})]
52
+ with pytest.raises(DistutilsSetupError):
53
+ cmd.get_source_files()
54
+
55
+ cmd.libraries = [('name', {'sources': 1})]
56
+ with pytest.raises(DistutilsSetupError):
57
+ cmd.get_source_files()
58
+
59
+ cmd.libraries = [('name', {'sources': ['a', 'b']})]
60
+ assert cmd.get_source_files() == ['a', 'b']
61
+
62
+ cmd.libraries = [('name', {'sources': ('a', 'b')})]
63
+ assert cmd.get_source_files() == ['a', 'b']
64
+
65
+ cmd.libraries = [
66
+ ('name', {'sources': ('a', 'b')}),
67
+ ('name2', {'sources': ['c', 'd']}),
68
+ ]
69
+ assert cmd.get_source_files() == ['a', 'b', 'c', 'd']
70
+
71
+ def test_build_libraries(self):
72
+ pkg_dir, dist = self.create_dist()
73
+ cmd = build_clib(dist)
74
+
75
+ class FakeCompiler:
76
+ def compile(*args, **kw):
77
+ pass
78
+
79
+ create_static_lib = compile
80
+
81
+ cmd.compiler = FakeCompiler()
82
+
83
+ # build_libraries is also doing a bit of typo checking
84
+ lib = [('name', {'sources': 'notvalid'})]
85
+ with pytest.raises(DistutilsSetupError):
86
+ cmd.build_libraries(lib)
87
+
88
+ lib = [('name', {'sources': list()})]
89
+ cmd.build_libraries(lib)
90
+
91
+ lib = [('name', {'sources': tuple()})]
92
+ cmd.build_libraries(lib)
93
+
94
+ def test_finalize_options(self):
95
+ pkg_dir, dist = self.create_dist()
96
+ cmd = build_clib(dist)
97
+
98
+ cmd.include_dirs = 'one-dir'
99
+ cmd.finalize_options()
100
+ assert cmd.include_dirs == ['one-dir']
101
+
102
+ cmd.include_dirs = None
103
+ cmd.finalize_options()
104
+ assert cmd.include_dirs == []
105
+
106
+ cmd.distribution.libraries = 'WONTWORK'
107
+ with pytest.raises(DistutilsSetupError):
108
+ cmd.finalize_options()
109
+
110
+ @pytest.mark.skipif('platform.system() == "Windows"')
111
+ def test_run(self):
112
+ pkg_dir, dist = self.create_dist()
113
+ cmd = build_clib(dist)
114
+
115
+ foo_c = os.path.join(pkg_dir, 'foo.c')
116
+ self.write_file(foo_c, 'int main(void) { return 1;}\n')
117
+ cmd.libraries = [('foo', {'sources': [foo_c]})]
118
+
119
+ build_temp = os.path.join(pkg_dir, 'build')
120
+ os.mkdir(build_temp)
121
+ cmd.build_temp = build_temp
122
+ cmd.build_clib = build_temp
123
+
124
+ # Before we run the command, we want to make sure
125
+ # all commands are present on the system.
126
+ ccmd = missing_compiler_executable()
127
+ if ccmd is not None:
128
+ self.skipTest(f'The {ccmd!r} command is not found')
129
+
130
+ # this should work
131
+ cmd.run()
132
+
133
+ # let's check the result
134
+ assert 'libfoo.a' in os.listdir(build_temp)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_ext.py ADDED
@@ -0,0 +1,628 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import contextlib
2
+ import glob
3
+ import importlib
4
+ import os.path
5
+ import platform
6
+ import re
7
+ import shutil
8
+ import site
9
+ import subprocess
10
+ import sys
11
+ import tempfile
12
+ import textwrap
13
+ import time
14
+ from distutils import sysconfig
15
+ from distutils.command.build_ext import build_ext
16
+ from distutils.core import Distribution
17
+ from distutils.errors import (
18
+ CompileError,
19
+ DistutilsPlatformError,
20
+ DistutilsSetupError,
21
+ UnknownFileError,
22
+ )
23
+ from distutils.extension import Extension
24
+ from distutils.tests import missing_compiler_executable
25
+ from distutils.tests.support import TempdirManager, copy_xxmodule_c, fixup_build_ext
26
+ from io import StringIO
27
+
28
+ import jaraco.path
29
+ import path
30
+ import pytest
31
+ from test import support
32
+
33
+ from .compat import py39 as import_helper
34
+
35
+
36
+ @pytest.fixture()
37
+ def user_site_dir(request):
38
+ self = request.instance
39
+ self.tmp_dir = self.mkdtemp()
40
+ self.tmp_path = path.Path(self.tmp_dir)
41
+ from distutils.command import build_ext
42
+
43
+ orig_user_base = site.USER_BASE
44
+
45
+ site.USER_BASE = self.mkdtemp()
46
+ build_ext.USER_BASE = site.USER_BASE
47
+
48
+ # bpo-30132: On Windows, a .pdb file may be created in the current
49
+ # working directory. Create a temporary working directory to cleanup
50
+ # everything at the end of the test.
51
+ with self.tmp_path:
52
+ yield
53
+
54
+ site.USER_BASE = orig_user_base
55
+ build_ext.USER_BASE = orig_user_base
56
+
57
+ if sys.platform == 'cygwin':
58
+ time.sleep(1)
59
+
60
+
61
+ @contextlib.contextmanager
62
+ def safe_extension_import(name, path):
63
+ with import_helper.CleanImport(name):
64
+ with extension_redirect(name, path) as new_path:
65
+ with import_helper.DirsOnSysPath(new_path):
66
+ yield
67
+
68
+
69
+ @contextlib.contextmanager
70
+ def extension_redirect(mod, path):
71
+ """
72
+ Tests will fail to tear down an extension module if it's been imported.
73
+
74
+ Before importing, copy the file to a temporary directory that won't
75
+ be cleaned up. Yield the new path.
76
+ """
77
+ if platform.system() != "Windows" and sys.platform != "cygwin":
78
+ yield path
79
+ return
80
+ with import_helper.DirsOnSysPath(path):
81
+ spec = importlib.util.find_spec(mod)
82
+ filename = os.path.basename(spec.origin)
83
+ trash_dir = tempfile.mkdtemp(prefix='deleteme')
84
+ dest = os.path.join(trash_dir, os.path.basename(filename))
85
+ shutil.copy(spec.origin, dest)
86
+ yield trash_dir
87
+ # TODO: can the file be scheduled for deletion?
88
+
89
+
90
+ @pytest.mark.usefixtures('user_site_dir')
91
+ class TestBuildExt(TempdirManager):
92
+ def build_ext(self, *args, **kwargs):
93
+ return build_ext(*args, **kwargs)
94
+
95
+ @pytest.mark.parametrize("copy_so", [False])
96
+ def test_build_ext(self, copy_so):
97
+ missing_compiler_executable()
98
+ copy_xxmodule_c(self.tmp_dir)
99
+ xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
100
+ xx_ext = Extension('xx', [xx_c])
101
+ if sys.platform != "win32":
102
+ if not copy_so:
103
+ xx_ext = Extension(
104
+ 'xx',
105
+ [xx_c],
106
+ library_dirs=['/usr/lib'],
107
+ libraries=['z'],
108
+ runtime_library_dirs=['/usr/lib'],
109
+ )
110
+ elif sys.platform == 'linux':
111
+ libz_so = {
112
+ os.path.realpath(name) for name in glob.iglob('/usr/lib*/libz.so*')
113
+ }
114
+ libz_so = sorted(libz_so, key=lambda lib_path: len(lib_path))
115
+ shutil.copyfile(libz_so[-1], '/tmp/libxx_z.so')
116
+
117
+ xx_ext = Extension(
118
+ 'xx',
119
+ [xx_c],
120
+ library_dirs=['/tmp'],
121
+ libraries=['xx_z'],
122
+ runtime_library_dirs=['/tmp'],
123
+ )
124
+ dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
125
+ dist.package_dir = self.tmp_dir
126
+ cmd = self.build_ext(dist)
127
+ fixup_build_ext(cmd)
128
+ cmd.build_lib = self.tmp_dir
129
+ cmd.build_temp = self.tmp_dir
130
+
131
+ old_stdout = sys.stdout
132
+ if not support.verbose:
133
+ # silence compiler output
134
+ sys.stdout = StringIO()
135
+ try:
136
+ cmd.ensure_finalized()
137
+ cmd.run()
138
+ finally:
139
+ sys.stdout = old_stdout
140
+
141
+ with safe_extension_import('xx', self.tmp_dir):
142
+ self._test_xx(copy_so)
143
+
144
+ if sys.platform == 'linux' and copy_so:
145
+ os.unlink('/tmp/libxx_z.so')
146
+
147
+ @staticmethod
148
+ def _test_xx(copy_so):
149
+ import xx # type: ignore[import-not-found] # Module generated for tests
150
+
151
+ for attr in ('error', 'foo', 'new', 'roj'):
152
+ assert hasattr(xx, attr)
153
+
154
+ assert xx.foo(2, 5) == 7
155
+ assert xx.foo(13, 15) == 28
156
+ assert xx.new().demo() is None
157
+ if support.HAVE_DOCSTRINGS:
158
+ doc = 'This is a template module just for instruction.'
159
+ assert xx.__doc__ == doc
160
+ assert isinstance(xx.Null(), xx.Null)
161
+ assert isinstance(xx.Str(), xx.Str)
162
+
163
+ if sys.platform == 'linux':
164
+ so_headers = subprocess.check_output(
165
+ ["readelf", "-d", xx.__file__], universal_newlines=True
166
+ )
167
+ import pprint
168
+
169
+ pprint.pprint(so_headers)
170
+ rpaths = [
171
+ rpath
172
+ for line in so_headers.split("\n")
173
+ if "RPATH" in line or "RUNPATH" in line
174
+ for rpath in line.split()[2][1:-1].split(":")
175
+ ]
176
+ if not copy_so:
177
+ pprint.pprint(rpaths)
178
+ # Linked against a library in /usr/lib{,64}
179
+ assert "/usr/lib" not in rpaths and "/usr/lib64" not in rpaths
180
+ else:
181
+ # Linked against a library in /tmp
182
+ assert "/tmp" in rpaths
183
+ # The import is the real test here
184
+
185
+ def test_solaris_enable_shared(self):
186
+ dist = Distribution({'name': 'xx'})
187
+ cmd = self.build_ext(dist)
188
+ old = sys.platform
189
+
190
+ sys.platform = 'sunos' # fooling finalize_options
191
+ from distutils.sysconfig import _config_vars
192
+
193
+ old_var = _config_vars.get('Py_ENABLE_SHARED')
194
+ _config_vars['Py_ENABLE_SHARED'] = True
195
+ try:
196
+ cmd.ensure_finalized()
197
+ finally:
198
+ sys.platform = old
199
+ if old_var is None:
200
+ del _config_vars['Py_ENABLE_SHARED']
201
+ else:
202
+ _config_vars['Py_ENABLE_SHARED'] = old_var
203
+
204
+ # make sure we get some library dirs under solaris
205
+ assert len(cmd.library_dirs) > 0
206
+
207
+ def test_user_site(self):
208
+ import site
209
+
210
+ dist = Distribution({'name': 'xx'})
211
+ cmd = self.build_ext(dist)
212
+
213
+ # making sure the user option is there
214
+ options = [name for name, short, label in cmd.user_options]
215
+ assert 'user' in options
216
+
217
+ # setting a value
218
+ cmd.user = True
219
+
220
+ # setting user based lib and include
221
+ lib = os.path.join(site.USER_BASE, 'lib')
222
+ incl = os.path.join(site.USER_BASE, 'include')
223
+ os.mkdir(lib)
224
+ os.mkdir(incl)
225
+
226
+ # let's run finalize
227
+ cmd.ensure_finalized()
228
+
229
+ # see if include_dirs and library_dirs
230
+ # were set
231
+ assert lib in cmd.library_dirs
232
+ assert lib in cmd.rpath
233
+ assert incl in cmd.include_dirs
234
+
235
+ def test_optional_extension(self):
236
+ # this extension will fail, but let's ignore this failure
237
+ # with the optional argument.
238
+ modules = [Extension('foo', ['xxx'], optional=False)]
239
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
240
+ cmd = self.build_ext(dist)
241
+ cmd.ensure_finalized()
242
+ with pytest.raises((UnknownFileError, CompileError)):
243
+ cmd.run() # should raise an error
244
+
245
+ modules = [Extension('foo', ['xxx'], optional=True)]
246
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
247
+ cmd = self.build_ext(dist)
248
+ cmd.ensure_finalized()
249
+ cmd.run() # should pass
250
+
251
+ def test_finalize_options(self):
252
+ # Make sure Python's include directories (for Python.h, pyconfig.h,
253
+ # etc.) are in the include search path.
254
+ modules = [Extension('foo', ['xxx'], optional=False)]
255
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
256
+ cmd = self.build_ext(dist)
257
+ cmd.finalize_options()
258
+
259
+ py_include = sysconfig.get_python_inc()
260
+ for p in py_include.split(os.path.pathsep):
261
+ assert p in cmd.include_dirs
262
+
263
+ plat_py_include = sysconfig.get_python_inc(plat_specific=True)
264
+ for p in plat_py_include.split(os.path.pathsep):
265
+ assert p in cmd.include_dirs
266
+
267
+ # make sure cmd.libraries is turned into a list
268
+ # if it's a string
269
+ cmd = self.build_ext(dist)
270
+ cmd.libraries = 'my_lib, other_lib lastlib'
271
+ cmd.finalize_options()
272
+ assert cmd.libraries == ['my_lib', 'other_lib', 'lastlib']
273
+
274
+ # make sure cmd.library_dirs is turned into a list
275
+ # if it's a string
276
+ cmd = self.build_ext(dist)
277
+ cmd.library_dirs = f'my_lib_dir{os.pathsep}other_lib_dir'
278
+ cmd.finalize_options()
279
+ assert 'my_lib_dir' in cmd.library_dirs
280
+ assert 'other_lib_dir' in cmd.library_dirs
281
+
282
+ # make sure rpath is turned into a list
283
+ # if it's a string
284
+ cmd = self.build_ext(dist)
285
+ cmd.rpath = f'one{os.pathsep}two'
286
+ cmd.finalize_options()
287
+ assert cmd.rpath == ['one', 'two']
288
+
289
+ # make sure cmd.link_objects is turned into a list
290
+ # if it's a string
291
+ cmd = build_ext(dist)
292
+ cmd.link_objects = 'one two,three'
293
+ cmd.finalize_options()
294
+ assert cmd.link_objects == ['one', 'two', 'three']
295
+
296
+ # XXX more tests to perform for win32
297
+
298
+ # make sure define is turned into 2-tuples
299
+ # strings if they are ','-separated strings
300
+ cmd = self.build_ext(dist)
301
+ cmd.define = 'one,two'
302
+ cmd.finalize_options()
303
+ assert cmd.define == [('one', '1'), ('two', '1')]
304
+
305
+ # make sure undef is turned into a list of
306
+ # strings if they are ','-separated strings
307
+ cmd = self.build_ext(dist)
308
+ cmd.undef = 'one,two'
309
+ cmd.finalize_options()
310
+ assert cmd.undef == ['one', 'two']
311
+
312
+ # make sure swig_opts is turned into a list
313
+ cmd = self.build_ext(dist)
314
+ cmd.swig_opts = None
315
+ cmd.finalize_options()
316
+ assert cmd.swig_opts == []
317
+
318
+ cmd = self.build_ext(dist)
319
+ cmd.swig_opts = '1 2'
320
+ cmd.finalize_options()
321
+ assert cmd.swig_opts == ['1', '2']
322
+
323
+ def test_check_extensions_list(self):
324
+ dist = Distribution()
325
+ cmd = self.build_ext(dist)
326
+ cmd.finalize_options()
327
+
328
+ # 'extensions' option must be a list of Extension instances
329
+ with pytest.raises(DistutilsSetupError):
330
+ cmd.check_extensions_list('foo')
331
+
332
+ # each element of 'ext_modules' option must be an
333
+ # Extension instance or 2-tuple
334
+ exts = [('bar', 'foo', 'bar'), 'foo']
335
+ with pytest.raises(DistutilsSetupError):
336
+ cmd.check_extensions_list(exts)
337
+
338
+ # first element of each tuple in 'ext_modules'
339
+ # must be the extension name (a string) and match
340
+ # a python dotted-separated name
341
+ exts = [('foo-bar', '')]
342
+ with pytest.raises(DistutilsSetupError):
343
+ cmd.check_extensions_list(exts)
344
+
345
+ # second element of each tuple in 'ext_modules'
346
+ # must be a dictionary (build info)
347
+ exts = [('foo.bar', '')]
348
+ with pytest.raises(DistutilsSetupError):
349
+ cmd.check_extensions_list(exts)
350
+
351
+ # ok this one should pass
352
+ exts = [('foo.bar', {'sources': [''], 'libraries': 'foo', 'some': 'bar'})]
353
+ cmd.check_extensions_list(exts)
354
+ ext = exts[0]
355
+ assert isinstance(ext, Extension)
356
+
357
+ # check_extensions_list adds in ext the values passed
358
+ # when they are in ('include_dirs', 'library_dirs', 'libraries'
359
+ # 'extra_objects', 'extra_compile_args', 'extra_link_args')
360
+ assert ext.libraries == 'foo'
361
+ assert not hasattr(ext, 'some')
362
+
363
+ # 'macros' element of build info dict must be 1- or 2-tuple
364
+ exts = [
365
+ (
366
+ 'foo.bar',
367
+ {
368
+ 'sources': [''],
369
+ 'libraries': 'foo',
370
+ 'some': 'bar',
371
+ 'macros': [('1', '2', '3'), 'foo'],
372
+ },
373
+ )
374
+ ]
375
+ with pytest.raises(DistutilsSetupError):
376
+ cmd.check_extensions_list(exts)
377
+
378
+ exts[0][1]['macros'] = [('1', '2'), ('3',)]
379
+ cmd.check_extensions_list(exts)
380
+ assert exts[0].undef_macros == ['3']
381
+ assert exts[0].define_macros == [('1', '2')]
382
+
383
+ def test_get_source_files(self):
384
+ modules = [Extension('foo', ['xxx'], optional=False)]
385
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
386
+ cmd = self.build_ext(dist)
387
+ cmd.ensure_finalized()
388
+ assert cmd.get_source_files() == ['xxx']
389
+
390
+ def test_unicode_module_names(self):
391
+ modules = [
392
+ Extension('foo', ['aaa'], optional=False),
393
+ Extension('föö', ['uuu'], optional=False),
394
+ ]
395
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
396
+ cmd = self.build_ext(dist)
397
+ cmd.ensure_finalized()
398
+ assert re.search(r'foo(_d)?\..*', cmd.get_ext_filename(modules[0].name))
399
+ assert re.search(r'föö(_d)?\..*', cmd.get_ext_filename(modules[1].name))
400
+ assert cmd.get_export_symbols(modules[0]) == ['PyInit_foo']
401
+ assert cmd.get_export_symbols(modules[1]) == ['PyInitU_f_1gaa']
402
+
403
+ def test_export_symbols__init__(self):
404
+ # https://github.com/python/cpython/issues/80074
405
+ # https://github.com/pypa/setuptools/issues/4826
406
+ modules = [
407
+ Extension('foo.__init__', ['aaa']),
408
+ Extension('föö.__init__', ['uuu']),
409
+ ]
410
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
411
+ cmd = self.build_ext(dist)
412
+ cmd.ensure_finalized()
413
+ assert cmd.get_export_symbols(modules[0]) == ['PyInit_foo']
414
+ assert cmd.get_export_symbols(modules[1]) == ['PyInitU_f_1gaa']
415
+
416
+ def test_compiler_option(self):
417
+ # cmd.compiler is an option and
418
+ # should not be overridden by a compiler instance
419
+ # when the command is run
420
+ dist = Distribution()
421
+ cmd = self.build_ext(dist)
422
+ cmd.compiler = 'unix'
423
+ cmd.ensure_finalized()
424
+ cmd.run()
425
+ assert cmd.compiler == 'unix'
426
+
427
+ def test_get_outputs(self):
428
+ missing_compiler_executable()
429
+ tmp_dir = self.mkdtemp()
430
+ c_file = os.path.join(tmp_dir, 'foo.c')
431
+ self.write_file(c_file, 'void PyInit_foo(void) {}\n')
432
+ ext = Extension('foo', [c_file], optional=False)
433
+ dist = Distribution({'name': 'xx', 'ext_modules': [ext]})
434
+ cmd = self.build_ext(dist)
435
+ fixup_build_ext(cmd)
436
+ cmd.ensure_finalized()
437
+ assert len(cmd.get_outputs()) == 1
438
+
439
+ cmd.build_lib = os.path.join(self.tmp_dir, 'build')
440
+ cmd.build_temp = os.path.join(self.tmp_dir, 'tempt')
441
+
442
+ # issue #5977 : distutils build_ext.get_outputs
443
+ # returns wrong result with --inplace
444
+ other_tmp_dir = os.path.realpath(self.mkdtemp())
445
+ old_wd = os.getcwd()
446
+ os.chdir(other_tmp_dir)
447
+ try:
448
+ cmd.inplace = True
449
+ cmd.run()
450
+ so_file = cmd.get_outputs()[0]
451
+ finally:
452
+ os.chdir(old_wd)
453
+ assert os.path.exists(so_file)
454
+ ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
455
+ assert so_file.endswith(ext_suffix)
456
+ so_dir = os.path.dirname(so_file)
457
+ assert so_dir == other_tmp_dir
458
+
459
+ cmd.inplace = False
460
+ cmd.compiler = None
461
+ cmd.run()
462
+ so_file = cmd.get_outputs()[0]
463
+ assert os.path.exists(so_file)
464
+ assert so_file.endswith(ext_suffix)
465
+ so_dir = os.path.dirname(so_file)
466
+ assert so_dir == cmd.build_lib
467
+
468
+ # inplace = False, cmd.package = 'bar'
469
+ build_py = cmd.get_finalized_command('build_py')
470
+ build_py.package_dir = {'': 'bar'}
471
+ path = cmd.get_ext_fullpath('foo')
472
+ # checking that the last directory is the build_dir
473
+ path = os.path.split(path)[0]
474
+ assert path == cmd.build_lib
475
+
476
+ # inplace = True, cmd.package = 'bar'
477
+ cmd.inplace = True
478
+ other_tmp_dir = os.path.realpath(self.mkdtemp())
479
+ old_wd = os.getcwd()
480
+ os.chdir(other_tmp_dir)
481
+ try:
482
+ path = cmd.get_ext_fullpath('foo')
483
+ finally:
484
+ os.chdir(old_wd)
485
+ # checking that the last directory is bar
486
+ path = os.path.split(path)[0]
487
+ lastdir = os.path.split(path)[-1]
488
+ assert lastdir == 'bar'
489
+
490
+ def test_ext_fullpath(self):
491
+ ext = sysconfig.get_config_var('EXT_SUFFIX')
492
+ # building lxml.etree inplace
493
+ # etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
494
+ # etree_ext = Extension('lxml.etree', [etree_c])
495
+ # dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
496
+ dist = Distribution()
497
+ cmd = self.build_ext(dist)
498
+ cmd.inplace = True
499
+ cmd.distribution.package_dir = {'': 'src'}
500
+ cmd.distribution.packages = ['lxml', 'lxml.html']
501
+ curdir = os.getcwd()
502
+ wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
503
+ path = cmd.get_ext_fullpath('lxml.etree')
504
+ assert wanted == path
505
+
506
+ # building lxml.etree not inplace
507
+ cmd.inplace = False
508
+ cmd.build_lib = os.path.join(curdir, 'tmpdir')
509
+ wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
510
+ path = cmd.get_ext_fullpath('lxml.etree')
511
+ assert wanted == path
512
+
513
+ # building twisted.runner.portmap not inplace
514
+ build_py = cmd.get_finalized_command('build_py')
515
+ build_py.package_dir = {}
516
+ cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
517
+ path = cmd.get_ext_fullpath('twisted.runner.portmap')
518
+ wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner', 'portmap' + ext)
519
+ assert wanted == path
520
+
521
+ # building twisted.runner.portmap inplace
522
+ cmd.inplace = True
523
+ path = cmd.get_ext_fullpath('twisted.runner.portmap')
524
+ wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
525
+ assert wanted == path
526
+
527
+ @pytest.mark.skipif('platform.system() != "Darwin"')
528
+ @pytest.mark.usefixtures('save_env')
529
+ def test_deployment_target_default(self):
530
+ # Issue 9516: Test that, in the absence of the environment variable,
531
+ # an extension module is compiled with the same deployment target as
532
+ # the interpreter.
533
+ self._try_compile_deployment_target('==', None)
534
+
535
+ @pytest.mark.skipif('platform.system() != "Darwin"')
536
+ @pytest.mark.usefixtures('save_env')
537
+ def test_deployment_target_too_low(self):
538
+ # Issue 9516: Test that an extension module is not allowed to be
539
+ # compiled with a deployment target less than that of the interpreter.
540
+ with pytest.raises(DistutilsPlatformError):
541
+ self._try_compile_deployment_target('>', '10.1')
542
+
543
+ @pytest.mark.skipif('platform.system() != "Darwin"')
544
+ @pytest.mark.usefixtures('save_env')
545
+ def test_deployment_target_higher_ok(self): # pragma: no cover
546
+ # Issue 9516: Test that an extension module can be compiled with a
547
+ # deployment target higher than that of the interpreter: the ext
548
+ # module may depend on some newer OS feature.
549
+ deptarget = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
550
+ if deptarget:
551
+ # increment the minor version number (i.e. 10.6 -> 10.7)
552
+ deptarget = [int(x) for x in deptarget.split('.')]
553
+ deptarget[-1] += 1
554
+ deptarget = '.'.join(str(i) for i in deptarget)
555
+ self._try_compile_deployment_target('<', deptarget)
556
+
557
+ def _try_compile_deployment_target(self, operator, target): # pragma: no cover
558
+ if target is None:
559
+ if os.environ.get('MACOSX_DEPLOYMENT_TARGET'):
560
+ del os.environ['MACOSX_DEPLOYMENT_TARGET']
561
+ else:
562
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
563
+
564
+ jaraco.path.build(
565
+ {
566
+ 'deptargetmodule.c': textwrap.dedent(f"""\
567
+ #include <AvailabilityMacros.h>
568
+
569
+ int dummy;
570
+
571
+ #if TARGET {operator} MAC_OS_X_VERSION_MIN_REQUIRED
572
+ #else
573
+ #error "Unexpected target"
574
+ #endif
575
+
576
+ """),
577
+ },
578
+ self.tmp_path,
579
+ )
580
+
581
+ # get the deployment target that the interpreter was built with
582
+ target = sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET')
583
+ target = tuple(map(int, target.split('.')[0:2]))
584
+ # format the target value as defined in the Apple
585
+ # Availability Macros. We can't use the macro names since
586
+ # at least one value we test with will not exist yet.
587
+ if target[:2] < (10, 10):
588
+ # for 10.1 through 10.9.x -> "10n0"
589
+ tmpl = '{:02}{:01}0'
590
+ else:
591
+ # for 10.10 and beyond -> "10nn00"
592
+ if len(target) >= 2:
593
+ tmpl = '{:02}{:02}00'
594
+ else:
595
+ # 11 and later can have no minor version (11 instead of 11.0)
596
+ tmpl = '{:02}0000'
597
+ target = tmpl.format(*target)
598
+ deptarget_ext = Extension(
599
+ 'deptarget',
600
+ [self.tmp_path / 'deptargetmodule.c'],
601
+ extra_compile_args=[f'-DTARGET={target}'],
602
+ )
603
+ dist = Distribution({'name': 'deptarget', 'ext_modules': [deptarget_ext]})
604
+ dist.package_dir = self.tmp_dir
605
+ cmd = self.build_ext(dist)
606
+ cmd.build_lib = self.tmp_dir
607
+ cmd.build_temp = self.tmp_dir
608
+
609
+ try:
610
+ old_stdout = sys.stdout
611
+ if not support.verbose:
612
+ # silence compiler output
613
+ sys.stdout = StringIO()
614
+ try:
615
+ cmd.ensure_finalized()
616
+ cmd.run()
617
+ finally:
618
+ sys.stdout = old_stdout
619
+
620
+ except CompileError:
621
+ self.fail("Wrong deployment target during compilation")
622
+
623
+
624
+ class TestParallelBuildExt(TestBuildExt):
625
+ def build_ext(self, *args, **kwargs):
626
+ build_ext = super().build_ext(*args, **kwargs)
627
+ build_ext.parallel = True
628
+ return build_ext
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_build_py.py ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.build_py."""
2
+
3
+ import os
4
+ import sys
5
+ from distutils.command.build_py import build_py
6
+ from distutils.core import Distribution
7
+ from distutils.errors import DistutilsFileError
8
+ from distutils.tests import support
9
+
10
+ import jaraco.path
11
+ import pytest
12
+
13
+
14
+ @support.combine_markers
15
+ class TestBuildPy(support.TempdirManager):
16
+ def test_package_data(self):
17
+ sources = self.mkdtemp()
18
+ jaraco.path.build(
19
+ {
20
+ '__init__.py': "# Pretend this is a package.",
21
+ 'README.txt': 'Info about this package',
22
+ },
23
+ sources,
24
+ )
25
+
26
+ destination = self.mkdtemp()
27
+
28
+ dist = Distribution({"packages": ["pkg"], "package_dir": {"pkg": sources}})
29
+ # script_name need not exist, it just need to be initialized
30
+ dist.script_name = os.path.join(sources, "setup.py")
31
+ dist.command_obj["build"] = support.DummyCommand(
32
+ force=False, build_lib=destination
33
+ )
34
+ dist.packages = ["pkg"]
35
+ dist.package_data = {"pkg": ["README.txt"]}
36
+ dist.package_dir = {"pkg": sources}
37
+
38
+ cmd = build_py(dist)
39
+ cmd.compile = True
40
+ cmd.ensure_finalized()
41
+ assert cmd.package_data == dist.package_data
42
+
43
+ cmd.run()
44
+
45
+ # This makes sure the list of outputs includes byte-compiled
46
+ # files for Python modules but not for package data files
47
+ # (there shouldn't *be* byte-code files for those!).
48
+ assert len(cmd.get_outputs()) == 3
49
+ pkgdest = os.path.join(destination, "pkg")
50
+ files = os.listdir(pkgdest)
51
+ pycache_dir = os.path.join(pkgdest, "__pycache__")
52
+ assert "__init__.py" in files
53
+ assert "README.txt" in files
54
+ if sys.dont_write_bytecode:
55
+ assert not os.path.exists(pycache_dir)
56
+ else:
57
+ pyc_files = os.listdir(pycache_dir)
58
+ assert f"__init__.{sys.implementation.cache_tag}.pyc" in pyc_files
59
+
60
+ def test_empty_package_dir(self):
61
+ # See bugs #1668596/#1720897
62
+ sources = self.mkdtemp()
63
+ jaraco.path.build({'__init__.py': '', 'doc': {'testfile': ''}}, sources)
64
+
65
+ os.chdir(sources)
66
+ dist = Distribution({
67
+ "packages": ["pkg"],
68
+ "package_dir": {"pkg": ""},
69
+ "package_data": {"pkg": ["doc/*"]},
70
+ })
71
+ # script_name need not exist, it just need to be initialized
72
+ dist.script_name = os.path.join(sources, "setup.py")
73
+ dist.script_args = ["build"]
74
+ dist.parse_command_line()
75
+
76
+ try:
77
+ dist.run_commands()
78
+ except DistutilsFileError:
79
+ self.fail("failed package_data test when package_dir is ''")
80
+
81
+ @pytest.mark.skipif('sys.dont_write_bytecode')
82
+ def test_byte_compile(self):
83
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
84
+ os.chdir(project_dir)
85
+ self.write_file('boiledeggs.py', 'import antigravity')
86
+ cmd = build_py(dist)
87
+ cmd.compile = True
88
+ cmd.build_lib = 'here'
89
+ cmd.finalize_options()
90
+ cmd.run()
91
+
92
+ found = os.listdir(cmd.build_lib)
93
+ assert sorted(found) == ['__pycache__', 'boiledeggs.py']
94
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
95
+ assert found == [f'boiledeggs.{sys.implementation.cache_tag}.pyc']
96
+
97
+ @pytest.mark.skipif('sys.dont_write_bytecode')
98
+ def test_byte_compile_optimized(self):
99
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
100
+ os.chdir(project_dir)
101
+ self.write_file('boiledeggs.py', 'import antigravity')
102
+ cmd = build_py(dist)
103
+ cmd.compile = False
104
+ cmd.optimize = 1
105
+ cmd.build_lib = 'here'
106
+ cmd.finalize_options()
107
+ cmd.run()
108
+
109
+ found = os.listdir(cmd.build_lib)
110
+ assert sorted(found) == ['__pycache__', 'boiledeggs.py']
111
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
112
+ expect = f'boiledeggs.{sys.implementation.cache_tag}.opt-1.pyc'
113
+ assert sorted(found) == [expect]
114
+
115
+ def test_dir_in_package_data(self):
116
+ """
117
+ A directory in package_data should not be added to the filelist.
118
+ """
119
+ # See bug 19286
120
+ sources = self.mkdtemp()
121
+ jaraco.path.build(
122
+ {
123
+ 'pkg': {
124
+ '__init__.py': '',
125
+ 'doc': {
126
+ 'testfile': '',
127
+ # create a directory that could be incorrectly detected as a file
128
+ 'otherdir': {},
129
+ },
130
+ }
131
+ },
132
+ sources,
133
+ )
134
+
135
+ os.chdir(sources)
136
+ dist = Distribution({"packages": ["pkg"], "package_data": {"pkg": ["doc/*"]}})
137
+ # script_name need not exist, it just need to be initialized
138
+ dist.script_name = os.path.join(sources, "setup.py")
139
+ dist.script_args = ["build"]
140
+ dist.parse_command_line()
141
+
142
+ try:
143
+ dist.run_commands()
144
+ except DistutilsFileError:
145
+ self.fail("failed package_data when data dir includes a dir")
146
+
147
+ def test_dont_write_bytecode(self, caplog):
148
+ # makes sure byte_compile is not used
149
+ dist = self.create_dist()[1]
150
+ cmd = build_py(dist)
151
+ cmd.compile = True
152
+ cmd.optimize = 1
153
+
154
+ old_dont_write_bytecode = sys.dont_write_bytecode
155
+ sys.dont_write_bytecode = True
156
+ try:
157
+ cmd.byte_compile([])
158
+ finally:
159
+ sys.dont_write_bytecode = old_dont_write_bytecode
160
+
161
+ assert 'byte-compiling is disabled' in caplog.records[0].message
162
+
163
+ def test_namespace_package_does_not_warn(self, caplog):
164
+ """
165
+ Originally distutils implementation did not account for PEP 420
166
+ and included warns for package directories that did not contain
167
+ ``__init__.py`` files.
168
+ After the acceptance of PEP 420, these warnings don't make more sense
169
+ so we want to ensure there are not displayed to not confuse the users.
170
+ """
171
+ # Create a fake project structure with a package namespace:
172
+ tmp = self.mkdtemp()
173
+ jaraco.path.build({'ns': {'pkg': {'module.py': ''}}}, tmp)
174
+ os.chdir(tmp)
175
+
176
+ # Configure the package:
177
+ attrs = {
178
+ "name": "ns.pkg",
179
+ "packages": ["ns", "ns.pkg"],
180
+ "script_name": "setup.py",
181
+ }
182
+ dist = Distribution(attrs)
183
+
184
+ # Run code paths that would trigger the trap:
185
+ cmd = dist.get_command_obj("build_py")
186
+ cmd.finalize_options()
187
+ modules = cmd.find_all_modules()
188
+ assert len(modules) == 1
189
+ module_path = modules[0][-1]
190
+ assert module_path.replace(os.sep, "/") == "ns/pkg/module.py"
191
+
192
+ cmd.run()
193
+
194
+ assert not any(
195
+ "package init file" in msg and "not found" in msg for msg in caplog.messages
196
+ )
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_clean.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.clean."""
2
+
3
+ import os
4
+ from distutils.command.clean import clean
5
+ from distutils.tests import support
6
+
7
+
8
+ class TestClean(support.TempdirManager):
9
+ def test_simple_run(self):
10
+ pkg_dir, dist = self.create_dist()
11
+ cmd = clean(dist)
12
+
13
+ # let's add some elements clean should remove
14
+ dirs = [
15
+ (d, os.path.join(pkg_dir, d))
16
+ for d in (
17
+ 'build_temp',
18
+ 'build_lib',
19
+ 'bdist_base',
20
+ 'build_scripts',
21
+ 'build_base',
22
+ )
23
+ ]
24
+
25
+ for name, path in dirs:
26
+ os.mkdir(path)
27
+ setattr(cmd, name, path)
28
+ if name == 'build_base':
29
+ continue
30
+ for f in ('one', 'two', 'three'):
31
+ self.write_file(os.path.join(path, f))
32
+
33
+ # let's run the command
34
+ cmd.all = 1
35
+ cmd.ensure_finalized()
36
+ cmd.run()
37
+
38
+ # make sure the files where removed
39
+ for _name, path in dirs:
40
+ assert not os.path.exists(path), f'{path} was not removed'
41
+
42
+ # let's run the command again (should spit warnings but succeed)
43
+ cmd.all = 1
44
+ cmd.ensure_finalized()
45
+ cmd.run()
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_cmd.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.cmd."""
2
+
3
+ import os
4
+ from distutils import debug
5
+ from distutils.cmd import Command
6
+ from distutils.dist import Distribution
7
+ from distutils.errors import DistutilsOptionError
8
+
9
+ import pytest
10
+
11
+
12
+ class MyCmd(Command):
13
+ def initialize_options(self):
14
+ pass
15
+
16
+
17
+ @pytest.fixture
18
+ def cmd(request):
19
+ return MyCmd(Distribution())
20
+
21
+
22
+ class TestCommand:
23
+ def test_ensure_string_list(self, cmd):
24
+ cmd.not_string_list = ['one', 2, 'three']
25
+ cmd.yes_string_list = ['one', 'two', 'three']
26
+ cmd.not_string_list2 = object()
27
+ cmd.yes_string_list2 = 'ok'
28
+ cmd.ensure_string_list('yes_string_list')
29
+ cmd.ensure_string_list('yes_string_list2')
30
+
31
+ with pytest.raises(DistutilsOptionError):
32
+ cmd.ensure_string_list('not_string_list')
33
+
34
+ with pytest.raises(DistutilsOptionError):
35
+ cmd.ensure_string_list('not_string_list2')
36
+
37
+ cmd.option1 = 'ok,dok'
38
+ cmd.ensure_string_list('option1')
39
+ assert cmd.option1 == ['ok', 'dok']
40
+
41
+ cmd.option2 = ['xxx', 'www']
42
+ cmd.ensure_string_list('option2')
43
+
44
+ cmd.option3 = ['ok', 2]
45
+ with pytest.raises(DistutilsOptionError):
46
+ cmd.ensure_string_list('option3')
47
+
48
+ def test_make_file(self, cmd):
49
+ # making sure it raises when infiles is not a string or a list/tuple
50
+ with pytest.raises(TypeError):
51
+ cmd.make_file(infiles=True, outfile='', func='func', args=())
52
+
53
+ # making sure execute gets called properly
54
+ def _execute(func, args, exec_msg, level):
55
+ assert exec_msg == 'generating out from in'
56
+
57
+ cmd.force = True
58
+ cmd.execute = _execute
59
+ cmd.make_file(infiles='in', outfile='out', func='func', args=())
60
+
61
+ def test_dump_options(self, cmd):
62
+ msgs = []
63
+
64
+ def _announce(msg, level):
65
+ msgs.append(msg)
66
+
67
+ cmd.announce = _announce
68
+ cmd.option1 = 1
69
+ cmd.option2 = 1
70
+ cmd.user_options = [('option1', '', ''), ('option2', '', '')]
71
+ cmd.dump_options()
72
+
73
+ wanted = ["command options for 'MyCmd':", ' option1 = 1', ' option2 = 1']
74
+ assert msgs == wanted
75
+
76
+ def test_ensure_string(self, cmd):
77
+ cmd.option1 = 'ok'
78
+ cmd.ensure_string('option1')
79
+
80
+ cmd.option2 = None
81
+ cmd.ensure_string('option2', 'xxx')
82
+ assert hasattr(cmd, 'option2')
83
+
84
+ cmd.option3 = 1
85
+ with pytest.raises(DistutilsOptionError):
86
+ cmd.ensure_string('option3')
87
+
88
+ def test_ensure_filename(self, cmd):
89
+ cmd.option1 = __file__
90
+ cmd.ensure_filename('option1')
91
+ cmd.option2 = 'xxx'
92
+ with pytest.raises(DistutilsOptionError):
93
+ cmd.ensure_filename('option2')
94
+
95
+ def test_ensure_dirname(self, cmd):
96
+ cmd.option1 = os.path.dirname(__file__) or os.curdir
97
+ cmd.ensure_dirname('option1')
98
+ cmd.option2 = 'xxx'
99
+ with pytest.raises(DistutilsOptionError):
100
+ cmd.ensure_dirname('option2')
101
+
102
+ def test_debug_print(self, cmd, capsys, monkeypatch):
103
+ cmd.debug_print('xxx')
104
+ assert capsys.readouterr().out == ''
105
+ monkeypatch.setattr(debug, 'DEBUG', True)
106
+ cmd.debug_print('xxx')
107
+ assert capsys.readouterr().out == 'xxx\n'
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_config_cmd.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.config."""
2
+
3
+ import os
4
+ import sys
5
+ from distutils._log import log
6
+ from distutils.command.config import config, dump_file
7
+ from distutils.tests import missing_compiler_executable, support
8
+
9
+ import more_itertools
10
+ import path
11
+ import pytest
12
+
13
+
14
+ @pytest.fixture(autouse=True)
15
+ def info_log(request, monkeypatch):
16
+ self = request.instance
17
+ self._logs = []
18
+ monkeypatch.setattr(log, 'info', self._info)
19
+
20
+
21
+ @support.combine_markers
22
+ class TestConfig(support.TempdirManager):
23
+ def _info(self, msg, *args):
24
+ for line in msg.splitlines():
25
+ self._logs.append(line)
26
+
27
+ def test_dump_file(self):
28
+ this_file = path.Path(__file__).with_suffix('.py')
29
+ with this_file.open(encoding='utf-8') as f:
30
+ numlines = more_itertools.ilen(f)
31
+
32
+ dump_file(this_file, 'I am the header')
33
+ assert len(self._logs) == numlines + 1
34
+
35
+ @pytest.mark.skipif('platform.system() == "Windows"')
36
+ def test_search_cpp(self):
37
+ cmd = missing_compiler_executable(['preprocessor'])
38
+ if cmd is not None:
39
+ self.skipTest(f'The {cmd!r} command is not found')
40
+ pkg_dir, dist = self.create_dist()
41
+ cmd = config(dist)
42
+ cmd._check_compiler()
43
+ compiler = cmd.compiler
44
+ if sys.platform[:3] == "aix" and "xlc" in compiler.preprocessor[0].lower():
45
+ self.skipTest(
46
+ 'xlc: The -E option overrides the -P, -o, and -qsyntaxonly options'
47
+ )
48
+
49
+ # simple pattern searches
50
+ match = cmd.search_cpp(pattern='xxx', body='/* xxx */')
51
+ assert match == 0
52
+
53
+ match = cmd.search_cpp(pattern='_configtest', body='/* xxx */')
54
+ assert match == 1
55
+
56
+ def test_finalize_options(self):
57
+ # finalize_options does a bit of transformation
58
+ # on options
59
+ pkg_dir, dist = self.create_dist()
60
+ cmd = config(dist)
61
+ cmd.include_dirs = f'one{os.pathsep}two'
62
+ cmd.libraries = 'one'
63
+ cmd.library_dirs = f'three{os.pathsep}four'
64
+ cmd.ensure_finalized()
65
+
66
+ assert cmd.include_dirs == ['one', 'two']
67
+ assert cmd.libraries == ['one']
68
+ assert cmd.library_dirs == ['three', 'four']
69
+
70
+ def test_clean(self):
71
+ # _clean removes files
72
+ tmp_dir = self.mkdtemp()
73
+ f1 = os.path.join(tmp_dir, 'one')
74
+ f2 = os.path.join(tmp_dir, 'two')
75
+
76
+ self.write_file(f1, 'xxx')
77
+ self.write_file(f2, 'xxx')
78
+
79
+ for f in (f1, f2):
80
+ assert os.path.exists(f)
81
+
82
+ pkg_dir, dist = self.create_dist()
83
+ cmd = config(dist)
84
+ cmd._clean(f1, f2)
85
+
86
+ for f in (f1, f2):
87
+ assert not os.path.exists(f)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_core.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.core."""
2
+
3
+ import distutils.core
4
+ import io
5
+ import os
6
+ import sys
7
+ from distutils.dist import Distribution
8
+
9
+ import pytest
10
+
11
+ # setup script that uses __file__
12
+ setup_using___file__ = """\
13
+
14
+ __file__
15
+
16
+ from distutils.core import setup
17
+ setup()
18
+ """
19
+
20
+ setup_prints_cwd = """\
21
+
22
+ import os
23
+ print(os.getcwd())
24
+
25
+ from distutils.core import setup
26
+ setup()
27
+ """
28
+
29
+ setup_does_nothing = """\
30
+ from distutils.core import setup
31
+ setup()
32
+ """
33
+
34
+
35
+ setup_defines_subclass = """\
36
+ from distutils.core import setup
37
+ from distutils.command.install import install as _install
38
+
39
+ class install(_install):
40
+ sub_commands = _install.sub_commands + ['cmd']
41
+
42
+ setup(cmdclass={'install': install})
43
+ """
44
+
45
+ setup_within_if_main = """\
46
+ from distutils.core import setup
47
+
48
+ def main():
49
+ return setup(name="setup_within_if_main")
50
+
51
+ if __name__ == "__main__":
52
+ main()
53
+ """
54
+
55
+
56
+ @pytest.fixture(autouse=True)
57
+ def save_stdout(monkeypatch):
58
+ monkeypatch.setattr(sys, 'stdout', sys.stdout)
59
+
60
+
61
+ @pytest.fixture
62
+ def temp_file(tmp_path):
63
+ return tmp_path / 'file'
64
+
65
+
66
+ @pytest.mark.usefixtures('save_env')
67
+ @pytest.mark.usefixtures('save_argv')
68
+ class TestCore:
69
+ def test_run_setup_provides_file(self, temp_file):
70
+ # Make sure the script can use __file__; if that's missing, the test
71
+ # setup.py script will raise NameError.
72
+ temp_file.write_text(setup_using___file__, encoding='utf-8')
73
+ distutils.core.run_setup(temp_file)
74
+
75
+ def test_run_setup_preserves_sys_argv(self, temp_file):
76
+ # Make sure run_setup does not clobber sys.argv
77
+ argv_copy = sys.argv.copy()
78
+ temp_file.write_text(setup_does_nothing, encoding='utf-8')
79
+ distutils.core.run_setup(temp_file)
80
+ assert sys.argv == argv_copy
81
+
82
+ def test_run_setup_defines_subclass(self, temp_file):
83
+ # Make sure the script can use __file__; if that's missing, the test
84
+ # setup.py script will raise NameError.
85
+ temp_file.write_text(setup_defines_subclass, encoding='utf-8')
86
+ dist = distutils.core.run_setup(temp_file)
87
+ install = dist.get_command_obj('install')
88
+ assert 'cmd' in install.sub_commands
89
+
90
+ def test_run_setup_uses_current_dir(self, tmp_path):
91
+ """
92
+ Test that the setup script is run with the current directory
93
+ as its own current directory.
94
+ """
95
+ sys.stdout = io.StringIO()
96
+ cwd = os.getcwd()
97
+
98
+ # Create a directory and write the setup.py file there:
99
+ setup_py = tmp_path / 'setup.py'
100
+ setup_py.write_text(setup_prints_cwd, encoding='utf-8')
101
+ distutils.core.run_setup(setup_py)
102
+
103
+ output = sys.stdout.getvalue()
104
+ if output.endswith("\n"):
105
+ output = output[:-1]
106
+ assert cwd == output
107
+
108
+ def test_run_setup_within_if_main(self, temp_file):
109
+ temp_file.write_text(setup_within_if_main, encoding='utf-8')
110
+ dist = distutils.core.run_setup(temp_file, stop_after="config")
111
+ assert isinstance(dist, Distribution)
112
+ assert dist.get_name() == "setup_within_if_main"
113
+
114
+ def test_run_commands(self, temp_file):
115
+ sys.argv = ['setup.py', 'build']
116
+ temp_file.write_text(setup_within_if_main, encoding='utf-8')
117
+ dist = distutils.core.run_setup(temp_file, stop_after="commandline")
118
+ assert 'build' not in dist.have_run
119
+ distutils.core.run_commands(dist)
120
+ assert 'build' in dist.have_run
121
+
122
+ def test_debug_mode(self, capsys, monkeypatch):
123
+ # this covers the code called when DEBUG is set
124
+ sys.argv = ['setup.py', '--name']
125
+ distutils.core.setup(name='bar')
126
+ assert capsys.readouterr().out == 'bar\n'
127
+ monkeypatch.setattr(distutils.core, 'DEBUG', True)
128
+ distutils.core.setup(name='bar')
129
+ wanted = "options (after parsing config files):\n"
130
+ assert capsys.readouterr().out.startswith(wanted)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_dist.py ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.dist."""
2
+
3
+ import email
4
+ import email.generator
5
+ import email.policy
6
+ import functools
7
+ import io
8
+ import os
9
+ import sys
10
+ import textwrap
11
+ import unittest.mock as mock
12
+ import warnings
13
+ from distutils.cmd import Command
14
+ from distutils.dist import Distribution, fix_help_options
15
+ from distutils.tests import support
16
+ from typing import ClassVar
17
+
18
+ import jaraco.path
19
+ import pytest
20
+
21
+ pydistutils_cfg = '.' * (os.name == 'posix') + 'pydistutils.cfg'
22
+
23
+
24
+ class test_dist(Command):
25
+ """Sample distutils extension command."""
26
+
27
+ user_options: ClassVar[list[tuple[str, str, str]]] = [
28
+ ("sample-option=", "S", "help text"),
29
+ ]
30
+
31
+ def initialize_options(self):
32
+ self.sample_option = None
33
+
34
+
35
+ class TestDistribution(Distribution):
36
+ """Distribution subclasses that avoids the default search for
37
+ configuration files.
38
+
39
+ The ._config_files attribute must be set before
40
+ .parse_config_files() is called.
41
+ """
42
+
43
+ def find_config_files(self):
44
+ return self._config_files
45
+
46
+
47
+ @pytest.fixture
48
+ def clear_argv():
49
+ del sys.argv[1:]
50
+
51
+
52
+ @support.combine_markers
53
+ @pytest.mark.usefixtures('save_env')
54
+ @pytest.mark.usefixtures('save_argv')
55
+ class TestDistributionBehavior(support.TempdirManager):
56
+ def create_distribution(self, configfiles=()):
57
+ d = TestDistribution()
58
+ d._config_files = configfiles
59
+ d.parse_config_files()
60
+ d.parse_command_line()
61
+ return d
62
+
63
+ def test_command_packages_unspecified(self, clear_argv):
64
+ sys.argv.append("build")
65
+ d = self.create_distribution()
66
+ assert d.get_command_packages() == ["distutils.command"]
67
+
68
+ def test_command_packages_cmdline(self, clear_argv):
69
+ from distutils.tests.test_dist import test_dist
70
+
71
+ sys.argv.extend([
72
+ "--command-packages",
73
+ "foo.bar,distutils.tests",
74
+ "test_dist",
75
+ "-Ssometext",
76
+ ])
77
+ d = self.create_distribution()
78
+ # let's actually try to load our test command:
79
+ assert d.get_command_packages() == [
80
+ "distutils.command",
81
+ "foo.bar",
82
+ "distutils.tests",
83
+ ]
84
+ cmd = d.get_command_obj("test_dist")
85
+ assert isinstance(cmd, test_dist)
86
+ assert cmd.sample_option == "sometext"
87
+
88
+ @pytest.mark.skipif(
89
+ 'distutils' not in Distribution.parse_config_files.__module__,
90
+ reason='Cannot test when virtualenv has monkey-patched Distribution',
91
+ )
92
+ def test_venv_install_options(self, tmp_path, clear_argv):
93
+ sys.argv.append("install")
94
+ file = str(tmp_path / 'file')
95
+
96
+ fakepath = '/somedir'
97
+
98
+ jaraco.path.build({
99
+ file: f"""
100
+ [install]
101
+ install-base = {fakepath}
102
+ install-platbase = {fakepath}
103
+ install-lib = {fakepath}
104
+ install-platlib = {fakepath}
105
+ install-purelib = {fakepath}
106
+ install-headers = {fakepath}
107
+ install-scripts = {fakepath}
108
+ install-data = {fakepath}
109
+ prefix = {fakepath}
110
+ exec-prefix = {fakepath}
111
+ home = {fakepath}
112
+ user = {fakepath}
113
+ root = {fakepath}
114
+ """,
115
+ })
116
+
117
+ # Base case: Not in a Virtual Environment
118
+ with mock.patch.multiple(sys, prefix='/a', base_prefix='/a'):
119
+ d = self.create_distribution([file])
120
+
121
+ option_tuple = (file, fakepath)
122
+
123
+ result_dict = {
124
+ 'install_base': option_tuple,
125
+ 'install_platbase': option_tuple,
126
+ 'install_lib': option_tuple,
127
+ 'install_platlib': option_tuple,
128
+ 'install_purelib': option_tuple,
129
+ 'install_headers': option_tuple,
130
+ 'install_scripts': option_tuple,
131
+ 'install_data': option_tuple,
132
+ 'prefix': option_tuple,
133
+ 'exec_prefix': option_tuple,
134
+ 'home': option_tuple,
135
+ 'user': option_tuple,
136
+ 'root': option_tuple,
137
+ }
138
+
139
+ assert sorted(d.command_options.get('install').keys()) == sorted(
140
+ result_dict.keys()
141
+ )
142
+
143
+ for key, value in d.command_options.get('install').items():
144
+ assert value == result_dict[key]
145
+
146
+ # Test case: In a Virtual Environment
147
+ with mock.patch.multiple(sys, prefix='/a', base_prefix='/b'):
148
+ d = self.create_distribution([file])
149
+
150
+ for key in result_dict.keys():
151
+ assert key not in d.command_options.get('install', {})
152
+
153
+ def test_command_packages_configfile(self, tmp_path, clear_argv):
154
+ sys.argv.append("build")
155
+ file = str(tmp_path / "file")
156
+ jaraco.path.build({
157
+ file: """
158
+ [global]
159
+ command_packages = foo.bar, splat
160
+ """,
161
+ })
162
+
163
+ d = self.create_distribution([file])
164
+ assert d.get_command_packages() == ["distutils.command", "foo.bar", "splat"]
165
+
166
+ # ensure command line overrides config:
167
+ sys.argv[1:] = ["--command-packages", "spork", "build"]
168
+ d = self.create_distribution([file])
169
+ assert d.get_command_packages() == ["distutils.command", "spork"]
170
+
171
+ # Setting --command-packages to '' should cause the default to
172
+ # be used even if a config file specified something else:
173
+ sys.argv[1:] = ["--command-packages", "", "build"]
174
+ d = self.create_distribution([file])
175
+ assert d.get_command_packages() == ["distutils.command"]
176
+
177
+ def test_empty_options(self, request):
178
+ # an empty options dictionary should not stay in the
179
+ # list of attributes
180
+
181
+ # catching warnings
182
+ warns = []
183
+
184
+ def _warn(msg):
185
+ warns.append(msg)
186
+
187
+ request.addfinalizer(
188
+ functools.partial(setattr, warnings, 'warn', warnings.warn)
189
+ )
190
+ warnings.warn = _warn
191
+ dist = Distribution(
192
+ attrs={
193
+ 'author': 'xxx',
194
+ 'name': 'xxx',
195
+ 'version': 'xxx',
196
+ 'url': 'xxxx',
197
+ 'options': {},
198
+ }
199
+ )
200
+
201
+ assert len(warns) == 0
202
+ assert 'options' not in dir(dist)
203
+
204
+ def test_finalize_options(self):
205
+ attrs = {'keywords': 'one,two', 'platforms': 'one,two'}
206
+
207
+ dist = Distribution(attrs=attrs)
208
+ dist.finalize_options()
209
+
210
+ # finalize_option splits platforms and keywords
211
+ assert dist.metadata.platforms == ['one', 'two']
212
+ assert dist.metadata.keywords == ['one', 'two']
213
+
214
+ attrs = {'keywords': 'foo bar', 'platforms': 'foo bar'}
215
+ dist = Distribution(attrs=attrs)
216
+ dist.finalize_options()
217
+ assert dist.metadata.platforms == ['foo bar']
218
+ assert dist.metadata.keywords == ['foo bar']
219
+
220
+ def test_get_command_packages(self):
221
+ dist = Distribution()
222
+ assert dist.command_packages is None
223
+ cmds = dist.get_command_packages()
224
+ assert cmds == ['distutils.command']
225
+ assert dist.command_packages == ['distutils.command']
226
+
227
+ dist.command_packages = 'one,two'
228
+ cmds = dist.get_command_packages()
229
+ assert cmds == ['distutils.command', 'one', 'two']
230
+
231
+ def test_announce(self):
232
+ # make sure the level is known
233
+ dist = Distribution()
234
+ with pytest.raises(TypeError):
235
+ dist.announce('ok', level='ok2')
236
+
237
+ def test_find_config_files_disable(self, temp_home):
238
+ # Ticket #1180: Allow user to disable their home config file.
239
+ jaraco.path.build({pydistutils_cfg: '[distutils]\n'}, temp_home)
240
+
241
+ d = Distribution()
242
+ all_files = d.find_config_files()
243
+
244
+ d = Distribution(attrs={'script_args': ['--no-user-cfg']})
245
+ files = d.find_config_files()
246
+
247
+ # make sure --no-user-cfg disables the user cfg file
248
+ assert len(all_files) - 1 == len(files)
249
+
250
+ def test_script_args_list_coercion(self):
251
+ d = Distribution(attrs={'script_args': ('build', '--no-user-cfg')})
252
+
253
+ # make sure script_args is a list even if it started as a different iterable
254
+ assert d.script_args == ['build', '--no-user-cfg']
255
+
256
+ @pytest.mark.skipif(
257
+ 'platform.system() == "Windows"',
258
+ reason='Windows does not honor chmod 000',
259
+ )
260
+ def test_find_config_files_permission_error(self, fake_home):
261
+ """
262
+ Finding config files should not fail when directory is inaccessible.
263
+ """
264
+ fake_home.joinpath(pydistutils_cfg).write_text('', encoding='utf-8')
265
+ fake_home.chmod(0o000)
266
+ Distribution().find_config_files()
267
+
268
+
269
+ @pytest.mark.usefixtures('save_env')
270
+ @pytest.mark.usefixtures('save_argv')
271
+ class TestMetadata(support.TempdirManager):
272
+ def format_metadata(self, dist):
273
+ sio = io.StringIO()
274
+ dist.metadata.write_pkg_file(sio)
275
+ return sio.getvalue()
276
+
277
+ def test_simple_metadata(self):
278
+ attrs = {"name": "package", "version": "1.0"}
279
+ dist = Distribution(attrs)
280
+ meta = self.format_metadata(dist)
281
+ assert "Metadata-Version: 1.0" in meta
282
+ assert "provides:" not in meta.lower()
283
+ assert "requires:" not in meta.lower()
284
+ assert "obsoletes:" not in meta.lower()
285
+
286
+ def test_provides(self):
287
+ attrs = {
288
+ "name": "package",
289
+ "version": "1.0",
290
+ "provides": ["package", "package.sub"],
291
+ }
292
+ dist = Distribution(attrs)
293
+ assert dist.metadata.get_provides() == ["package", "package.sub"]
294
+ assert dist.get_provides() == ["package", "package.sub"]
295
+ meta = self.format_metadata(dist)
296
+ assert "Metadata-Version: 1.1" in meta
297
+ assert "requires:" not in meta.lower()
298
+ assert "obsoletes:" not in meta.lower()
299
+
300
+ def test_provides_illegal(self):
301
+ with pytest.raises(ValueError):
302
+ Distribution(
303
+ {"name": "package", "version": "1.0", "provides": ["my.pkg (splat)"]},
304
+ )
305
+
306
+ def test_requires(self):
307
+ attrs = {
308
+ "name": "package",
309
+ "version": "1.0",
310
+ "requires": ["other", "another (==1.0)"],
311
+ }
312
+ dist = Distribution(attrs)
313
+ assert dist.metadata.get_requires() == ["other", "another (==1.0)"]
314
+ assert dist.get_requires() == ["other", "another (==1.0)"]
315
+ meta = self.format_metadata(dist)
316
+ assert "Metadata-Version: 1.1" in meta
317
+ assert "provides:" not in meta.lower()
318
+ assert "Requires: other" in meta
319
+ assert "Requires: another (==1.0)" in meta
320
+ assert "obsoletes:" not in meta.lower()
321
+
322
+ def test_requires_illegal(self):
323
+ with pytest.raises(ValueError):
324
+ Distribution(
325
+ {"name": "package", "version": "1.0", "requires": ["my.pkg (splat)"]},
326
+ )
327
+
328
+ def test_requires_to_list(self):
329
+ attrs = {"name": "package", "requires": iter(["other"])}
330
+ dist = Distribution(attrs)
331
+ assert isinstance(dist.metadata.requires, list)
332
+
333
+ def test_obsoletes(self):
334
+ attrs = {
335
+ "name": "package",
336
+ "version": "1.0",
337
+ "obsoletes": ["other", "another (<1.0)"],
338
+ }
339
+ dist = Distribution(attrs)
340
+ assert dist.metadata.get_obsoletes() == ["other", "another (<1.0)"]
341
+ assert dist.get_obsoletes() == ["other", "another (<1.0)"]
342
+ meta = self.format_metadata(dist)
343
+ assert "Metadata-Version: 1.1" in meta
344
+ assert "provides:" not in meta.lower()
345
+ assert "requires:" not in meta.lower()
346
+ assert "Obsoletes: other" in meta
347
+ assert "Obsoletes: another (<1.0)" in meta
348
+
349
+ def test_obsoletes_illegal(self):
350
+ with pytest.raises(ValueError):
351
+ Distribution(
352
+ {"name": "package", "version": "1.0", "obsoletes": ["my.pkg (splat)"]},
353
+ )
354
+
355
+ def test_obsoletes_to_list(self):
356
+ attrs = {"name": "package", "obsoletes": iter(["other"])}
357
+ dist = Distribution(attrs)
358
+ assert isinstance(dist.metadata.obsoletes, list)
359
+
360
+ def test_classifier(self):
361
+ attrs = {
362
+ 'name': 'Boa',
363
+ 'version': '3.0',
364
+ 'classifiers': ['Programming Language :: Python :: 3'],
365
+ }
366
+ dist = Distribution(attrs)
367
+ assert dist.get_classifiers() == ['Programming Language :: Python :: 3']
368
+ meta = self.format_metadata(dist)
369
+ assert 'Metadata-Version: 1.1' in meta
370
+
371
+ def test_classifier_invalid_type(self, caplog):
372
+ attrs = {
373
+ 'name': 'Boa',
374
+ 'version': '3.0',
375
+ 'classifiers': ('Programming Language :: Python :: 3',),
376
+ }
377
+ d = Distribution(attrs)
378
+ # should have warning about passing a non-list
379
+ assert 'should be a list' in caplog.messages[0]
380
+ # should be converted to a list
381
+ assert isinstance(d.metadata.classifiers, list)
382
+ assert d.metadata.classifiers == list(attrs['classifiers'])
383
+
384
+ def test_keywords(self):
385
+ attrs = {
386
+ 'name': 'Monty',
387
+ 'version': '1.0',
388
+ 'keywords': ['spam', 'eggs', 'life of brian'],
389
+ }
390
+ dist = Distribution(attrs)
391
+ assert dist.get_keywords() == ['spam', 'eggs', 'life of brian']
392
+
393
+ def test_keywords_invalid_type(self, caplog):
394
+ attrs = {
395
+ 'name': 'Monty',
396
+ 'version': '1.0',
397
+ 'keywords': ('spam', 'eggs', 'life of brian'),
398
+ }
399
+ d = Distribution(attrs)
400
+ # should have warning about passing a non-list
401
+ assert 'should be a list' in caplog.messages[0]
402
+ # should be converted to a list
403
+ assert isinstance(d.metadata.keywords, list)
404
+ assert d.metadata.keywords == list(attrs['keywords'])
405
+
406
+ def test_platforms(self):
407
+ attrs = {
408
+ 'name': 'Monty',
409
+ 'version': '1.0',
410
+ 'platforms': ['GNU/Linux', 'Some Evil Platform'],
411
+ }
412
+ dist = Distribution(attrs)
413
+ assert dist.get_platforms() == ['GNU/Linux', 'Some Evil Platform']
414
+
415
+ def test_platforms_invalid_types(self, caplog):
416
+ attrs = {
417
+ 'name': 'Monty',
418
+ 'version': '1.0',
419
+ 'platforms': ('GNU/Linux', 'Some Evil Platform'),
420
+ }
421
+ d = Distribution(attrs)
422
+ # should have warning about passing a non-list
423
+ assert 'should be a list' in caplog.messages[0]
424
+ # should be converted to a list
425
+ assert isinstance(d.metadata.platforms, list)
426
+ assert d.metadata.platforms == list(attrs['platforms'])
427
+
428
+ def test_download_url(self):
429
+ attrs = {
430
+ 'name': 'Boa',
431
+ 'version': '3.0',
432
+ 'download_url': 'http://example.org/boa',
433
+ }
434
+ dist = Distribution(attrs)
435
+ meta = self.format_metadata(dist)
436
+ assert 'Metadata-Version: 1.1' in meta
437
+
438
+ def test_long_description(self):
439
+ long_desc = textwrap.dedent(
440
+ """\
441
+ example::
442
+ We start here
443
+ and continue here
444
+ and end here."""
445
+ )
446
+ attrs = {"name": "package", "version": "1.0", "long_description": long_desc}
447
+
448
+ dist = Distribution(attrs)
449
+ meta = self.format_metadata(dist)
450
+ meta = meta.replace('\n' + 8 * ' ', '\n')
451
+ assert long_desc in meta
452
+
453
+ def test_custom_pydistutils(self, temp_home):
454
+ """
455
+ pydistutils.cfg is found
456
+ """
457
+ jaraco.path.build({pydistutils_cfg: ''}, temp_home)
458
+ config_path = temp_home / pydistutils_cfg
459
+
460
+ assert str(config_path) in Distribution().find_config_files()
461
+
462
+ def test_extra_pydistutils(self, monkeypatch, tmp_path):
463
+ jaraco.path.build({'overrides.cfg': ''}, tmp_path)
464
+ filename = tmp_path / 'overrides.cfg'
465
+ monkeypatch.setenv('DIST_EXTRA_CONFIG', str(filename))
466
+ assert str(filename) in Distribution().find_config_files()
467
+
468
+ def test_fix_help_options(self):
469
+ help_tuples = [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
470
+ fancy_options = fix_help_options(help_tuples)
471
+ assert fancy_options[0] == ('a', 'b', 'c')
472
+ assert fancy_options[1] == (1, 2, 3)
473
+
474
+ def test_show_help(self, request, capsys):
475
+ # smoke test, just makes sure some help is displayed
476
+ dist = Distribution()
477
+ sys.argv = []
478
+ dist.help = True
479
+ dist.script_name = 'setup.py'
480
+ dist.parse_command_line()
481
+
482
+ output = [
483
+ line for line in capsys.readouterr().out.split('\n') if line.strip() != ''
484
+ ]
485
+ assert output
486
+
487
+ def test_read_metadata(self):
488
+ attrs = {
489
+ "name": "package",
490
+ "version": "1.0",
491
+ "long_description": "desc",
492
+ "description": "xxx",
493
+ "download_url": "http://example.com",
494
+ "keywords": ['one', 'two'],
495
+ "requires": ['foo'],
496
+ }
497
+
498
+ dist = Distribution(attrs)
499
+ metadata = dist.metadata
500
+
501
+ # write it then reloads it
502
+ PKG_INFO = io.StringIO()
503
+ metadata.write_pkg_file(PKG_INFO)
504
+ PKG_INFO.seek(0)
505
+ metadata.read_pkg_file(PKG_INFO)
506
+
507
+ assert metadata.name == "package"
508
+ assert metadata.version == "1.0"
509
+ assert metadata.description == "xxx"
510
+ assert metadata.download_url == 'http://example.com'
511
+ assert metadata.keywords == ['one', 'two']
512
+ assert metadata.platforms is None
513
+ assert metadata.obsoletes is None
514
+ assert metadata.requires == ['foo']
515
+
516
+ def test_round_trip_through_email_generator(self):
517
+ """
518
+ In pypa/setuptools#4033, it was shown that once PKG-INFO is
519
+ re-generated using ``email.generator.Generator``, some control
520
+ characters might cause problems.
521
+ """
522
+ # Given a PKG-INFO file ...
523
+ attrs = {
524
+ "name": "package",
525
+ "version": "1.0",
526
+ "long_description": "hello\x0b\nworld\n",
527
+ }
528
+ dist = Distribution(attrs)
529
+ metadata = dist.metadata
530
+
531
+ with io.StringIO() as buffer:
532
+ metadata.write_pkg_file(buffer)
533
+ msg = buffer.getvalue()
534
+
535
+ # ... when it is read and re-written using stdlib's email library,
536
+ orig = email.message_from_string(msg)
537
+ policy = email.policy.EmailPolicy(
538
+ utf8=True,
539
+ mangle_from_=False,
540
+ max_line_length=0,
541
+ )
542
+ with io.StringIO() as buffer:
543
+ email.generator.Generator(buffer, policy=policy).flatten(orig)
544
+
545
+ buffer.seek(0)
546
+ regen = email.message_from_file(buffer)
547
+
548
+ # ... then it should be the same as the original
549
+ # (except for the specific line break characters)
550
+ orig_desc = set(orig["Description"].splitlines())
551
+ regen_desc = set(regen["Description"].splitlines())
552
+ assert regen_desc == orig_desc
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_extension.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.extension."""
2
+
3
+ import os
4
+ import pathlib
5
+ import warnings
6
+ from distutils.extension import Extension, read_setup_file
7
+
8
+ import pytest
9
+ from test.support.warnings_helper import check_warnings
10
+
11
+
12
+ class TestExtension:
13
+ def test_read_setup_file(self):
14
+ # trying to read a Setup file
15
+ # (sample extracted from the PyGame project)
16
+ setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
17
+
18
+ exts = read_setup_file(setup)
19
+ names = [ext.name for ext in exts]
20
+ names.sort()
21
+
22
+ # here are the extensions read_setup_file should have created
23
+ # out of the file
24
+ wanted = [
25
+ '_arraysurfarray',
26
+ '_camera',
27
+ '_numericsndarray',
28
+ '_numericsurfarray',
29
+ 'base',
30
+ 'bufferproxy',
31
+ 'cdrom',
32
+ 'color',
33
+ 'constants',
34
+ 'display',
35
+ 'draw',
36
+ 'event',
37
+ 'fastevent',
38
+ 'font',
39
+ 'gfxdraw',
40
+ 'image',
41
+ 'imageext',
42
+ 'joystick',
43
+ 'key',
44
+ 'mask',
45
+ 'mixer',
46
+ 'mixer_music',
47
+ 'mouse',
48
+ 'movie',
49
+ 'overlay',
50
+ 'pixelarray',
51
+ 'pypm',
52
+ 'rect',
53
+ 'rwobject',
54
+ 'scrap',
55
+ 'surface',
56
+ 'surflock',
57
+ 'time',
58
+ 'transform',
59
+ ]
60
+
61
+ assert names == wanted
62
+
63
+ def test_extension_init(self):
64
+ # the first argument, which is the name, must be a string
65
+ with pytest.raises(TypeError):
66
+ Extension(1, [])
67
+ ext = Extension('name', [])
68
+ assert ext.name == 'name'
69
+
70
+ # the second argument, which is the list of files, must
71
+ # be an iterable of strings or PathLike objects, and not a string
72
+ with pytest.raises(TypeError):
73
+ Extension('name', 'file')
74
+ with pytest.raises(TypeError):
75
+ Extension('name', ['file', 1])
76
+ ext = Extension('name', ['file1', 'file2'])
77
+ assert ext.sources == ['file1', 'file2']
78
+ ext = Extension('name', [pathlib.Path('file1'), pathlib.Path('file2')])
79
+ assert ext.sources == ['file1', 'file2']
80
+
81
+ # any non-string iterable of strings or PathLike objects should work
82
+ ext = Extension('name', ('file1', 'file2')) # tuple
83
+ assert ext.sources == ['file1', 'file2']
84
+ ext = Extension('name', {'file1', 'file2'}) # set
85
+ assert sorted(ext.sources) == ['file1', 'file2']
86
+ ext = Extension('name', iter(['file1', 'file2'])) # iterator
87
+ assert ext.sources == ['file1', 'file2']
88
+ ext = Extension('name', [pathlib.Path('file1'), 'file2']) # mixed types
89
+ assert ext.sources == ['file1', 'file2']
90
+
91
+ # others arguments have defaults
92
+ for attr in (
93
+ 'include_dirs',
94
+ 'define_macros',
95
+ 'undef_macros',
96
+ 'library_dirs',
97
+ 'libraries',
98
+ 'runtime_library_dirs',
99
+ 'extra_objects',
100
+ 'extra_compile_args',
101
+ 'extra_link_args',
102
+ 'export_symbols',
103
+ 'swig_opts',
104
+ 'depends',
105
+ ):
106
+ assert getattr(ext, attr) == []
107
+
108
+ assert ext.language is None
109
+ assert ext.optional is None
110
+
111
+ # if there are unknown keyword options, warn about them
112
+ with check_warnings() as w:
113
+ warnings.simplefilter('always')
114
+ ext = Extension('name', ['file1', 'file2'], chic=True)
115
+
116
+ assert len(w.warnings) == 1
117
+ assert str(w.warnings[0].message) == "Unknown Extension options: 'chic'"
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_file_util.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.file_util."""
2
+
3
+ import errno
4
+ import os
5
+ import unittest.mock as mock
6
+ from distutils.errors import DistutilsFileError
7
+ from distutils.file_util import copy_file, move_file
8
+
9
+ import jaraco.path
10
+ import pytest
11
+
12
+
13
+ @pytest.fixture(autouse=True)
14
+ def stuff(request, tmp_path):
15
+ self = request.instance
16
+ self.source = tmp_path / 'f1'
17
+ self.target = tmp_path / 'f2'
18
+ self.target_dir = tmp_path / 'd1'
19
+
20
+
21
+ class TestFileUtil:
22
+ def test_move_file_verbosity(self, caplog):
23
+ jaraco.path.build({self.source: 'some content'})
24
+
25
+ move_file(self.source, self.target, verbose=False)
26
+ assert not caplog.messages
27
+
28
+ # back to original state
29
+ move_file(self.target, self.source, verbose=False)
30
+
31
+ move_file(self.source, self.target, verbose=True)
32
+ wanted = [f'moving {self.source} -> {self.target}']
33
+ assert caplog.messages == wanted
34
+
35
+ # back to original state
36
+ move_file(self.target, self.source, verbose=False)
37
+
38
+ caplog.clear()
39
+ # now the target is a dir
40
+ os.mkdir(self.target_dir)
41
+ move_file(self.source, self.target_dir, verbose=True)
42
+ wanted = [f'moving {self.source} -> {self.target_dir}']
43
+ assert caplog.messages == wanted
44
+
45
+ def test_move_file_exception_unpacking_rename(self):
46
+ # see issue 22182
47
+ with (
48
+ mock.patch("os.rename", side_effect=OSError("wrong", 1)),
49
+ pytest.raises(DistutilsFileError),
50
+ ):
51
+ jaraco.path.build({self.source: 'spam eggs'})
52
+ move_file(self.source, self.target, verbose=False)
53
+
54
+ def test_move_file_exception_unpacking_unlink(self):
55
+ # see issue 22182
56
+ with (
57
+ mock.patch("os.rename", side_effect=OSError(errno.EXDEV, "wrong")),
58
+ mock.patch("os.unlink", side_effect=OSError("wrong", 1)),
59
+ pytest.raises(DistutilsFileError),
60
+ ):
61
+ jaraco.path.build({self.source: 'spam eggs'})
62
+ move_file(self.source, self.target, verbose=False)
63
+
64
+ def test_copy_file_hard_link(self):
65
+ jaraco.path.build({self.source: 'some content'})
66
+ # Check first that copy_file() will not fall back on copying the file
67
+ # instead of creating the hard link.
68
+ try:
69
+ os.link(self.source, self.target)
70
+ except OSError as e:
71
+ self.skipTest(f'os.link: {e}')
72
+ else:
73
+ self.target.unlink()
74
+ st = os.stat(self.source)
75
+ copy_file(self.source, self.target, link='hard')
76
+ st2 = os.stat(self.source)
77
+ st3 = os.stat(self.target)
78
+ assert os.path.samestat(st, st2), (st, st2)
79
+ assert os.path.samestat(st2, st3), (st2, st3)
80
+ assert self.source.read_text(encoding='utf-8') == 'some content'
81
+
82
+ def test_copy_file_hard_link_failure(self):
83
+ # If hard linking fails, copy_file() falls back on copying file
84
+ # (some special filesystems don't support hard linking even under
85
+ # Unix, see issue #8876).
86
+ jaraco.path.build({self.source: 'some content'})
87
+ st = os.stat(self.source)
88
+ with mock.patch("os.link", side_effect=OSError(0, "linking unsupported")):
89
+ copy_file(self.source, self.target, link='hard')
90
+ st2 = os.stat(self.source)
91
+ st3 = os.stat(self.target)
92
+ assert os.path.samestat(st, st2), (st, st2)
93
+ assert not os.path.samestat(st2, st3), (st2, st3)
94
+ for fn in (self.source, self.target):
95
+ assert fn.read_text(encoding='utf-8') == 'some content'
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_install_data.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.command.install_data."""
2
+
3
+ import os
4
+ import pathlib
5
+ from distutils.command.install_data import install_data
6
+ from distutils.tests import support
7
+
8
+ import pytest
9
+
10
+
11
+ @pytest.mark.usefixtures('save_env')
12
+ class TestInstallData(
13
+ support.TempdirManager,
14
+ ):
15
+ def test_simple_run(self):
16
+ pkg_dir, dist = self.create_dist()
17
+ cmd = install_data(dist)
18
+ cmd.install_dir = inst = os.path.join(pkg_dir, 'inst')
19
+
20
+ # data_files can contain
21
+ # - simple files
22
+ # - a Path object
23
+ # - a tuple with a path, and a list of file
24
+ one = os.path.join(pkg_dir, 'one')
25
+ self.write_file(one, 'xxx')
26
+ inst2 = os.path.join(pkg_dir, 'inst2')
27
+ two = os.path.join(pkg_dir, 'two')
28
+ self.write_file(two, 'xxx')
29
+ three = pathlib.Path(pkg_dir) / 'three'
30
+ self.write_file(three, 'xxx')
31
+
32
+ cmd.data_files = [one, (inst2, [two]), three]
33
+ assert cmd.get_inputs() == [one, (inst2, [two]), three]
34
+
35
+ # let's run the command
36
+ cmd.ensure_finalized()
37
+ cmd.run()
38
+
39
+ # let's check the result
40
+ assert len(cmd.get_outputs()) == 3
41
+ rthree = os.path.split(one)[-1]
42
+ assert os.path.exists(os.path.join(inst, rthree))
43
+ rtwo = os.path.split(two)[-1]
44
+ assert os.path.exists(os.path.join(inst2, rtwo))
45
+ rone = os.path.split(one)[-1]
46
+ assert os.path.exists(os.path.join(inst, rone))
47
+ cmd.outfiles = []
48
+
49
+ # let's try with warn_dir one
50
+ cmd.warn_dir = True
51
+ cmd.ensure_finalized()
52
+ cmd.run()
53
+
54
+ # let's check the result
55
+ assert len(cmd.get_outputs()) == 3
56
+ assert os.path.exists(os.path.join(inst, rthree))
57
+ assert os.path.exists(os.path.join(inst2, rtwo))
58
+ assert os.path.exists(os.path.join(inst, rone))
59
+ cmd.outfiles = []
60
+
61
+ # now using root and empty dir
62
+ cmd.root = os.path.join(pkg_dir, 'root')
63
+ inst5 = os.path.join(pkg_dir, 'inst5')
64
+ four = os.path.join(cmd.install_dir, 'four')
65
+ self.write_file(four, 'xx')
66
+ cmd.data_files = [one, (inst2, [two]), three, ('inst5', [four]), (inst5, [])]
67
+ cmd.ensure_finalized()
68
+ cmd.run()
69
+
70
+ # let's check the result
71
+ assert len(cmd.get_outputs()) == 5
72
+ assert os.path.exists(os.path.join(inst, rthree))
73
+ assert os.path.exists(os.path.join(inst2, rtwo))
74
+ assert os.path.exists(os.path.join(inst, rone))
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_log.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.log"""
2
+
3
+ import logging
4
+ from distutils._log import log
5
+
6
+
7
+ class TestLog:
8
+ def test_non_ascii(self, caplog):
9
+ caplog.set_level(logging.DEBUG)
10
+ log.debug('Dεbug\tMėssãge')
11
+ log.fatal('Fαtal\tÈrrōr')
12
+ assert caplog.messages == ['Dεbug\tMėssãge', 'Fαtal\tÈrrōr']
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_modified.py ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils._modified."""
2
+
3
+ import os
4
+ import types
5
+ from distutils._modified import newer, newer_group, newer_pairwise, newer_pairwise_group
6
+ from distutils.errors import DistutilsFileError
7
+ from distutils.tests import support
8
+
9
+ import pytest
10
+
11
+
12
+ class TestDepUtil(support.TempdirManager):
13
+ def test_newer(self):
14
+ tmpdir = self.mkdtemp()
15
+ new_file = os.path.join(tmpdir, 'new')
16
+ old_file = os.path.abspath(__file__)
17
+
18
+ # Raise DistutilsFileError if 'new_file' does not exist.
19
+ with pytest.raises(DistutilsFileError):
20
+ newer(new_file, old_file)
21
+
22
+ # Return true if 'new_file' exists and is more recently modified than
23
+ # 'old_file', or if 'new_file' exists and 'old_file' doesn't.
24
+ self.write_file(new_file)
25
+ assert newer(new_file, 'I_dont_exist')
26
+ assert newer(new_file, old_file)
27
+
28
+ # Return false if both exist and 'old_file' is the same age or younger
29
+ # than 'new_file'.
30
+ assert not newer(old_file, new_file)
31
+
32
+ def _setup_1234(self):
33
+ tmpdir = self.mkdtemp()
34
+ sources = os.path.join(tmpdir, 'sources')
35
+ targets = os.path.join(tmpdir, 'targets')
36
+ os.mkdir(sources)
37
+ os.mkdir(targets)
38
+ one = os.path.join(sources, 'one')
39
+ two = os.path.join(sources, 'two')
40
+ three = os.path.abspath(__file__) # I am the old file
41
+ four = os.path.join(targets, 'four')
42
+ self.write_file(one)
43
+ self.write_file(two)
44
+ self.write_file(four)
45
+ return one, two, three, four
46
+
47
+ def test_newer_pairwise(self):
48
+ one, two, three, four = self._setup_1234()
49
+
50
+ assert newer_pairwise([one, two], [three, four]) == ([one], [three])
51
+
52
+ def test_newer_pairwise_mismatch(self):
53
+ one, two, three, four = self._setup_1234()
54
+
55
+ with pytest.raises(ValueError):
56
+ newer_pairwise([one], [three, four])
57
+
58
+ with pytest.raises(ValueError):
59
+ newer_pairwise([one, two], [three])
60
+
61
+ def test_newer_pairwise_empty(self):
62
+ assert newer_pairwise([], []) == ([], [])
63
+
64
+ def test_newer_pairwise_fresh(self):
65
+ one, two, three, four = self._setup_1234()
66
+
67
+ assert newer_pairwise([one, three], [two, four]) == ([], [])
68
+
69
+ def test_newer_group(self):
70
+ tmpdir = self.mkdtemp()
71
+ sources = os.path.join(tmpdir, 'sources')
72
+ os.mkdir(sources)
73
+ one = os.path.join(sources, 'one')
74
+ two = os.path.join(sources, 'two')
75
+ three = os.path.join(sources, 'three')
76
+ old_file = os.path.abspath(__file__)
77
+
78
+ # return true if 'old_file' is out-of-date with respect to any file
79
+ # listed in 'sources'.
80
+ self.write_file(one)
81
+ self.write_file(two)
82
+ self.write_file(three)
83
+ assert newer_group([one, two, three], old_file)
84
+ assert not newer_group([one, two, old_file], three)
85
+
86
+ # missing handling
87
+ os.remove(one)
88
+ with pytest.raises(OSError):
89
+ newer_group([one, two, old_file], three)
90
+
91
+ assert not newer_group([one, two, old_file], three, missing='ignore')
92
+
93
+ assert newer_group([one, two, old_file], three, missing='newer')
94
+
95
+
96
+ @pytest.fixture
97
+ def groups_target(tmp_path):
98
+ """
99
+ Set up some older sources, a target, and newer sources.
100
+
101
+ Returns a simple namespace with these values.
102
+ """
103
+ filenames = ['older.c', 'older.h', 'target.o', 'newer.c', 'newer.h']
104
+ paths = [tmp_path / name for name in filenames]
105
+
106
+ for mtime, path in enumerate(paths):
107
+ path.write_text('', encoding='utf-8')
108
+
109
+ # make sure modification times are sequential
110
+ os.utime(path, (mtime, mtime))
111
+
112
+ return types.SimpleNamespace(older=paths[:2], target=paths[2], newer=paths[3:])
113
+
114
+
115
+ def test_newer_pairwise_group(groups_target):
116
+ older = newer_pairwise_group([groups_target.older], [groups_target.target])
117
+ newer = newer_pairwise_group([groups_target.newer], [groups_target.target])
118
+ assert older == ([], [])
119
+ assert newer == ([groups_target.newer], [groups_target.target])
120
+
121
+
122
+ def test_newer_group_no_sources_no_target(tmp_path):
123
+ """
124
+ Consider no sources and no target "newer".
125
+ """
126
+ assert newer_group([], str(tmp_path / 'does-not-exist'))
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_spawn.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.spawn."""
2
+
3
+ import os
4
+ import stat
5
+ import sys
6
+ import unittest.mock as mock
7
+ from distutils.errors import DistutilsExecError
8
+ from distutils.spawn import find_executable, spawn
9
+ from distutils.tests import support
10
+
11
+ import path
12
+ import pytest
13
+ from test.support import unix_shell
14
+
15
+ from .compat import py39 as os_helper
16
+
17
+
18
+ class TestSpawn(support.TempdirManager):
19
+ @pytest.mark.skipif("os.name not in ('nt', 'posix')")
20
+ def test_spawn(self):
21
+ tmpdir = self.mkdtemp()
22
+
23
+ # creating something executable
24
+ # through the shell that returns 1
25
+ if sys.platform != 'win32':
26
+ exe = os.path.join(tmpdir, 'foo.sh')
27
+ self.write_file(exe, f'#!{unix_shell}\nexit 1')
28
+ else:
29
+ exe = os.path.join(tmpdir, 'foo.bat')
30
+ self.write_file(exe, 'exit 1')
31
+
32
+ os.chmod(exe, 0o777)
33
+ with pytest.raises(DistutilsExecError):
34
+ spawn([exe])
35
+
36
+ # now something that works
37
+ if sys.platform != 'win32':
38
+ exe = os.path.join(tmpdir, 'foo.sh')
39
+ self.write_file(exe, f'#!{unix_shell}\nexit 0')
40
+ else:
41
+ exe = os.path.join(tmpdir, 'foo.bat')
42
+ self.write_file(exe, 'exit 0')
43
+
44
+ os.chmod(exe, 0o777)
45
+ spawn([exe]) # should work without any error
46
+
47
+ def test_find_executable(self, tmp_path):
48
+ program_path = self._make_executable(tmp_path, '.exe')
49
+ program = program_path.name
50
+ program_noeext = program_path.with_suffix('').name
51
+ filename = str(program_path)
52
+ tmp_dir = path.Path(tmp_path)
53
+
54
+ # test path parameter
55
+ rv = find_executable(program, path=tmp_dir)
56
+ assert rv == filename
57
+
58
+ if sys.platform == 'win32':
59
+ # test without ".exe" extension
60
+ rv = find_executable(program_noeext, path=tmp_dir)
61
+ assert rv == filename
62
+
63
+ # test find in the current directory
64
+ with tmp_dir:
65
+ rv = find_executable(program)
66
+ assert rv == program
67
+
68
+ # test non-existent program
69
+ dont_exist_program = "dontexist_" + program
70
+ rv = find_executable(dont_exist_program, path=tmp_dir)
71
+ assert rv is None
72
+
73
+ # PATH='': no match, except in the current directory
74
+ with os_helper.EnvironmentVarGuard() as env:
75
+ env['PATH'] = ''
76
+ with (
77
+ mock.patch(
78
+ 'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
79
+ ),
80
+ mock.patch('distutils.spawn.os.defpath', tmp_dir),
81
+ ):
82
+ rv = find_executable(program)
83
+ assert rv is None
84
+
85
+ # look in current directory
86
+ with tmp_dir:
87
+ rv = find_executable(program)
88
+ assert rv == program
89
+
90
+ # PATH=':': explicitly looks in the current directory
91
+ with os_helper.EnvironmentVarGuard() as env:
92
+ env['PATH'] = os.pathsep
93
+ with (
94
+ mock.patch('distutils.spawn.os.confstr', return_value='', create=True),
95
+ mock.patch('distutils.spawn.os.defpath', ''),
96
+ ):
97
+ rv = find_executable(program)
98
+ assert rv is None
99
+
100
+ # look in current directory
101
+ with tmp_dir:
102
+ rv = find_executable(program)
103
+ assert rv == program
104
+
105
+ # missing PATH: test os.confstr("CS_PATH") and os.defpath
106
+ with os_helper.EnvironmentVarGuard() as env:
107
+ env.pop('PATH', None)
108
+
109
+ # without confstr
110
+ with (
111
+ mock.patch(
112
+ 'distutils.spawn.os.confstr', side_effect=ValueError, create=True
113
+ ),
114
+ mock.patch('distutils.spawn.os.defpath', tmp_dir),
115
+ ):
116
+ rv = find_executable(program)
117
+ assert rv == filename
118
+
119
+ # with confstr
120
+ with (
121
+ mock.patch(
122
+ 'distutils.spawn.os.confstr', return_value=tmp_dir, create=True
123
+ ),
124
+ mock.patch('distutils.spawn.os.defpath', ''),
125
+ ):
126
+ rv = find_executable(program)
127
+ assert rv == filename
128
+
129
+ @staticmethod
130
+ def _make_executable(tmp_path, ext):
131
+ # Give the temporary program a suffix regardless of platform.
132
+ # It's needed on Windows and not harmful on others.
133
+ program = tmp_path.joinpath('program').with_suffix(ext)
134
+ program.write_text("", encoding='utf-8')
135
+ program.chmod(stat.S_IXUSR)
136
+ return program
137
+
138
+ def test_spawn_missing_exe(self):
139
+ with pytest.raises(DistutilsExecError) as ctx:
140
+ spawn(['does-not-exist'])
141
+ assert "command 'does-not-exist' failed" in str(ctx.value)
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_sysconfig.py ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.sysconfig."""
2
+
3
+ import contextlib
4
+ import distutils
5
+ import os
6
+ import pathlib
7
+ import subprocess
8
+ import sys
9
+ from distutils import sysconfig
10
+ from distutils.ccompiler import new_compiler # noqa: F401
11
+ from distutils.unixccompiler import UnixCCompiler
12
+
13
+ import jaraco.envs
14
+ import path
15
+ import pytest
16
+ from jaraco.text import trim
17
+ from test.support import swap_item
18
+
19
+
20
+ def _gen_makefile(root, contents):
21
+ jaraco.path.build({'Makefile': trim(contents)}, root)
22
+ return root / 'Makefile'
23
+
24
+
25
+ @pytest.mark.usefixtures('save_env')
26
+ class TestSysconfig:
27
+ def test_get_config_h_filename(self):
28
+ config_h = sysconfig.get_config_h_filename()
29
+ assert os.path.isfile(config_h)
30
+
31
+ @pytest.mark.skipif("platform.system() == 'Windows'")
32
+ @pytest.mark.skipif("sys.implementation.name != 'cpython'")
33
+ def test_get_makefile_filename(self):
34
+ makefile = sysconfig.get_makefile_filename()
35
+ assert os.path.isfile(makefile)
36
+
37
+ def test_get_python_lib(self, tmp_path):
38
+ assert sysconfig.get_python_lib() != sysconfig.get_python_lib(prefix=tmp_path)
39
+
40
+ def test_get_config_vars(self):
41
+ cvars = sysconfig.get_config_vars()
42
+ assert isinstance(cvars, dict)
43
+ assert cvars
44
+
45
+ @pytest.mark.skipif('sysconfig.IS_PYPY')
46
+ @pytest.mark.skipif('sysconfig.python_build')
47
+ @pytest.mark.xfail('platform.system() == "Windows"')
48
+ def test_srcdir_simple(self):
49
+ # See #15364.
50
+ srcdir = pathlib.Path(sysconfig.get_config_var('srcdir'))
51
+
52
+ assert srcdir.absolute()
53
+ assert srcdir.is_dir()
54
+
55
+ makefile = pathlib.Path(sysconfig.get_makefile_filename())
56
+ assert makefile.parent.samefile(srcdir)
57
+
58
+ @pytest.mark.skipif('sysconfig.IS_PYPY')
59
+ @pytest.mark.skipif('not sysconfig.python_build')
60
+ def test_srcdir_python_build(self):
61
+ # See #15364.
62
+ srcdir = pathlib.Path(sysconfig.get_config_var('srcdir'))
63
+
64
+ # The python executable has not been installed so srcdir
65
+ # should be a full source checkout.
66
+ Python_h = srcdir.joinpath('Include', 'Python.h')
67
+ assert Python_h.is_file()
68
+ assert sysconfig._is_python_source_dir(srcdir)
69
+ assert sysconfig._is_python_source_dir(str(srcdir))
70
+
71
+ def test_srcdir_independent_of_cwd(self):
72
+ """
73
+ srcdir should be independent of the current working directory
74
+ """
75
+ # See #15364.
76
+ srcdir = sysconfig.get_config_var('srcdir')
77
+ with path.Path('..'):
78
+ srcdir2 = sysconfig.get_config_var('srcdir')
79
+ assert srcdir == srcdir2
80
+
81
+ def customize_compiler(self):
82
+ # make sure AR gets caught
83
+ class compiler:
84
+ compiler_type = 'unix'
85
+ executables = UnixCCompiler.executables
86
+
87
+ def __init__(self):
88
+ self.exes = {}
89
+
90
+ def set_executables(self, **kw):
91
+ for k, v in kw.items():
92
+ self.exes[k] = v
93
+
94
+ sysconfig_vars = {
95
+ 'AR': 'sc_ar',
96
+ 'CC': 'sc_cc',
97
+ 'CXX': 'sc_cxx',
98
+ 'ARFLAGS': '--sc-arflags',
99
+ 'CFLAGS': '--sc-cflags',
100
+ 'CCSHARED': '--sc-ccshared',
101
+ 'LDSHARED': 'sc_ldshared',
102
+ 'SHLIB_SUFFIX': 'sc_shutil_suffix',
103
+ }
104
+
105
+ comp = compiler()
106
+ with contextlib.ExitStack() as cm:
107
+ for key, value in sysconfig_vars.items():
108
+ cm.enter_context(swap_item(sysconfig._config_vars, key, value))
109
+ sysconfig.customize_compiler(comp)
110
+
111
+ return comp
112
+
113
+ @pytest.mark.skipif("not isinstance(new_compiler(), UnixCCompiler)")
114
+ @pytest.mark.usefixtures('disable_macos_customization')
115
+ def test_customize_compiler(self):
116
+ # Make sure that sysconfig._config_vars is initialized
117
+ sysconfig.get_config_vars()
118
+
119
+ os.environ['AR'] = 'env_ar'
120
+ os.environ['CC'] = 'env_cc'
121
+ os.environ['CPP'] = 'env_cpp'
122
+ os.environ['CXX'] = 'env_cxx --env-cxx-flags'
123
+ os.environ['LDSHARED'] = 'env_ldshared'
124
+ os.environ['LDFLAGS'] = '--env-ldflags'
125
+ os.environ['ARFLAGS'] = '--env-arflags'
126
+ os.environ['CFLAGS'] = '--env-cflags'
127
+ os.environ['CPPFLAGS'] = '--env-cppflags'
128
+ os.environ['RANLIB'] = 'env_ranlib'
129
+
130
+ comp = self.customize_compiler()
131
+ assert comp.exes['archiver'] == 'env_ar --env-arflags'
132
+ assert comp.exes['preprocessor'] == 'env_cpp --env-cppflags'
133
+ assert comp.exes['compiler'] == 'env_cc --env-cflags --env-cppflags'
134
+ assert comp.exes['compiler_so'] == (
135
+ 'env_cc --env-cflags --env-cppflags --sc-ccshared'
136
+ )
137
+ assert (
138
+ comp.exes['compiler_cxx']
139
+ == 'env_cxx --env-cxx-flags --sc-cflags --env-cppflags'
140
+ )
141
+ assert comp.exes['linker_exe'] == 'env_cc'
142
+ assert comp.exes['linker_so'] == (
143
+ 'env_ldshared --env-ldflags --env-cflags --env-cppflags'
144
+ )
145
+ assert comp.shared_lib_extension == 'sc_shutil_suffix'
146
+
147
+ if sys.platform == "darwin":
148
+ assert comp.exes['ranlib'] == 'env_ranlib'
149
+ else:
150
+ assert 'ranlib' not in comp.exes
151
+
152
+ del os.environ['AR']
153
+ del os.environ['CC']
154
+ del os.environ['CPP']
155
+ del os.environ['CXX']
156
+ del os.environ['LDSHARED']
157
+ del os.environ['LDFLAGS']
158
+ del os.environ['ARFLAGS']
159
+ del os.environ['CFLAGS']
160
+ del os.environ['CPPFLAGS']
161
+ del os.environ['RANLIB']
162
+
163
+ comp = self.customize_compiler()
164
+ assert comp.exes['archiver'] == 'sc_ar --sc-arflags'
165
+ assert comp.exes['preprocessor'] == 'sc_cc -E'
166
+ assert comp.exes['compiler'] == 'sc_cc --sc-cflags'
167
+ assert comp.exes['compiler_so'] == 'sc_cc --sc-cflags --sc-ccshared'
168
+ assert comp.exes['compiler_cxx'] == 'sc_cxx --sc-cflags'
169
+ assert comp.exes['linker_exe'] == 'sc_cc'
170
+ assert comp.exes['linker_so'] == 'sc_ldshared'
171
+ assert comp.shared_lib_extension == 'sc_shutil_suffix'
172
+ assert 'ranlib' not in comp.exes
173
+
174
+ def test_parse_makefile_base(self, tmp_path):
175
+ makefile = _gen_makefile(
176
+ tmp_path,
177
+ """
178
+ CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'
179
+ VAR=$OTHER
180
+ OTHER=foo
181
+ """,
182
+ )
183
+ d = sysconfig.parse_makefile(makefile)
184
+ assert d == {'CONFIG_ARGS': "'--arg1=optarg1' 'ENV=LIB'", 'OTHER': 'foo'}
185
+
186
+ def test_parse_makefile_literal_dollar(self, tmp_path):
187
+ makefile = _gen_makefile(
188
+ tmp_path,
189
+ """
190
+ CONFIG_ARGS= '--arg1=optarg1' 'ENV=\\$$LIB'
191
+ VAR=$OTHER
192
+ OTHER=foo
193
+ """,
194
+ )
195
+ d = sysconfig.parse_makefile(makefile)
196
+ assert d == {'CONFIG_ARGS': r"'--arg1=optarg1' 'ENV=\$LIB'", 'OTHER': 'foo'}
197
+
198
+ def test_sysconfig_module(self):
199
+ import sysconfig as global_sysconfig
200
+
201
+ assert global_sysconfig.get_config_var('CFLAGS') == sysconfig.get_config_var(
202
+ 'CFLAGS'
203
+ )
204
+ assert global_sysconfig.get_config_var('LDFLAGS') == sysconfig.get_config_var(
205
+ 'LDFLAGS'
206
+ )
207
+
208
+ # On macOS, binary installers support extension module building on
209
+ # various levels of the operating system with differing Xcode
210
+ # configurations, requiring customization of some of the
211
+ # compiler configuration directives to suit the environment on
212
+ # the installed machine. Some of these customizations may require
213
+ # running external programs and are thus deferred until needed by
214
+ # the first extension module build. Only
215
+ # the Distutils version of sysconfig is used for extension module
216
+ # builds, which happens earlier in the Distutils tests. This may
217
+ # cause the following tests to fail since no tests have caused
218
+ # the global version of sysconfig to call the customization yet.
219
+ # The solution for now is to simply skip this test in this case.
220
+ # The longer-term solution is to only have one version of sysconfig.
221
+ @pytest.mark.skipif("sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER')")
222
+ def test_sysconfig_compiler_vars(self):
223
+ import sysconfig as global_sysconfig
224
+
225
+ if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'):
226
+ pytest.skip('compiler flags customized')
227
+ assert global_sysconfig.get_config_var('LDSHARED') == sysconfig.get_config_var(
228
+ 'LDSHARED'
229
+ )
230
+ assert global_sysconfig.get_config_var('CC') == sysconfig.get_config_var('CC')
231
+
232
+ @pytest.mark.skipif("not sysconfig.get_config_var('EXT_SUFFIX')")
233
+ def test_SO_deprecation(self):
234
+ with pytest.warns(DeprecationWarning):
235
+ sysconfig.get_config_var('SO')
236
+
237
+ def test_customize_compiler_before_get_config_vars(self, tmp_path):
238
+ # Issue #21923: test that a Distribution compiler
239
+ # instance can be called without an explicit call to
240
+ # get_config_vars().
241
+ jaraco.path.build(
242
+ {
243
+ 'file': trim("""
244
+ from distutils.core import Distribution
245
+ config = Distribution().get_command_obj('config')
246
+ # try_compile may pass or it may fail if no compiler
247
+ # is found but it should not raise an exception.
248
+ rc = config.try_compile('int x;')
249
+ """)
250
+ },
251
+ tmp_path,
252
+ )
253
+ p = subprocess.Popen(
254
+ [sys.executable, tmp_path / 'file'],
255
+ stdout=subprocess.PIPE,
256
+ stderr=subprocess.STDOUT,
257
+ universal_newlines=True,
258
+ encoding='utf-8',
259
+ )
260
+ outs, errs = p.communicate()
261
+ assert 0 == p.returncode, "Subprocess failed: " + outs
262
+
263
+ def test_parse_config_h(self):
264
+ config_h = sysconfig.get_config_h_filename()
265
+ input = {}
266
+ with open(config_h, encoding="utf-8") as f:
267
+ result = sysconfig.parse_config_h(f, g=input)
268
+ assert input is result
269
+ with open(config_h, encoding="utf-8") as f:
270
+ result = sysconfig.parse_config_h(f)
271
+ assert isinstance(result, dict)
272
+
273
+ @pytest.mark.skipif("platform.system() != 'Windows'")
274
+ @pytest.mark.skipif("sys.implementation.name != 'cpython'")
275
+ def test_win_ext_suffix(self):
276
+ assert sysconfig.get_config_var("EXT_SUFFIX").endswith(".pyd")
277
+ assert sysconfig.get_config_var("EXT_SUFFIX") != ".pyd"
278
+
279
+ @pytest.mark.skipif("platform.system() != 'Windows'")
280
+ @pytest.mark.skipif("sys.implementation.name != 'cpython'")
281
+ @pytest.mark.skipif(
282
+ '\\PCbuild\\'.casefold() not in sys.executable.casefold(),
283
+ reason='Need sys.executable to be in a source tree',
284
+ )
285
+ def test_win_build_venv_from_source_tree(self, tmp_path):
286
+ """Ensure distutils.sysconfig detects venvs from source tree builds."""
287
+ env = jaraco.envs.VEnv()
288
+ env.create_opts = env.clean_opts
289
+ env.root = tmp_path
290
+ env.ensure_env()
291
+ cmd = [
292
+ env.exe(),
293
+ "-c",
294
+ "import distutils.sysconfig; print(distutils.sysconfig.python_build)",
295
+ ]
296
+ distutils_path = os.path.dirname(os.path.dirname(distutils.__file__))
297
+ out = subprocess.check_output(
298
+ cmd, env={**os.environ, "PYTHONPATH": distutils_path}
299
+ )
300
+ assert out == "True"
301
+
302
+ def test_get_python_inc_missing_config_dir(self, monkeypatch):
303
+ """
304
+ In portable Python installations, the sysconfig will be broken,
305
+ pointing to the directories where the installation was built and
306
+ not where it currently is. In this case, ensure that the missing
307
+ directory isn't used for get_python_inc.
308
+
309
+ See pypa/distutils#178.
310
+ """
311
+
312
+ def override(name):
313
+ if name == 'INCLUDEPY':
314
+ return '/does-not-exist'
315
+ return sysconfig.get_config_var(name)
316
+
317
+ monkeypatch.setattr(sysconfig, 'get_config_var', override)
318
+
319
+ assert os.path.exists(sysconfig.get_python_inc())
project/ManiSkill3/src/maniskill2_benchmark/mani_skill2_repo/.eggs/setuptools-80.9.0-py3.10.egg/setuptools/_distutils/tests/test_util.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for distutils.util."""
2
+
3
+ import email
4
+ import email.generator
5
+ import email.policy
6
+ import io
7
+ import os
8
+ import pathlib
9
+ import sys
10
+ import sysconfig as stdlib_sysconfig
11
+ import unittest.mock as mock
12
+ from copy import copy
13
+ from distutils import sysconfig, util
14
+ from distutils.errors import DistutilsByteCompileError, DistutilsPlatformError
15
+ from distutils.util import (
16
+ byte_compile,
17
+ change_root,
18
+ check_environ,
19
+ convert_path,
20
+ get_host_platform,
21
+ get_platform,
22
+ grok_environment_error,
23
+ rfc822_escape,
24
+ split_quoted,
25
+ strtobool,
26
+ )
27
+
28
+ import pytest
29
+
30
+
31
+ @pytest.fixture(autouse=True)
32
+ def environment(monkeypatch):
33
+ monkeypatch.setattr(os, 'name', os.name)
34
+ monkeypatch.setattr(sys, 'platform', sys.platform)
35
+ monkeypatch.setattr(sys, 'version', sys.version)
36
+ monkeypatch.setattr(os, 'sep', os.sep)
37
+ monkeypatch.setattr(os.path, 'join', os.path.join)
38
+ monkeypatch.setattr(os.path, 'isabs', os.path.isabs)
39
+ monkeypatch.setattr(os.path, 'splitdrive', os.path.splitdrive)
40
+ monkeypatch.setattr(sysconfig, '_config_vars', copy(sysconfig._config_vars))
41
+
42
+
43
+ @pytest.mark.usefixtures('save_env')
44
+ class TestUtil:
45
+ def test_get_host_platform(self):
46
+ with mock.patch('os.name', 'nt'):
47
+ with mock.patch('sys.version', '... [... (ARM64)]'):
48
+ assert get_host_platform() == 'win-arm64'
49
+ with mock.patch('sys.version', '... [... (ARM)]'):
50
+ assert get_host_platform() == 'win-arm32'
51
+
52
+ with mock.patch('sys.version_info', (3, 9, 0, 'final', 0)):
53
+ assert get_host_platform() == stdlib_sysconfig.get_platform()
54
+
55
+ def test_get_platform(self):
56
+ with mock.patch('os.name', 'nt'):
57
+ with mock.patch.dict('os.environ', {'VSCMD_ARG_TGT_ARCH': 'x86'}):
58
+ assert get_platform() == 'win32'
59
+ with mock.patch.dict('os.environ', {'VSCMD_ARG_TGT_ARCH': 'x64'}):
60
+ assert get_platform() == 'win-amd64'
61
+ with mock.patch.dict('os.environ', {'VSCMD_ARG_TGT_ARCH': 'arm'}):
62
+ assert get_platform() == 'win-arm32'
63
+ with mock.patch.dict('os.environ', {'VSCMD_ARG_TGT_ARCH': 'arm64'}):
64
+ assert get_platform() == 'win-arm64'
65
+
66
+ def test_convert_path(self):
67
+ expected = os.sep.join(('', 'home', 'to', 'my', 'stuff'))
68
+ assert convert_path('/home/to/my/stuff') == expected
69
+ assert convert_path(pathlib.Path('/home/to/my/stuff')) == expected
70
+ assert convert_path('.') == os.curdir
71
+
72
+ def test_change_root(self):
73
+ # linux/mac
74
+ os.name = 'posix'
75
+
76
+ def _isabs(path):
77
+ return path[0] == '/'
78
+
79
+ os.path.isabs = _isabs
80
+
81
+ def _join(*path):
82
+ return '/'.join(path)
83
+
84
+ os.path.join = _join
85
+
86
+ assert change_root('/root', '/old/its/here') == '/root/old/its/here'
87
+ assert change_root('/root', 'its/here') == '/root/its/here'
88
+
89
+ # windows
90
+ os.name = 'nt'
91
+ os.sep = '\\'
92
+
93
+ def _isabs(path):
94
+ return path.startswith('c:\\')
95
+
96
+ os.path.isabs = _isabs
97
+
98
+ def _splitdrive(path):
99
+ if path.startswith('c:'):
100
+ return ('', path.replace('c:', ''))
101
+ return ('', path)
102
+
103
+ os.path.splitdrive = _splitdrive
104
+
105
+ def _join(*path):
106
+ return '\\'.join(path)
107
+
108
+ os.path.join = _join
109
+
110
+ assert (
111
+ change_root('c:\\root', 'c:\\old\\its\\here') == 'c:\\root\\old\\its\\here'
112
+ )
113
+ assert change_root('c:\\root', 'its\\here') == 'c:\\root\\its\\here'
114
+
115
+ # BugsBunny os (it's a great os)
116
+ os.name = 'BugsBunny'
117
+ with pytest.raises(DistutilsPlatformError):
118
+ change_root('c:\\root', 'its\\here')
119
+
120
+ # XXX platforms to be covered: mac
121
+
122
+ def test_check_environ(self):
123
+ util.check_environ.cache_clear()
124
+ os.environ.pop('HOME', None)
125
+
126
+ check_environ()
127
+
128
+ assert os.environ['PLAT'] == get_platform()
129
+
130
+ @pytest.mark.skipif("os.name != 'posix'")
131
+ def test_check_environ_getpwuid(self):
132
+ util.check_environ.cache_clear()
133
+ os.environ.pop('HOME', None)
134
+
135
+ import pwd
136
+
137
+ # only set pw_dir field, other fields are not used
138
+ result = pwd.struct_passwd((
139
+ None,
140
+ None,
141
+ None,
142
+ None,
143
+ None,
144
+ '/home/distutils',
145
+ None,
146
+ ))
147
+ with mock.patch.object(pwd, 'getpwuid', return_value=result):
148
+ check_environ()
149
+ assert os.environ['HOME'] == '/home/distutils'
150
+
151
+ util.check_environ.cache_clear()
152
+ os.environ.pop('HOME', None)
153
+
154
+ # bpo-10496: Catch pwd.getpwuid() error
155
+ with mock.patch.object(pwd, 'getpwuid', side_effect=KeyError):
156
+ check_environ()
157
+ assert 'HOME' not in os.environ
158
+
159
+ def test_split_quoted(self):
160
+ assert split_quoted('""one"" "two" \'three\' \\four') == [
161
+ 'one',
162
+ 'two',
163
+ 'three',
164
+ 'four',
165
+ ]
166
+
167
+ def test_strtobool(self):
168
+ yes = ('y', 'Y', 'yes', 'True', 't', 'true', 'True', 'On', 'on', '1')
169
+ no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N')
170
+
171
+ for y in yes:
172
+ assert strtobool(y)
173
+
174
+ for n in no:
175
+ assert not strtobool(n)
176
+
177
+ indent = 8 * ' '
178
+
179
+ @pytest.mark.parametrize(
180
+ "given,wanted",
181
+ [
182
+ # 0x0b, 0x0c, ..., etc are also considered a line break by Python
183
+ ("hello\x0b\nworld\n", f"hello\x0b{indent}\n{indent}world\n{indent}"),
184
+ ("hello\x1eworld", f"hello\x1e{indent}world"),
185
+ ("", ""),
186
+ (
187
+ "I am a\npoor\nlonesome\nheader\n",
188
+ f"I am a\n{indent}poor\n{indent}lonesome\n{indent}header\n{indent}",
189
+ ),
190
+ ],
191
+ )
192
+ def test_rfc822_escape(self, given, wanted):
193
+ """
194
+ We want to ensure a multi-line header parses correctly.
195
+
196
+ For interoperability, the escaped value should also "round-trip" over
197
+ `email.generator.Generator.flatten` and `email.message_from_*`
198
+ (see pypa/setuptools#4033).
199
+
200
+ The main issue is that internally `email.policy.EmailPolicy` uses
201
+ `splitlines` which will split on some control chars. If all the new lines
202
+ are not prefixed with spaces, the parser will interrupt reading
203
+ the current header and produce an incomplete value, while
204
+ incorrectly interpreting the rest of the headers as part of the payload.
205
+ """
206
+ res = rfc822_escape(given)
207
+
208
+ policy = email.policy.EmailPolicy(
209
+ utf8=True,
210
+ mangle_from_=False,
211
+ max_line_length=0,
212
+ )
213
+ with io.StringIO() as buffer:
214
+ raw = f"header: {res}\nother-header: 42\n\npayload\n"
215
+ orig = email.message_from_string(raw)
216
+ email.generator.Generator(buffer, policy=policy).flatten(orig)
217
+ buffer.seek(0)
218
+ regen = email.message_from_file(buffer)
219
+
220
+ for msg in (orig, regen):
221
+ assert msg.get_payload() == "payload\n"
222
+ assert msg["other-header"] == "42"
223
+ # Generator may replace control chars with `\n`
224
+ assert set(msg["header"].splitlines()) == set(res.splitlines())
225
+
226
+ assert res == wanted
227
+
228
+ def test_dont_write_bytecode(self):
229
+ # makes sure byte_compile raise a DistutilsError
230
+ # if sys.dont_write_bytecode is True
231
+ old_dont_write_bytecode = sys.dont_write_bytecode
232
+ sys.dont_write_bytecode = True
233
+ try:
234
+ with pytest.raises(DistutilsByteCompileError):
235
+ byte_compile([])
236
+ finally:
237
+ sys.dont_write_bytecode = old_dont_write_bytecode
238
+
239
+ def test_grok_environment_error(self):
240
+ # test obsolete function to ensure backward compat (#4931)
241
+ exc = OSError("Unable to find batch file")
242
+ msg = grok_environment_error(exc)
243
+ assert msg == "error: Unable to find batch file"
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_scene/0_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -10
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/0_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/1_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/2_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/3_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/4_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/empty_table/5_scene_config.yaml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene.yaml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - name: table
3
+ visual:
4
+ path: object/table/desktable.glb
5
+ collision:
6
+ path: "object/table/desktable.obj" # same as visual in this case
7
+ scale: [2.0, 1.0, 1.5]
8
+ pose:
9
+ position: [0.4, 0, -0.75]
10
+ quaternion: [0, 0, 0.7071068, 0.7071068]
11
+ # - name: box_1
12
+ # visual:
13
+ # path: object/box_01/box_01.gltf
14
+ # collision:
15
+ # path: "object/box_01/box_01.gltf" # same as visual in this case
16
+ # scale: [0.6, 1, 0.7]
17
+ # pose:
18
+ # position: [0.6, 0, 0.2]
19
+ # quaternion: [1, 0, 0, 0]
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene_shelf.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - name: table
3
+ visual:
4
+ path: object/table/desktable.glb
5
+ collision:
6
+ path: "object/table/desktable.obj" # same as visual in this case
7
+ scale: [2.0, 1.0, 1.5]
8
+ pose:
9
+ position: [0.4, 0.5, -0.75]
10
+ quaternion: [0, 0, 0.7071068, 0.7071068]
11
+ - name: rack
12
+ visual:
13
+ path: object/storage_rack_02/storage_rack_02.gltf
14
+ collision:
15
+ path: "object/storage_rack_02/rack_convex/"
16
+ scale: [0.4, 1.1, 1.0]
17
+ pose:
18
+ position: [0.4, -0.6, -1.0]
19
+ quaternion: [0.5, 0.5, 0.5, 0.5]
20
+ # - name: rack
21
+ # visual:
22
+ # path: object/storage_rack_02/storage_rack_02.gltf
23
+ # collision:
24
+ # path: "object/storage_rack_02/storage_rack_02.gltf" # same as visual in this case
25
+ # scale: [0.4, 1.1, 1.0]
26
+ # pose:
27
+ # position: [0.4, -0.6, -1.0]
28
+ # quaternion: [0.5, 0.5, 0.5, 0.5]
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/scene/base_scene_shelf_box.yaml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - name: table
3
+ visual:
4
+ path: object/table/desktable.glb
5
+ collision:
6
+ path: "object/table/desktable.obj" # same as visual in this case
7
+ scale: [2.0, 1.0, 1.5]
8
+ pose:
9
+ position: [0.4, 0, -0.75]
10
+ quaternion: [0, 0, 0.7071068, 0.7071068]
11
+ - name: box_1
12
+ visual:
13
+ path: object/box_01/box_01.gltf
14
+ collision:
15
+ path: "object/box_01/box_01.gltf" # same as visual in this case
16
+ scale: [0.6, 0.6, 0.5]
17
+ pose:
18
+ position: [0.4, -0.1, 0]
19
+ quaternion: [0.5, 0.5, 0.5, 0.5]
20
+ - name: rack
21
+ visual:
22
+ path: object/storage_rack_02/storage_rack_02.gltf
23
+ collision:
24
+ path: "object/storage_rack_02/storage_rack_02.gltf" # same as visual in this case
25
+ scale: [1.0, 1.0, 1.2]
26
+ pose:
27
+ position: [-1.3, -0.1, -0.7]
28
+ quaternion: [0.5, 0.5, 0.5, 0.5]
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/10_scene_config.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
21
+ - collision:
22
+ path: object/box_01/box_01.gltf
23
+ name: box_01
24
+ pose:
25
+ position:
26
+ - 0.5540059208869934
27
+ - 0.3453783690929413
28
+ - 0.12628550827503204
29
+ quaternion:
30
+ - 0.955771803855896
31
+ - 4.656612873077393e-10
32
+ - 2.219451289420249e-09
33
+ - 0.2941097021102905
34
+ scale:
35
+ - 0.30462633472651585
36
+ - 0.4503056890001809
37
+ - 0.6995941077533729
38
+ visual:
39
+ path: object/box_01/box_01.gltf
40
+ - collision:
41
+ path: object/box_01/box_01.gltf
42
+ name: box_02
43
+ pose:
44
+ position:
45
+ - 0.27282679080963135
46
+ - 0.3247530162334442
47
+ - 0.3824552595615387
48
+ quaternion:
49
+ - 0.9843308329582214
50
+ - -2.3283064365386963e-10
51
+ - 8.717506716493517e-10
52
+ - -0.1763322800397873
53
+ scale:
54
+ - 0.48187877729829126
55
+ - 0.5548228280451645
56
+ - 0.6028739189573185
57
+ visual:
58
+ path: object/box_01/box_01.gltf
59
+ - collision:
60
+ path: object/051_large_clamp/collision.obj
61
+ name: large_clamp
62
+ pose:
63
+ position:
64
+ - 0.6507374048233032
65
+ - 0.26436543464660645
66
+ - 0.0047948057763278484
67
+ quaternion:
68
+ - 0.0034927770029753447
69
+ - 0.9787878394126892
70
+ - 0.204830601811409
71
+ - -0.002589120762422681
72
+ scale: 1.0
73
+ visual:
74
+ path: object/051_large_clamp/textured.obj
75
+ - collision:
76
+ path: object/032_knife/collision.obj
77
+ name: knife
78
+ pose:
79
+ position:
80
+ - 0.13959355652332306
81
+ - -0.1456039547920227
82
+ - -0.006704706232994795
83
+ quaternion:
84
+ - 0.8540351986885071
85
+ - -0.0500582791864872
86
+ - -0.029334235936403275
87
+ - 0.516969621181488
88
+ scale: 1.0
89
+ visual:
90
+ path: object/032_knife/textured.obj
91
+ - collision:
92
+ path: object/038_padlock/collision.obj
93
+ name: padlock
94
+ pose:
95
+ position:
96
+ - 0.058888789266347885
97
+ - 0.3259919583797455
98
+ - 0.0003714972117450088
99
+ quaternion:
100
+ - 0.9998327493667603
101
+ - 3.6139972507953644e-06
102
+ - -6.181653589010239e-07
103
+ - -0.01829713210463524
104
+ scale: 1.0
105
+ visual:
106
+ path: object/038_padlock/textured.obj
107
+ - collision:
108
+ path: object/005_tomato_soup_can/collision.obj
109
+ name: tomato_soup_can
110
+ pose:
111
+ position:
112
+ - 0.5280516147613525
113
+ - -0.13761192560195923
114
+ - 0.03673742711544037
115
+ quaternion:
116
+ - 0.7122544646263123
117
+ - 0.0030311106238514185
118
+ - -0.003631005762144923
119
+ - -0.7019054889678955
120
+ scale: 1.0
121
+ visual:
122
+ path: object/005_tomato_soup_can/textured.obj
123
+ - collision:
124
+ path: object/057_racquetball/collision.obj
125
+ name: racquetball
126
+ pose:
127
+ position:
128
+ - 0.47516927123069763
129
+ - -0.3109491169452667
130
+ - 0.013362742960453033
131
+ quaternion:
132
+ - 0.9950342774391174
133
+ - 0.055038727819919586
134
+ - -0.0804380252957344
135
+ - -0.02018539048731327
136
+ scale: 1.0
137
+ visual:
138
+ path: object/057_racquetball/textured.obj
139
+ - collision:
140
+ path: object/054_softball/collision.obj
141
+ name: softball
142
+ pose:
143
+ position:
144
+ - 0.3860659897327423
145
+ - -0.018826313316822052
146
+ - 0.03258978947997093
147
+ quaternion:
148
+ - 0.7283158302307129
149
+ - 0.02213624119758606
150
+ - -0.01194368489086628
151
+ - 0.6847798824310303
152
+ scale: 1.0
153
+ visual:
154
+ path: object/054_softball/textured.obj
155
+ - collision:
156
+ path: object/009_gelatin_box/collision.obj
157
+ name: gelatin_box
158
+ pose:
159
+ position:
160
+ - 0.05515049770474434
161
+ - 0.4038052558898926
162
+ - 0.00034619105281308293
163
+ quaternion:
164
+ - 0.006828893441706896
165
+ - -0.6510798335075378
166
+ - -0.7589545249938965
167
+ - -0.006042522378265858
168
+ scale: 1.0
169
+ visual:
170
+ path: object/009_gelatin_box/textured.obj
171
+ - collision:
172
+ path: object/011_banana/collision.obj
173
+ name: banana
174
+ pose:
175
+ position:
176
+ - 0.5881876349449158
177
+ - 0.09575887024402618
178
+ - 0.004429987631738186
179
+ quaternion:
180
+ - 0.7235199809074402
181
+ - 0.00045461952686309814
182
+ - -0.0008089791517704725
183
+ - 0.6903027296066284
184
+ scale: 1.0
185
+ visual:
186
+ path: object/011_banana/textured.obj
187
+ - collision:
188
+ path: object/043_phillips_screwdriver/collision.obj
189
+ name: phillips_screwdriver
190
+ pose:
191
+ position:
192
+ - 0.3318164348602295
193
+ - 0.34391456842422485
194
+ - 0.5161935687065125
195
+ quaternion:
196
+ - 0.9093779921531677
197
+ - 0.19456228613853455
198
+ - 0.050330422818660736
199
+ - 0.3642030358314514
200
+ scale: 1.0
201
+ visual:
202
+ path: object/043_phillips_screwdriver/textured.obj
203
+ - collision:
204
+ path: object/073-a_lego_duplo/collision.obj
205
+ name: lego_duplo
206
+ pose:
207
+ position:
208
+ - 0.3287605047225952
209
+ - -0.3322675824165344
210
+ - -0.001962269190698862
211
+ quaternion:
212
+ - 0.9214631915092468
213
+ - -0.00017691310495138168
214
+ - -0.0002771954459603876
215
+ - 0.38846608996391296
216
+ scale: 1.0
217
+ visual:
218
+ path: object/073-a_lego_duplo/textured.obj
219
+ - collision:
220
+ path: object/006_mustard_bottle/collision.obj
221
+ name: mustard_bottle
222
+ pose:
223
+ position:
224
+ - 0.3012140691280365
225
+ - -0.19351541996002197
226
+ - 0.0831894800066948
227
+ quaternion:
228
+ - 0.998798668384552
229
+ - -0.003416737075895071
230
+ - 0.00013295424287207425
231
+ - -0.04888187721371651
232
+ scale: 1.0
233
+ visual:
234
+ path: object/006_mustard_bottle/textured.obj
235
+ - collision:
236
+ path: object/002_master_chef_can/collision.obj
237
+ name: master_chef_can
238
+ pose:
239
+ position:
240
+ - 0.2739158272743225
241
+ - 0.16811329126358032
242
+ - 0.056464310735464096
243
+ quaternion:
244
+ - 0.9971371293067932
245
+ - 3.3126998459920287e-06
246
+ - -1.9168946892023087e-06
247
+ - -0.07561670243740082
248
+ scale: 1.0
249
+ visual:
250
+ path: object/002_master_chef_can/textured.obj
251
+ - collision:
252
+ path: object/036_wood_block/collision.obj
253
+ name: wood_block
254
+ pose:
255
+ position:
256
+ - 0.42733234167099
257
+ - -0.2404153198003769
258
+ - 0.0901753306388855
259
+ quaternion:
260
+ - 0.788737952709198
261
+ - -0.00010942301014438272
262
+ - -0.00404078746214509
263
+ - -0.6147165298461914
264
+ scale: 1.0
265
+ visual:
266
+ path: object/036_wood_block/textured.obj
267
+ - collision:
268
+ path: object/012_strawberry/collision.obj
269
+ name: strawberry
270
+ pose:
271
+ position:
272
+ - 0.19788631796836853
273
+ - -0.364406555891037
274
+ - 0.008576838299632072
275
+ quaternion:
276
+ - 0.9993845224380493
277
+ - -0.019167844206094742
278
+ - 0.025167033076286316
279
+ - 0.015163440257310867
280
+ scale: 1.0
281
+ visual:
282
+ path: object/012_strawberry/textured.obj
283
+ - collision:
284
+ path: object/072-c_toy_airplane/collision.obj
285
+ name: toy_airplane
286
+ pose:
287
+ position:
288
+ - 0.0575077198445797
289
+ - -0.5082716941833496
290
+ - 0.019499726593494415
291
+ quaternion:
292
+ - 0.9456946849822998
293
+ - 8.636110578663647e-06
294
+ - 1.4507357263937593e-05
295
+ - -0.3250561058521271
296
+ scale: 1.0
297
+ visual:
298
+ path: object/072-c_toy_airplane/textured.obj
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/13_scene_config.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
21
+ - collision:
22
+ path: object/box_01/box_01.gltf
23
+ name: box_01
24
+ pose:
25
+ position:
26
+ - 0.2600131332874298
27
+ - 0.3242727220058441
28
+ - 0.12627248466014862
29
+ quaternion:
30
+ - 0.9969368577003479
31
+ - 2.3283064365386963e-10
32
+ - 1.9917933968827128e-10
33
+ - 0.07821343094110489
34
+ scale:
35
+ - 0.30462633472651585
36
+ - 0.4503056890001809
37
+ - 0.6995941077533729
38
+ visual:
39
+ path: object/box_01/box_01.gltf
40
+ - collision:
41
+ path: object/box_01/box_01.gltf
42
+ name: box_02
43
+ pose:
44
+ position:
45
+ - 0.31212708353996277
46
+ - -0.03571797162294388
47
+ - 0.10678669065237045
48
+ quaternion:
49
+ - 0.9896991848945618
50
+ - 1.3969838619232178e-09
51
+ - -2.5556801119819283e-10
52
+ - -0.14316244423389435
53
+ scale:
54
+ - 0.48187877729829126
55
+ - 0.5548228280451645
56
+ - 0.6028739189573185
57
+ visual:
58
+ path: object/box_01/box_01.gltf
59
+ - collision:
60
+ path: object/051_large_clamp/collision.obj
61
+ name: large_clamp
62
+ pose:
63
+ position:
64
+ - 0.30179834365844727
65
+ - -0.3673531413078308
66
+ - 0.004934901371598244
67
+ quaternion:
68
+ - 0.9214151501655579
69
+ - 0.01573387160897255
70
+ - 0.006530481856316328
71
+ - 0.3882060647010803
72
+ scale: 1.0
73
+ visual:
74
+ path: object/051_large_clamp/textured.obj
75
+ - collision:
76
+ path: object/032_knife/collision.obj
77
+ name: knife
78
+ pose:
79
+ position:
80
+ - 0.590972900390625
81
+ - -0.3353188633918762
82
+ - -0.006698941346257925
83
+ quaternion:
84
+ - 0.7824130654335022
85
+ - -0.04494365304708481
86
+ - 0.03668520227074623
87
+ - -0.6200517416000366
88
+ scale: 1.0
89
+ visual:
90
+ path: object/032_knife/textured.obj
91
+ - collision:
92
+ path: object/038_padlock/collision.obj
93
+ name: padlock
94
+ pose:
95
+ position:
96
+ - 0.5620276927947998
97
+ - 0.33525681495666504
98
+ - 0.0003732643090188503
99
+ quaternion:
100
+ - 0.9999450445175171
101
+ - 1.9050203263759613e-06
102
+ - -4.377681761980057e-06
103
+ - -0.010492338798940182
104
+ scale: 1.0
105
+ visual:
106
+ path: object/038_padlock/textured.obj
107
+ - collision:
108
+ path: object/005_tomato_soup_can/collision.obj
109
+ name: tomato_soup_can
110
+ pose:
111
+ position:
112
+ - 0.48183348774909973
113
+ - -0.29772084951400757
114
+ - 0.036742474883794785
115
+ quaternion:
116
+ - 0.9364031553268433
117
+ - 0.004575126338750124
118
+ - 0.001217052573338151
119
+ - 0.35089439153671265
120
+ scale: 1.0
121
+ visual:
122
+ path: object/005_tomato_soup_can/textured.obj
123
+ - collision:
124
+ path: object/057_racquetball/collision.obj
125
+ name: racquetball
126
+ pose:
127
+ position:
128
+ - 0.4179935157299042
129
+ - -0.12145572900772095
130
+ - 0.013357745483517647
131
+ quaternion:
132
+ - 0.7930589914321899
133
+ - -0.0027601830661296844
134
+ - -0.09742449969053268
135
+ - -0.6012974381446838
136
+ scale: 1.0
137
+ visual:
138
+ path: object/057_racquetball/textured.obj
139
+ - collision:
140
+ path: object/054_softball/collision.obj
141
+ name: softball
142
+ pose:
143
+ position:
144
+ - -0.2997354567050934
145
+ - 0.4991663098335266
146
+ - -0.7519590258598328
147
+ quaternion:
148
+ - -0.29745084047317505
149
+ - -0.8697314858436584
150
+ - 0.37594035267829895
151
+ - 0.11729992181062698
152
+ scale: 1.0
153
+ visual:
154
+ path: object/054_softball/textured.obj
155
+ - collision:
156
+ path: object/009_gelatin_box/collision.obj
157
+ name: gelatin_box
158
+ pose:
159
+ position:
160
+ - 0.6723349094390869
161
+ - -0.4518553614616394
162
+ - 0.0009576601441949606
163
+ quaternion:
164
+ - 0.995653510093689
165
+ - 5.730966222472489e-06
166
+ - -4.902940418105572e-07
167
+ - 0.09313605725765228
168
+ scale: 1.0
169
+ visual:
170
+ path: object/009_gelatin_box/textured.obj
171
+ - collision:
172
+ path: object/011_banana/collision.obj
173
+ name: banana
174
+ pose:
175
+ position:
176
+ - 0.27068841457366943
177
+ - -0.13846950232982635
178
+ - 0.004433405585587025
179
+ quaternion:
180
+ - 0.9667468070983887
181
+ - -0.0018015876412391663
182
+ - -0.0028480058535933495
183
+ - -0.25571319460868835
184
+ scale: 1.0
185
+ visual:
186
+ path: object/011_banana/textured.obj
187
+ - collision:
188
+ path: object/043_phillips_screwdriver/collision.obj
189
+ name: phillips_screwdriver
190
+ pose:
191
+ position:
192
+ - 0.2952132225036621
193
+ - 0.31410926580429077
194
+ - -8.021248504519463e-05
195
+ quaternion:
196
+ - -0.08763675391674042
197
+ - 0.044274117797613144
198
+ - -0.18019986152648926
199
+ - 0.9787173867225647
200
+ scale: 1.0
201
+ visual:
202
+ path: object/043_phillips_screwdriver/textured.obj
203
+ - collision:
204
+ path: object/073-a_lego_duplo/collision.obj
205
+ name: lego_duplo
206
+ pose:
207
+ position:
208
+ - 0.31756454706192017
209
+ - 0.17813710868358612
210
+ - -0.0019623327534645796
211
+ quaternion:
212
+ - 0.8716660141944885
213
+ - -1.400848850607872e-05
214
+ - 2.8955109883099794e-06
215
+ - -0.4901004135608673
216
+ scale: 1.0
217
+ visual:
218
+ path: object/073-a_lego_duplo/textured.obj
219
+ - collision:
220
+ path: object/006_mustard_bottle/collision.obj
221
+ name: mustard_bottle
222
+ pose:
223
+ position:
224
+ - 0.0867718979716301
225
+ - 0.1676323115825653
226
+ - 0.08319085836410522
227
+ quaternion:
228
+ - 0.8900477886199951
229
+ - -0.0030580703169107437
230
+ - 0.0015297516947612166
231
+ - -0.4558544456958771
232
+ scale: 1.0
233
+ visual:
234
+ path: object/006_mustard_bottle/textured.obj
235
+ - collision:
236
+ path: object/002_master_chef_can/collision.obj
237
+ name: master_chef_can
238
+ pose:
239
+ position:
240
+ - 0.45520690083503723
241
+ - 0.2683074176311493
242
+ - 0.056465260684490204
243
+ quaternion:
244
+ - 0.8327399492263794
245
+ - 2.822984242811799e-06
246
+ - 2.4348264560103416e-07
247
+ - -0.5536643862724304
248
+ scale: 1.0
249
+ visual:
250
+ path: object/002_master_chef_can/textured.obj
251
+ - collision:
252
+ path: object/036_wood_block/collision.obj
253
+ name: wood_block
254
+ pose:
255
+ position:
256
+ - 0.5919787883758545
257
+ - -0.09230861812829971
258
+ - 0.09017115086317062
259
+ quaternion:
260
+ - 0.987817645072937
261
+ - 0.001885376637801528
262
+ - -0.0035402229987084866
263
+ - -0.1555652916431427
264
+ scale: 1.0
265
+ visual:
266
+ path: object/036_wood_block/textured.obj
267
+ - collision:
268
+ path: object/012_strawberry/collision.obj
269
+ name: strawberry
270
+ pose:
271
+ position:
272
+ - 0.5924925208091736
273
+ - 0.24831071496009827
274
+ - 0.008575117215514183
275
+ quaternion:
276
+ - 0.909085214138031
277
+ - -0.02766706794500351
278
+ - 0.015344343148171902
279
+ - 0.41540753841400146
280
+ scale: 1.0
281
+ visual:
282
+ path: object/012_strawberry/textured.obj
283
+ - collision:
284
+ path: object/072-c_toy_airplane/collision.obj
285
+ name: toy_airplane
286
+ pose:
287
+ position:
288
+ - 0.4595275819301605
289
+ - 0.42760536074638367
290
+ - 0.01950046978890896
291
+ quaternion:
292
+ - 0.8649252653121948
293
+ - 7.10635504219681e-07
294
+ - -1.0786170605570078e-06
295
+ - 0.5019010901451111
296
+ scale: 1.0
297
+ visual:
298
+ path: object/072-c_toy_airplane/textured.obj
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/18_scene_config.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
21
+ - collision:
22
+ path: object/box_01/box_01.gltf
23
+ name: box_01
24
+ pose:
25
+ position:
26
+ - 0.4446021020412445
27
+ - 0.29050955176353455
28
+ - 0.12626424431800842
29
+ quaternion:
30
+ - 0.9433392882347107
31
+ - 0.0
32
+ - 3.0377123039215803e-10
33
+ - -0.33182990550994873
34
+ scale:
35
+ - 0.30462633472651585
36
+ - 0.4503056890001809
37
+ - 0.6995941077533729
38
+ visual:
39
+ path: object/box_01/box_01.gltf
40
+ - collision:
41
+ path: object/box_01/box_01.gltf
42
+ name: box_02
43
+ pose:
44
+ position:
45
+ - 0.46855005621910095
46
+ - -0.2516274154186249
47
+ - 0.10678362101316452
48
+ quaternion:
49
+ - 0.9293932318687439
50
+ - 2.3283064365386963e-09
51
+ - 3.0831870390102267e-10
52
+ - 0.369091659784317
53
+ scale:
54
+ - 0.48187877729829126
55
+ - 0.5548228280451645
56
+ - 0.6028739189573185
57
+ visual:
58
+ path: object/box_01/box_01.gltf
59
+ - collision:
60
+ path: object/051_large_clamp/collision.obj
61
+ name: large_clamp
62
+ pose:
63
+ position:
64
+ - 0.2098422795534134
65
+ - -0.1291932910680771
66
+ - 0.004791269078850746
67
+ quaternion:
68
+ - -0.003990287892520428
69
+ - -0.9072166681289673
70
+ - -0.42064112424850464
71
+ - 0.0017297938466072083
72
+ scale: 1.0
73
+ visual:
74
+ path: object/051_large_clamp/textured.obj
75
+ - collision:
76
+ path: object/032_knife/collision.obj
77
+ name: knife
78
+ pose:
79
+ position:
80
+ - 0.28637921810150146
81
+ - 0.01384325884282589
82
+ - -0.006703410763293505
83
+ quaternion:
84
+ - 0.9480249881744385
85
+ - -0.05482200160622597
86
+ - 0.018967915326356888
87
+ - -0.31286343932151794
88
+ scale: 1.0
89
+ visual:
90
+ path: object/032_knife/textured.obj
91
+ - collision:
92
+ path: object/038_padlock/collision.obj
93
+ name: padlock
94
+ pose:
95
+ position:
96
+ - 0.13275587558746338
97
+ - -0.2956305742263794
98
+ - 0.00037525923107750714
99
+ quaternion:
100
+ - 0.9865192770957947
101
+ - 5.6782737374305725e-06
102
+ - -1.8726568669080734e-06
103
+ - 0.163645401597023
104
+ scale: 1.0
105
+ visual:
106
+ path: object/038_padlock/textured.obj
107
+ - collision:
108
+ path: object/005_tomato_soup_can/collision.obj
109
+ name: tomato_soup_can
110
+ pose:
111
+ position:
112
+ - 0.7378512024879456
113
+ - 0.1887216418981552
114
+ - 0.019866012036800385
115
+ quaternion:
116
+ - -0.6632572412490845
117
+ - 0.39579665660858154
118
+ - 0.5805317759513855
119
+ - -0.2577165365219116
120
+ scale: 1.0
121
+ visual:
122
+ path: object/005_tomato_soup_can/textured.obj
123
+ - collision:
124
+ path: object/057_racquetball/collision.obj
125
+ name: racquetball
126
+ pose:
127
+ position:
128
+ - 0.5852177739143372
129
+ - -0.2394147515296936
130
+ - 0.013357710093259811
131
+ quaternion:
132
+ - 0.9352325201034546
133
+ - 0.0803675726056099
134
+ - -0.055147092789411545
135
+ - 0.3403528332710266
136
+ scale: 1.0
137
+ visual:
138
+ path: object/057_racquetball/textured.obj
139
+ - collision:
140
+ path: object/054_softball/collision.obj
141
+ name: softball
142
+ pose:
143
+ position:
144
+ - 0.37791121006011963
145
+ - -0.18030773103237152
146
+ - 0.2730855941772461
147
+ quaternion:
148
+ - 0.8899809718132019
149
+ - 0.015370525419712067
150
+ - -0.016068505123257637
151
+ - 0.45545536279678345
152
+ scale: 1.0
153
+ visual:
154
+ path: object/054_softball/textured.obj
155
+ - collision:
156
+ path: object/009_gelatin_box/collision.obj
157
+ name: gelatin_box
158
+ pose:
159
+ position:
160
+ - 0.2939893305301666
161
+ - 0.22424477338790894
162
+ - 0.0009559107711538672
163
+ quaternion:
164
+ - 0.756985604763031
165
+ - 3.3548567444086075e-06
166
+ - 1.1468182492535561e-07
167
+ - -0.6534317135810852
168
+ scale: 1.0
169
+ visual:
170
+ path: object/009_gelatin_box/textured.obj
171
+ - collision:
172
+ path: object/011_banana/collision.obj
173
+ name: banana
174
+ pose:
175
+ position:
176
+ - 0.2699192464351654
177
+ - -0.4690324366092682
178
+ - 0.004431434907019138
179
+ quaternion:
180
+ - 0.8259942531585693
181
+ - 0.0003224574029445648
182
+ - -0.0008735787123441696
183
+ - 0.5636776089668274
184
+ scale: 1.0
185
+ visual:
186
+ path: object/011_banana/textured.obj
187
+ - collision:
188
+ path: object/043_phillips_screwdriver/collision.obj
189
+ name: phillips_screwdriver
190
+ pose:
191
+ position:
192
+ - 0.0712708830833435
193
+ - -0.18694385886192322
194
+ - 0.00015884707681834698
195
+ quaternion:
196
+ - 0.7834087014198303
197
+ - 0.05132182687520981
198
+ - 0.006559666711837053
199
+ - 0.6193495988845825
200
+ scale: 1.0
201
+ visual:
202
+ path: object/043_phillips_screwdriver/textured.obj
203
+ - collision:
204
+ path: object/073-a_lego_duplo/collision.obj
205
+ name: lego_duplo
206
+ pose:
207
+ position:
208
+ - 0.4959663450717926
209
+ - -0.458866149187088
210
+ - -0.0019607827998697758
211
+ quaternion:
212
+ - 0.8269393444061279
213
+ - 5.000841338187456e-05
214
+ - 6.670382572337985e-05
215
+ - 0.5622912049293518
216
+ scale: 1.0
217
+ visual:
218
+ path: object/073-a_lego_duplo/textured.obj
219
+ - collision:
220
+ path: object/006_mustard_bottle/collision.obj
221
+ name: mustard_bottle
222
+ pose:
223
+ position:
224
+ - 0.6654345989227295
225
+ - -0.11777448654174805
226
+ - 0.08319094032049179
227
+ quaternion:
228
+ - 0.7906532287597656
229
+ - -0.002683550352230668
230
+ - -0.0021238576155155897
231
+ - 0.6122546792030334
232
+ scale: 1.0
233
+ visual:
234
+ path: object/006_mustard_bottle/textured.obj
235
+ - collision:
236
+ path: object/002_master_chef_can/collision.obj
237
+ name: master_chef_can
238
+ pose:
239
+ position:
240
+ - 0.20512913167476654
241
+ - 0.447907418012619
242
+ - 0.056465644389390945
243
+ quaternion:
244
+ - 0.9804720878601074
245
+ - 2.8952454158570617e-06
246
+ - -2.191954990848899e-06
247
+ - 0.19665849208831787
248
+ scale: 1.0
249
+ visual:
250
+ path: object/002_master_chef_can/textured.obj
251
+ - collision:
252
+ path: object/036_wood_block/collision.obj
253
+ name: wood_block
254
+ pose:
255
+ position:
256
+ - 0.4926045835018158
257
+ - 0.36373525857925415
258
+ - 0.3693050742149353
259
+ quaternion:
260
+ - 0.7077661752700806
261
+ - -0.0038924370892345905
262
+ - -5.648715887218714e-05
263
+ - -0.7064360976219177
264
+ scale: 1.0
265
+ visual:
266
+ path: object/036_wood_block/textured.obj
267
+ - collision:
268
+ path: object/012_strawberry/collision.obj
269
+ name: strawberry
270
+ pose:
271
+ position:
272
+ - 0.6029479503631592
273
+ - -0.3509550988674164
274
+ - 0.008256884291768074
275
+ quaternion:
276
+ - 0.8891028165817261
277
+ - -0.0734761506319046
278
+ - 0.010937608778476715
279
+ - -0.4516390264034271
280
+ scale: 1.0
281
+ visual:
282
+ path: object/012_strawberry/textured.obj
283
+ - collision:
284
+ path: object/072-c_toy_airplane/collision.obj
285
+ name: toy_airplane
286
+ pose:
287
+ position:
288
+ - 0.566066563129425
289
+ - -0.460176944732666
290
+ - 0.019500385969877243
291
+ quaternion:
292
+ - 0.8678380846977234
293
+ - 7.897335308371112e-06
294
+ - -4.277069820091128e-06
295
+ - 0.4968472421169281
296
+ scale: 1.0
297
+ visual:
298
+ path: object/072-c_toy_airplane/textured.obj
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/6_scene_config.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
21
+ - collision:
22
+ path: object/box_01/box_01.gltf
23
+ name: box_01
24
+ pose:
25
+ position:
26
+ - 0.3222593367099762
27
+ - -0.3457235097885132
28
+ - 0.1262739598751068
29
+ quaternion:
30
+ - 0.949219822883606
31
+ - -1.3969838619232178e-09
32
+ - -3.7562131183221936e-10
33
+ - -0.3146144151687622
34
+ scale:
35
+ - 0.30462633472651585
36
+ - 0.4503056890001809
37
+ - 0.6995941077533729
38
+ visual:
39
+ path: object/box_01/box_01.gltf
40
+ - collision:
41
+ path: object/box_01/box_01.gltf
42
+ name: box_02
43
+ pose:
44
+ position:
45
+ - 0.481027215719223
46
+ - -0.024567749351263046
47
+ - 0.1067868322134018
48
+ quaternion:
49
+ - 0.9900256395339966
50
+ - 1.6298145055770874e-09
51
+ - -4.3155523599125445e-10
52
+ - -0.14088822901248932
53
+ scale:
54
+ - 0.48187877729829126
55
+ - 0.5548228280451645
56
+ - 0.6028739189573185
57
+ visual:
58
+ path: object/box_01/box_01.gltf
59
+ - collision:
60
+ path: object/051_large_clamp/collision.obj
61
+ name: large_clamp
62
+ pose:
63
+ position:
64
+ - 0.1499818116426468
65
+ - 0.09657865762710571
66
+ - 0.004600871820002794
67
+ quaternion:
68
+ - 0.933480441570282
69
+ - -0.03696729242801666
70
+ - 0.014331860467791557
71
+ - -0.3564299941062927
72
+ scale: 1.0
73
+ visual:
74
+ path: object/051_large_clamp/textured.obj
75
+ - collision:
76
+ path: object/032_knife/collision.obj
77
+ name: knife
78
+ pose:
79
+ position:
80
+ - 0.3910253643989563
81
+ - 0.13206909596920013
82
+ - 0.23240238428115845
83
+ quaternion:
84
+ - 0.8722466826438904
85
+ - -0.10972946882247925
86
+ - -0.0036878089886158705
87
+ - 0.4765833914279938
88
+ scale: 1.0
89
+ visual:
90
+ path: object/032_knife/textured.obj
91
+ - collision:
92
+ path: object/038_padlock/collision.obj
93
+ name: padlock
94
+ pose:
95
+ position:
96
+ - 0.670044481754303
97
+ - 0.36275461316108704
98
+ - 0.0003735860518645495
99
+ quaternion:
100
+ - 0.9177653193473816
101
+ - 2.971850335597992e-06
102
+ - 4.7637149691581726e-07
103
+ - -0.3971234858036041
104
+ scale: 1.0
105
+ visual:
106
+ path: object/038_padlock/textured.obj
107
+ - collision:
108
+ path: object/005_tomato_soup_can/collision.obj
109
+ name: tomato_soup_can
110
+ pose:
111
+ position:
112
+ - 0.1289377510547638
113
+ - -0.265663743019104
114
+ - 0.03666556626558304
115
+ quaternion:
116
+ - 0.9753833413124084
117
+ - 0.00400533014908433
118
+ - 0.00018187658861279488
119
+ - -0.22048020362854004
120
+ scale: 1.0
121
+ visual:
122
+ path: object/005_tomato_soup_can/textured.obj
123
+ - collision:
124
+ path: object/057_racquetball/collision.obj
125
+ name: racquetball
126
+ pose:
127
+ position:
128
+ - 0.6248867511749268
129
+ - -0.17318613827228546
130
+ - 0.01335796806961298
131
+ quaternion:
132
+ - 0.9952068328857422
133
+ - 0.057292770594358444
134
+ - -0.0788535624742508
135
+ - 0.007947297766804695
136
+ scale: 1.0
137
+ visual:
138
+ path: object/057_racquetball/textured.obj
139
+ - collision:
140
+ path: object/054_softball/collision.obj
141
+ name: softball
142
+ pose:
143
+ position:
144
+ - 0.49240392446517944
145
+ - -0.098780557513237
146
+ - 0.03258971497416496
147
+ quaternion:
148
+ - 0.822936475276947
149
+ - -0.007003158330917358
150
+ - -0.02415677160024643
151
+ - -0.5675767064094543
152
+ scale: 1.0
153
+ visual:
154
+ path: object/054_softball/textured.obj
155
+ - collision:
156
+ path: object/009_gelatin_box/collision.obj
157
+ name: gelatin_box
158
+ pose:
159
+ position:
160
+ - 0.461259126663208
161
+ - -0.2755953073501587
162
+ - 0.030791644006967545
163
+ quaternion:
164
+ - 0.6426966190338135
165
+ - -0.639816403388977
166
+ - 0.29424235224723816
167
+ - -0.30165788531303406
168
+ scale: 1.0
169
+ visual:
170
+ path: object/009_gelatin_box/textured.obj
171
+ - collision:
172
+ path: object/011_banana/collision.obj
173
+ name: banana
174
+ pose:
175
+ position:
176
+ - 0.4110216200351715
177
+ - 0.35490134358406067
178
+ - 0.00443665124475956
179
+ quaternion:
180
+ - 0.9503698348999023
181
+ - 3.54573130607605e-05
182
+ - -0.0033732284791767597
183
+ - 0.3111042082309723
184
+ scale: 1.0
185
+ visual:
186
+ path: object/011_banana/textured.obj
187
+ - collision:
188
+ path: object/043_phillips_screwdriver/collision.obj
189
+ name: phillips_screwdriver
190
+ pose:
191
+ position:
192
+ - 0.28932085633277893
193
+ - -0.08201035112142563
194
+ - 0.00016026291996240616
195
+ quaternion:
196
+ - 0.9670155048370361
197
+ - 0.04959922283887863
198
+ - -0.014761464670300484
199
+ - 0.24940568208694458
200
+ scale: 1.0
201
+ visual:
202
+ path: object/043_phillips_screwdriver/textured.obj
203
+ - collision:
204
+ path: object/073-a_lego_duplo/collision.obj
205
+ name: lego_duplo
206
+ pose:
207
+ position:
208
+ - 0.6968550682067871
209
+ - -0.4321824014186859
210
+ - -0.0019602645188570023
211
+ quaternion:
212
+ - 0.8572718501091003
213
+ - 3.327080048620701e-05
214
+ - 9.370414773002267e-07
215
+ - -0.5148642063140869
216
+ scale: 1.0
217
+ visual:
218
+ path: object/073-a_lego_duplo/textured.obj
219
+ - collision:
220
+ path: object/006_mustard_bottle/collision.obj
221
+ name: mustard_bottle
222
+ pose:
223
+ position:
224
+ - 0.29827508330345154
225
+ - -0.41968485713005066
226
+ - 0.08319402486085892
227
+ quaternion:
228
+ - 0.982006847858429
229
+ - -0.003348998026922345
230
+ - -0.0006806309684179723
231
+ - 0.1888151317834854
232
+ scale: 1.0
233
+ visual:
234
+ path: object/006_mustard_bottle/textured.obj
235
+ - collision:
236
+ path: object/002_master_chef_can/collision.obj
237
+ name: master_chef_can
238
+ pose:
239
+ position:
240
+ - 0.1292555183172226
241
+ - -0.42202019691467285
242
+ - 0.05646669864654541
243
+ quaternion:
244
+ - 0.7298344373703003
245
+ - 3.900931915268302e-06
246
+ - 3.832974471151829e-06
247
+ - -0.6836239695549011
248
+ scale: 1.0
249
+ visual:
250
+ path: object/002_master_chef_can/textured.obj
251
+ - collision:
252
+ path: object/036_wood_block/collision.obj
253
+ name: wood_block
254
+ pose:
255
+ position:
256
+ - 0.6624081134796143
257
+ - 0.2338888794183731
258
+ - 0.09017322957515717
259
+ quaternion:
260
+ - 0.9026984572410583
261
+ - 0.0035555679351091385
262
+ - -0.001857698312960565
263
+ - 0.4302552342414856
264
+ scale: 1.0
265
+ visual:
266
+ path: object/036_wood_block/textured.obj
267
+ - collision:
268
+ path: object/012_strawberry/collision.obj
269
+ name: strawberry
270
+ pose:
271
+ position:
272
+ - 0.6003867387771606
273
+ - -0.3430365025997162
274
+ - 0.008257033303380013
275
+ quaternion:
276
+ - 0.9331845641136169
277
+ - -0.057636748999357224
278
+ - -0.046866096556186676
279
+ - 0.35163646936416626
280
+ scale: 1.0
281
+ visual:
282
+ path: object/012_strawberry/textured.obj
283
+ - collision:
284
+ path: object/072-c_toy_airplane/collision.obj
285
+ name: toy_airplane
286
+ pose:
287
+ position:
288
+ - 0.06322619318962097
289
+ - -0.2130347192287445
290
+ - 0.0006565345684066415
291
+ quaternion:
292
+ - -0.29697299003601074
293
+ - -0.2992590665817261
294
+ - 0.6475196480751038
295
+ - 0.6347987055778503
296
+ scale: 1.0
297
+ visual:
298
+ path: object/072-c_toy_airplane/textured.obj
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/env_config/smallbox_distractor/8_scene_config.yaml ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - collision:
3
+ path: object/table/desktable.obj
4
+ name: table
5
+ pose:
6
+ position:
7
+ - 0.4000000059604645
8
+ - 0.0
9
+ - -0.75
10
+ quaternion:
11
+ - 0.0
12
+ - 0.0
13
+ - 0.7071068286895752
14
+ - 0.7071068286895752
15
+ scale:
16
+ - 2.0
17
+ - 1.0
18
+ - 1.5
19
+ visual:
20
+ path: object/table/desktable.glb
21
+ - collision:
22
+ path: object/box_01/box_01.gltf
23
+ name: box_01
24
+ pose:
25
+ position:
26
+ - 0.37825292348861694
27
+ - 0.16329726576805115
28
+ - 0.1262717992067337
29
+ quaternion:
30
+ - 0.969598114490509
31
+ - 0.0
32
+ - -6.116351869422942e-11
33
+ - 0.24470341205596924
34
+ scale:
35
+ - 0.30462633472651585
36
+ - 0.4503056890001809
37
+ - 0.6995941077533729
38
+ visual:
39
+ path: object/box_01/box_01.gltf
40
+ - collision:
41
+ path: object/box_01/box_01.gltf
42
+ name: box_02
43
+ pose:
44
+ position:
45
+ - 0.4816591441631317
46
+ - 0.3444681465625763
47
+ - 0.1067897379398346
48
+ quaternion:
49
+ - 0.991497278213501
50
+ - 1.862645149230957e-09
51
+ - 3.866261977236718e-09
52
+ - 0.1301281899213791
53
+ scale:
54
+ - 0.48187877729829126
55
+ - 0.5548228280451645
56
+ - 0.6028739189573185
57
+ visual:
58
+ path: object/box_01/box_01.gltf
59
+ - collision:
60
+ path: object/051_large_clamp/collision.obj
61
+ name: large_clamp
62
+ pose:
63
+ position:
64
+ - 0.22649766504764557
65
+ - 0.3660420775413513
66
+ - 0.0047942474484443665
67
+ quaternion:
68
+ - -0.0006621364736929536
69
+ - 0.6380801796913147
70
+ - -0.7699576616287231
71
+ - -0.0042999982833862305
72
+ scale: 1.0
73
+ visual:
74
+ path: object/051_large_clamp/textured.obj
75
+ - collision:
76
+ path: object/032_knife/collision.obj
77
+ name: knife
78
+ pose:
79
+ position:
80
+ - 0.5382602214813232
81
+ - 0.13345010578632355
82
+ - -0.0067017762921750546
83
+ quaternion:
84
+ - 0.8549917340278625
85
+ - -0.04925115033984184
86
+ - 0.030661150813102722
87
+ - -0.5153865814208984
88
+ scale: 1.0
89
+ visual:
90
+ path: object/032_knife/textured.obj
91
+ - collision:
92
+ path: object/038_padlock/collision.obj
93
+ name: padlock
94
+ pose:
95
+ position:
96
+ - 0.5620970726013184
97
+ - -0.3338588774204254
98
+ - 0.00037482159677892923
99
+ quaternion:
100
+ - 0.7455541491508484
101
+ - 3.91155481338501e-06
102
+ - 4.93205152451992e-06
103
+ - -0.6664450764656067
104
+ scale: 1.0
105
+ visual:
106
+ path: object/038_padlock/textured.obj
107
+ - collision:
108
+ path: object/005_tomato_soup_can/collision.obj
109
+ name: tomato_soup_can
110
+ pose:
111
+ position:
112
+ - 0.16778449714183807
113
+ - 0.1865750253200531
114
+ - 0.03673816844820976
115
+ quaternion:
116
+ - 0.9962206482887268
117
+ - 0.0047322167083621025
118
+ - -5.394988693296909e-05
119
+ - 0.08673030138015747
120
+ scale: 1.0
121
+ visual:
122
+ path: object/005_tomato_soup_can/textured.obj
123
+ - collision:
124
+ path: object/057_racquetball/collision.obj
125
+ name: racquetball
126
+ pose:
127
+ position:
128
+ - 0.3258103132247925
129
+ - -0.2767982482910156
130
+ - 0.013363120146095753
131
+ quaternion:
132
+ - 0.9052622318267822
133
+ - 0.01858438551425934
134
+ - -0.0956725925207138
135
+ - -0.4135236144065857
136
+ scale: 1.0
137
+ visual:
138
+ path: object/057_racquetball/textured.obj
139
+ - collision:
140
+ path: object/054_softball/collision.obj
141
+ name: softball
142
+ pose:
143
+ position:
144
+ - 0.6794442534446716
145
+ - -0.37263914942741394
146
+ - 0.03259354084730148
147
+ quaternion:
148
+ - 0.9393547773361206
149
+ - 0.015637263655662537
150
+ - -0.01970824971795082
151
+ - 0.34202316403388977
152
+ scale: 1.0
153
+ visual:
154
+ path: object/054_softball/textured.obj
155
+ - collision:
156
+ path: object/009_gelatin_box/collision.obj
157
+ name: gelatin_box
158
+ pose:
159
+ position:
160
+ - 0.6688522696495056
161
+ - 0.3424641191959381
162
+ - 0.0009576840093359351
163
+ quaternion:
164
+ - 0.9925773739814758
165
+ - 2.238331944681704e-06
166
+ - -1.0965741239488125e-06
167
+ - 0.12161517888307571
168
+ scale: 1.0
169
+ visual:
170
+ path: object/009_gelatin_box/textured.obj
171
+ - collision:
172
+ path: object/011_banana/collision.obj
173
+ name: banana
174
+ pose:
175
+ position:
176
+ - 0.6101178526878357
177
+ - -0.18726269900798798
178
+ - 0.004428462125360966
179
+ quaternion:
180
+ - 0.8621869683265686
181
+ - 0.0002595148980617523
182
+ - -0.0008918971288949251
183
+ - 0.5065892338752747
184
+ scale: 1.0
185
+ visual:
186
+ path: object/011_banana/textured.obj
187
+ - collision:
188
+ path: object/043_phillips_screwdriver/collision.obj
189
+ name: phillips_screwdriver
190
+ pose:
191
+ position:
192
+ - 0.32951784133911133
193
+ - -0.3770958483219147
194
+ - 0.00016453256830573082
195
+ quaternion:
196
+ - 0.9927594661712646
197
+ - 0.041176386177539825
198
+ - -0.03133397921919823
199
+ - -0.10840417444705963
200
+ scale: 1.0
201
+ visual:
202
+ path: object/043_phillips_screwdriver/textured.obj
203
+ - collision:
204
+ path: object/073-a_lego_duplo/collision.obj
205
+ name: lego_duplo
206
+ pose:
207
+ position:
208
+ - 0.3602128028869629
209
+ - 0.05884125083684921
210
+ - 0.0019344050670042634
211
+ quaternion:
212
+ - -0.5039743185043335
213
+ - 0.503972053527832
214
+ - 0.49599689245224
215
+ - -0.4959932267665863
216
+ scale: 1.0
217
+ visual:
218
+ path: object/073-a_lego_duplo/textured.obj
219
+ - collision:
220
+ path: object/006_mustard_bottle/collision.obj
221
+ name: mustard_bottle
222
+ pose:
223
+ position:
224
+ - 0.3909037411212921
225
+ - -0.15876904129981995
226
+ - 0.08319000899791718
227
+ quaternion:
228
+ - 0.7571060657501221
229
+ - -0.002608793554827571
230
+ - 0.00221131625585258
231
+ - -0.6532832384109497
232
+ scale: 1.0
233
+ visual:
234
+ path: object/006_mustard_bottle/textured.obj
235
+ - collision:
236
+ path: object/002_master_chef_can/collision.obj
237
+ name: master_chef_can
238
+ pose:
239
+ position:
240
+ - 0.07956720888614655
241
+ - -0.47045576572418213
242
+ - 0.05646609887480736
243
+ quaternion:
244
+ - 0.8410736322402954
245
+ - 4.7594658099114895e-06
246
+ - 3.2882962841540575e-06
247
+ - -0.5409208536148071
248
+ scale: 1.0
249
+ visual:
250
+ path: object/002_master_chef_can/textured.obj
251
+ - collision:
252
+ path: object/036_wood_block/collision.obj
253
+ name: wood_block
254
+ pose:
255
+ position:
256
+ - 0.3544745147228241
257
+ - -0.027066651731729507
258
+ - 0.09017084538936615
259
+ quaternion:
260
+ - 0.7453569769859314
261
+ - 0.003932867664843798
262
+ - -0.0007846400840207934
263
+ - 0.6666537523269653
264
+ scale: 1.0
265
+ visual:
266
+ path: object/036_wood_block/textured.obj
267
+ - collision:
268
+ path: object/012_strawberry/collision.obj
269
+ name: strawberry
270
+ pose:
271
+ position:
272
+ - 0.05693713203072548
273
+ - 0.2519106864929199
274
+ - 0.008573662489652634
275
+ quaternion:
276
+ - 0.9645155668258667
277
+ - -0.011449531652033329
278
+ - 0.029495861381292343
279
+ - -0.2621235251426697
280
+ scale: 1.0
281
+ visual:
282
+ path: object/012_strawberry/textured.obj
283
+ - collision:
284
+ path: object/072-c_toy_airplane/collision.obj
285
+ name: toy_airplane
286
+ pose:
287
+ position:
288
+ - 0.04396650940179825
289
+ - 0.4770829677581787
290
+ - 0.019499460235238075
291
+ quaternion:
292
+ - 0.7658030986785889
293
+ - 4.197125235805288e-06
294
+ - -6.158588803373277e-06
295
+ - 0.6430752873420715
296
+ scale: 1.0
297
+ visual:
298
+ path: object/072-c_toy_airplane/textured.obj
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import os
3
+
4
+ # Get the path to the envs directory
5
+ ENVS_DIR = os.path.dirname(os.path.abspath(__file__))
6
+ # Get the path to the assets directory
7
+ ASSETS_DIR = os.path.join(ENVS_DIR, "assets")
8
+
9
+ # You might also want to add specific asset paths
10
+ ROBOT_ASSETS_DIR = os.path.join(ASSETS_DIR, "robot")
11
+
12
+ # Helper function to get specific asset paths
13
+ def get_asset_path(*paths):
14
+ """
15
+ Get the full path to an asset file or directory
16
+ Args:
17
+ *paths: Path components to join with the assets directory
18
+ Returns:
19
+ str: Full path to the asset
20
+ """
21
+ return os.path.join(ASSETS_DIR, *paths)
22
+
23
+ # Export the environment classes
24
+ from . import random_obstacle_reach_env
25
+ from . import object_pick_env
26
+ # from . import scene_generator_env
27
+ from . import shelf_env
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (826 Bytes). View file
 
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/object_pick_env.cpython-310.pyc ADDED
Binary file (9.95 kB). View file
 
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/random_obstacle_reach_env.cpython-310.pyc ADDED
Binary file (12.5 kB). View file
 
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/scene_generator_env.cpython-310.pyc ADDED
Binary file (17.1 kB). View file
 
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/__pycache__/shelf_env.cpython-310.pyc ADDED
Binary file (5.67 kB). View file
 
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/ms2/__init__.py ADDED
File without changes
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/object_pick_env.py ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sapien.core as sapien
2
+ from sapien.core import Pose
3
+
4
+ import os
5
+ import numpy as np
6
+ from collections import OrderedDict
7
+ from mani_skill.utils.structs.pose import vectorize_pose
8
+ from mani_skill.utils.registration import register_env
9
+ from msx_envs.legacy.random_obstacle_reach_env import RandomObstacleReachEnv
10
+ import yaml
11
+ from msx_envs.legacy import ENVS_DIR
12
+
13
+ import trimesh
14
+ import copy
15
+
16
+
17
+ OBJECT_CONFIG_PATH = os.path.join(ENVS_DIR, "env_config")
18
+ @register_env("CustomizedPick-v0", max_episode_steps=500)
19
+ class ObjectPickEnv(RandomObstacleReachEnv):
20
+ def __init__(self, *args, object_config_path=OBJECT_CONFIG_PATH, create_obstacle_point_cloud=True, **kwargs):
21
+ # Set these attributes before calling super().__init__
22
+ self.create_obstacle_point_cloud = create_obstacle_point_cloud
23
+ self.obstacle_point_cloud = None # Initialize as None instead of empty list or array
24
+
25
+ # Get all yaml files from object_config_path
26
+ self.object_config_files = []
27
+ for file in os.listdir(object_config_path):
28
+ if file.endswith('.yaml') or file.endswith('.yml'):
29
+ self.object_config_files.append(os.path.join(object_config_path, file))
30
+
31
+ self.current_config_index = 0 # Add counter
32
+
33
+ super().__init__(*args, **kwargs)
34
+
35
+ # These can be set after super().__init__
36
+ self.goal_thresh = 0.02
37
+ self.min_goal_dist = 0.4
38
+
39
+ def get_next_object_config(self):
40
+ """Load the next object configuration file and cycle back to the beginning if at the end."""
41
+ if not self.object_config_files:
42
+ raise ValueError("No object configuration files found")
43
+
44
+ with open(self.object_config_files[self.current_config_index], 'r') as f:
45
+ config = yaml.safe_load(f)
46
+ # # print("file name: ", self.object_config_files[self.current_config_index])
47
+
48
+ self.object_path_prefix = os.path.join(ENVS_DIR, "assets")
49
+ # Update index for next time, cycling back to 0 if we reach the end
50
+ self.current_config_index = (self.current_config_index + 1) % len(self.object_config_files)
51
+
52
+ return config
53
+
54
+ def _load_actors(self):
55
+ self._add_ground(render=self.bg_name is None, altitude=-0.8)
56
+ self.goal_site = self._build_sphere_site(radius=0.01)
57
+
58
+ # Clear previous obstacles
59
+ self.obstacles = []
60
+ obstacle_points = [] # Rename for clarity
61
+ self.primary_objects_ids = []
62
+
63
+ # Create YCB objects from config first
64
+ object_configs = self.get_next_object_config()
65
+ ycb_points = self._create_ycb_objects(object_configs) # Capture returned points
66
+
67
+ # Process each obstacle configuration
68
+ for obstacle_config in self.obstacle_configs:
69
+ obstacle_type = obstacle_config.get('type', 'box')
70
+ if obstacle_type == 'box':
71
+ obstacle, points = self._create_box_obstacle(obstacle_config)
72
+ elif obstacle_type == 'sphere':
73
+ obstacle, points = self._create_sphere_obstacle(obstacle_config)
74
+ elif obstacle_type == 'mesh':
75
+ obstacle, points = self._create_mesh_obstacle(obstacle_config)
76
+ else:
77
+ raise ValueError(f"Unsupported obstacle type: {obstacle_type}")
78
+
79
+ self.obstacles.append(obstacle)
80
+ obstacle_points.append(points)
81
+
82
+ # Combine both sources of point clouds
83
+ point_cloud_sources = []
84
+ if obstacle_points:
85
+ point_cloud_sources.append(np.vstack(obstacle_points))
86
+ if ycb_points is not None:
87
+ point_cloud_sources.append(ycb_points)
88
+
89
+ if point_cloud_sources:
90
+ self.obstacle_point_cloud = np.vstack(point_cloud_sources)
91
+ else:
92
+ self.obstacle_point_cloud = np.array([])
93
+
94
+ def _create_point_cloud_from_mesh(self, mesh_path, scale, obj_config):
95
+ # Load the mesh and get the geometry if it's a scene
96
+ loaded = trimesh.load(mesh_path)
97
+ if isinstance(loaded, trimesh.Scene):
98
+ # Get the first mesh from the scene
99
+ mesh = next(iter(loaded.geometry.values()))
100
+ else:
101
+ mesh = loaded
102
+
103
+ # Scale the mesh if needed
104
+ if not np.allclose(scale, 1.0):
105
+ mesh.apply_scale(scale)
106
+ # Sample points from the mesh surface
107
+ # points, _ = trimesh.sample.sample_surface(mesh, 200) # Sample points from mesh surface
108
+ # volume = mesh.volume
109
+ bbox = mesh.bounding_box
110
+ volume = bbox.volume
111
+ n_points = max(900, int(volume * 10000))
112
+
113
+ # Sample surface points
114
+ surface_points, _ = trimesh.sample.sample_surface(mesh, n_points)
115
+ points = surface_points
116
+
117
+ # Transform points to world coordinates using object's pose
118
+ obj_pos = np.array(obj_config['pose']['position'])
119
+ obj_quat = np.array(obj_config['pose']['quaternion'])
120
+ # Create transformation matrix
121
+ transform = trimesh.transformations.quaternion_matrix(obj_quat)
122
+ transform[:3, 3] = obj_pos
123
+ # Apply transformation to points
124
+ points = trimesh.transform_points(points, transform)
125
+
126
+ ### debug for max object height
127
+ # Get the maximum z-coordinate from the transformed points
128
+ max_z = np.max(points[:, 2]) if points.size > 0 else 0
129
+ total_height = max_z # Store the maximum height of this object
130
+ self.max_object_height = max(self.max_object_height, total_height)
131
+ # # print("object height: ", total_height)
132
+ return points
133
+
134
+ def _create_ycb_objects(self, object_configs):
135
+ self.ycb_objects = {}
136
+ all_ycb_points = []
137
+ self.max_object_height = 0
138
+ for obj_config in object_configs['objects']:
139
+ builder = self._scene.create_actor_builder()
140
+
141
+ # Handle scale that can be either float or list
142
+ scale = obj_config['scale']
143
+ if isinstance(scale, (int, float)):
144
+ scale = [float(scale)] * 3
145
+
146
+ # Add visual mesh if specified
147
+ if 'visual' in obj_config:
148
+ builder.add_visual_from_file(
149
+ filename=os.path.join(self.object_path_prefix, obj_config['visual']['path']),
150
+ scale=scale
151
+ )
152
+
153
+ # Add collision mesh (required)
154
+ collision_config = obj_config['collision']
155
+ collision_path = os.path.join(self.object_path_prefix, collision_config['path'])
156
+
157
+ # Check if the path is a directory containing multiple obj files
158
+ if os.path.isdir(collision_path):
159
+ collision_paths = [os.path.join(collision_path, f) for f in os.listdir(collision_path)
160
+ if f.endswith('.obj')]
161
+ else:
162
+ collision_paths = [collision_path]
163
+
164
+ # Create point cloud using trimesh if required
165
+ if self.create_obstacle_point_cloud:
166
+ for collision_path in collision_paths:
167
+ points = self._create_point_cloud_from_mesh(collision_path, scale, obj_config)
168
+ # # print("object name: ", obj_config['name'])
169
+ # # print("object points size: ", points.shape)
170
+ all_ycb_points.append(points) # Append transformed points
171
+
172
+ ###################
173
+ for collision_path in collision_paths:
174
+ builder.add_multiple_collisions_from_file(
175
+ filename=collision_path,
176
+ scale=scale,
177
+ material=None,
178
+ density=collision_config.get('density', 1000),
179
+ )
180
+ ###################
181
+
182
+ # Build actor as static or dynamic based on config
183
+ if obj_config.get('static', True):
184
+ obj = builder.build_static(obj_config['name'])
185
+ # print(obj_config['name'], " is static")
186
+ else:
187
+ obj = builder.build(obj_config['name'])
188
+ # print(obj_config['name'], " is dynamic")
189
+
190
+ # Set pose from config
191
+ obj.set_pose(Pose(
192
+ obj_config['pose']['position'],
193
+ obj_config['pose']['quaternion']
194
+ ))
195
+
196
+ if obj.name == "table": # TODO, send this by variable
197
+ self.primary_objects_ids.append(obj.id)
198
+
199
+ # Store reference to object and its point cloud
200
+ setattr(self, f"ycb_object_{obj_config['name']}", obj)
201
+ self.ycb_objects[obj_config['name']] = {
202
+ 'actor': obj,
203
+ 'points': points,
204
+ 'position': np.array(obj_config['pose']['position']),
205
+ 'quaternion': np.array(obj_config['pose']['quaternion'])
206
+ }
207
+
208
+ # Return the point cloud instead of setting it directly
209
+ if all_ycb_points:
210
+ return np.vstack(all_ycb_points)
211
+ return None
212
+
213
+ # def _initialize_task(self, max_trials=100, verbose=False):
214
+ # initial_qpos = np.array([0.0, -0.3, 0, -np.pi*2/3, 0, np.pi / 2, np.pi / 4, 0.05, 0.05])
215
+ # joint_states = None
216
+ # # Sample a goal position far enough from robot start point
217
+ # found_valid_goal = False
218
+ # while not found_valid_goal:
219
+ # for i in range(max_trials):
220
+ # goal_x = self._episode_rng.uniform(0.2, 0.7)
221
+ # goal_y = self._episode_rng.uniform(-0.5, 0.5)
222
+ # # goal_y = -0.5 #Concept
223
+ # goal_z = self._episode_rng.uniform(0.2, 0.25)
224
+ # goal_pos = np.hstack([goal_x, goal_y, goal_z])
225
+ # if np.linalg.norm(goal_pos - self.tcp.pose.p) > self.min_goal_dist:
226
+ # if verbose:
227
+ # # print(f"Found a valid goal at {i}-th trial")
228
+ # break
229
+ # base_quat = np.array([0, 1, 0, 0]) # Your original quaternion
230
+ # #self._generate_perturbed_quaternion(base_quat)
231
+ # goal_pose = sapien.Pose(goal_pos, base_quat)
232
+ # with self.use_ee_controller() as ee_controller:
233
+ # joint_states = ee_controller.compute_ik(goal_pose,
234
+ # initial_qpos=initial_qpos)
235
+ # if joint_states is not None:
236
+ # self.goal_pos = goal_pos
237
+ # self.goal_site.set_pose(Pose(self.goal_pos))
238
+ # self.goal_rot = base_quat
239
+
240
+ # # Backup current robot qpos before testing goal pose
241
+ # current_qpos = self.agent.robot.get_qpos().copy()
242
+ # # Temporarily set agent to goal pose joint state to check collision
243
+ # joint_states = np.concatenate([joint_states, np.array([0.04, 0.04])])
244
+ # self.agent.reset(joint_states)
245
+ # self._scene.step()
246
+ # collided = self._evaluate_collided(primary_objects_ids = self.primary_objects_ids)
247
+ # # # print("!!!!!!! collision!!!!! give up goal!!!")
248
+ # if collided is None:
249
+ # found_valid_goal = True
250
+ # # print("goal_pos: ", goal_pos)
251
+ # # Restore the robot to its original position after collision check
252
+ # self.agent.reset(current_qpos)
253
+ # self._scene.step()
254
+
255
+ def _initialize_task(self, max_trials=100, verbose=False):
256
+ initial_qpos = np.array([0.0, -0.3, 0, -np.pi*2/3, 0, np.pi / 2, np.pi / 4, 0.05, 0.05])
257
+ joint_states = None
258
+ # Sample a goal position far enough from robot start point
259
+ found_valid = False
260
+ current_qpos = self.agent.robot.get_qpos().copy()
261
+
262
+ while not found_valid:
263
+ for i in range(max_trials):
264
+ goal_x = self._episode_rng.uniform(0.2, 0.7)
265
+ goal_y = self._episode_rng.uniform(-0.5, 0.5)
266
+ # goal_y = -0.5 #Concept
267
+ goal_z = self._episode_rng.uniform(0.2, 0.25)
268
+
269
+ goal_pos = np.hstack([goal_x, goal_y, goal_z])
270
+ if np.linalg.norm(goal_pos - self.tcp.pose.p) > self.min_goal_dist:
271
+ if verbose:
272
+ pass
273
+ # print(f"Found a valid goal at {i}-th trial")
274
+ break
275
+
276
+ base_quat = np.array([0, 1, 0, 0])
277
+ #self._generate_perturbed_quaternion(base_quat)
278
+ goal_pose = sapien.Pose(goal_pos, base_quat)
279
+ found_valid, joint_states = self._check_robot_pose_valid(goal_pose, initial_qpos, current_qpos)
280
+ # print("goal qpos is: ", goal_pose, "valid?", found_valid)
281
+
282
+ if found_valid:
283
+ self.goal_pos = goal_pos
284
+ self.goal_site.set_pose(Pose(self.goal_pos))
285
+ self.goal_rot = base_quat
286
+ qpos = np.concatenate([joint_states, np.array([0.04, 0.04])])
287
+ self.goal_joint_state = qpos
288
+ # print("goal qpos is: ", qpos)
289
+
290
+
291
+ def _initialize_agent(self):
292
+ """Initialize agent with uniform random joint positions."""
293
+ self.agent.set_control_mode(self._control_mode)
294
+ if self.robot_uid in ("panda", "pandasphere"):
295
+ ## IK
296
+ initial_qpos = np.array(
297
+ [1.0, -0.3, -0.29, -2.46, 0.2, 2.7, 0.11, 0.05, 0.05]
298
+ )
299
+ joint_states = None
300
+ found_valid_start = False
301
+ while not found_valid_start:
302
+ ##### RANDOM ENVIRONMENT #####
303
+ start_x = self._episode_rng.uniform(0.2, 0.5)
304
+ start_y =self._episode_rng.uniform(-0.6, 0.6)
305
+ start_z = self._episode_rng.uniform(0.2, 0.3) # for full observation
306
+
307
+ # ##### CONCEPT ENVIRONMENT #####
308
+ # if self._episode_rng.random() < 0.5:
309
+ # start_x = self._episode_rng.uniform(0.2, 0.3)
310
+ # else:
311
+ # start_x = self._episode_rng.uniform(0.5, 0.65)
312
+ # start_y = 0.55
313
+ # start_z = 0.25
314
+
315
+ start_pos = np.hstack([start_x, start_y, start_z])
316
+ # Create a sapien.Pose object using the position (keep default orientation)
317
+ start_pose = sapien.Pose(start_pos, [0, 1, 0, 0])
318
+
319
+ found_valid_start, joint_states = self._check_robot_pose_valid(start_pose, initial_qpos)
320
+ if found_valid_start:
321
+ # print("found valid start pose: ", start_pose)
322
+ qpos = np.concatenate([joint_states, np.array([0.04, 0.04])])
323
+ self.agent.reset(qpos)
324
+ break
325
+
326
+ self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
327
+ else:
328
+ raise NotImplementedError(self.robot_uid)
329
+
330
+
331
+ def _check_robot_pose_valid(self, robot_pose, initial_qpos, current_qpos = None):
332
+ # get controller and ik from agent
333
+ robot_pose_valid = False
334
+ with self.use_ee_controller() as ee_controller:
335
+ joint_states = ee_controller.compute_ik(robot_pose,
336
+ initial_qpos=initial_qpos)
337
+
338
+ if joint_states is not None:
339
+ # print("start joint states before collision checking: ", joint_states)
340
+ qpos = joint_states
341
+ qpos = np.concatenate([joint_states, np.array([0.04, 0.04])])
342
+ self.agent.reset(qpos)# warning: potential issue here, we change the joint state of the agent
343
+ self._scene.step()
344
+ collided = self._evaluate_collided(primary_objects_ids = self.primary_objects_ids)
345
+ if collided is None:
346
+ robot_pose_valid = True
347
+ # # print("start_pos: ", robot_pose)
348
+ if current_qpos is not None:
349
+ self.agent.reset(current_qpos)# change it back to the original qpos
350
+ else:
351
+ self.agent.reset(initial_qpos)# change it back to the original qpos
352
+ self._scene.step()
353
+ return (robot_pose_valid, joint_states if robot_pose_valid else None)
354
+
355
+ def _get_obs_extra(self) -> OrderedDict:
356
+ collided = self._evaluate_collided(primary_objects_ids = self.primary_objects_ids)
357
+ obs = OrderedDict(
358
+ tcp_pose=vectorize_pose(self.tcp.pose),
359
+ goal_pos=self.goal_pos,
360
+ goal_pose=np.concatenate([self.goal_pos, self.goal_rot]),
361
+ goal_qpos=self.goal_joint_state,
362
+ collision = False if collided is None else True,
363
+ )
364
+ if self._obs_mode in ["state", "state_dict"]:
365
+ obs.update(
366
+ tcp_to_goal_pos=self.goal_pos - self.tcp.pose.p,
367
+ )
368
+ if self.create_obstacle_point_cloud:
369
+ # # # print("obstacle_point_cloud is: ", self.obstacle_point_cloud.shape)
370
+ obs.update({
371
+ 'obstacle_point_cloud': self.obstacle_point_cloud
372
+ })
373
+ return obs
374
+
375
+ def evaluate(self, **kwargs):
376
+ is_obj_placed = self.check_obj_placed()
377
+ is_robot_static = self.check_robot_static()
378
+ return dict(
379
+ is_obj_placed=is_obj_placed,
380
+ is_robot_static=is_robot_static,
381
+ success=is_obj_placed and is_robot_static,
382
+ )
383
+
384
+ def _evaluate_collided(self, primary_objects_ids: list[int]):
385
+ """Acertain if the robot gripper collided with another object that is not one of the targets."""
386
+ def robot_actor_contact_info(robot_id_and_primary_object_blacklist: set[str], robot_links, contact: sapien.Contact):
387
+ for robot_link in robot_links:
388
+ # Get collision between the robot and an object that is not the robot or a primary manipulation object.
389
+ collided = (
390
+ (robot_link == contact.actor0.id or robot_link == contact.actor1.id)
391
+ and (
392
+ (contact_obj := contact.actor0).id not in robot_id_and_primary_object_blacklist
393
+ or (contact_obj := contact.actor1).id not in robot_id_and_primary_object_blacklist
394
+ )
395
+ )
396
+ # # TODO: a temporary fix for the table collision
397
+ # if robot_link == (10 or 11 or 12) and contact_obj.name == "table":
398
+ # collided = True
399
+ if collided:
400
+ # # # print("collided: ", collided, "robot_link: ", robot_link, "contact_obj: ", contact_obj.name)
401
+
402
+ return collided, robot_link, contact_obj.name
403
+ return False, None, None
404
+ # contact pairs
405
+ contacts = self._scene.get_contacts()
406
+ # blacklist of objects that the robot should not check against
407
+ blacklist = set(self.agent.robot_link_ids)
408
+ blacklist.update(primary_objects_ids)
409
+ # robot links filtering out the links that are the robot's connection with the arena floor
410
+ checked_robot_links = set([l.id for l in self.agent.robot.get_links() if "wheel" not in l.name])
411
+ for contact in contacts:
412
+ collided, robot_link, obj_id = robot_actor_contact_info(blacklist, checked_robot_links, contact)
413
+ if collided:
414
+ return f"{obj_id}:{robot_link}"
415
+ return None
416
+
417
+ def _evaluate_grasped_wrong_target(self):
418
+ """Acertain if the robot grasped an object that is not the target."""
419
+ grasped_target = self.agent.check_grasp(self._get_primary_object(), max_angle=30)
420
+ if grasped_target:
421
+ return 'target'
422
+ for obj, _ in self._placed_objects:
423
+ if obj.name != self._get_primary_object().name:
424
+ if self.agent.check_grasp(obj, max_angle=30):
425
+ return 'wrong_target'
426
+ return None
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/object_pick_env.yaml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ objects:
2
+ - name: table
3
+ visual:
4
+ path: /home/xuan/Code/maniskill2_benchmark/cfdp/envs/assets/object/table/desktable_shifted.glb
5
+ collision:
6
+ path: "/home/xuan/Code/maniskill2_benchmark/cfdp/envs/assets/object/table/desktable_shifted.obj" # same as visual in this case
7
+ scale: [2.0, 1.0, 1.5]
8
+ pose:
9
+ position: [0.4, 0, 0]
10
+ quaternion: [0, 0, 0.7071068, 0.7071068]
11
+
12
+ - name: object_banana
13
+ visual:
14
+ path: /home/xuan/Code/maniskill2_benchmark/cfdp/envs/assets/object/011_banana/textured.obj
15
+ collision:
16
+ path: /home/xuan/Code/maniskill2_benchmark/cfdp/envs/assets/object/011_banana/collision.obj
17
+ scale: [1.0, 1.0, 1.0]
18
+ pose:
19
+ position: [0.5, 0.2, 0.1]
20
+ quaternion: [1, 0, 0, 0]
21
+
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/random_obstacle_reach_env.py ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import OrderedDict
2
+
3
+ import numpy as np
4
+ import sapien.core as sapien
5
+ from sapien.core import Pose
6
+ from transforms3d.euler import euler2quat
7
+ import copy
8
+ import torch
9
+
10
+ import trimesh
11
+
12
+ from mani_skill.utils.registration import register_env
13
+ from mani_skill.envs.scenes.base_env import SceneManipulationEnv
14
+ from mani_skill.sensors.camera import CameraConfig
15
+ from mani_skill.utils.sapien_utils import (
16
+ look_at,
17
+ )
18
+ from mani_skill.utils.structs.pose import vectorize_pose
19
+ from contextlib import contextmanager
20
+
21
+ #This environment aims to collect classical motion planning data
22
+ @register_env("RandomObstacleReach-v0", max_episode_steps=200)
23
+ class RandomObstacleReachEnv(SceneManipulationEnv):
24
+ goal_thresh = 0.025
25
+ min_goal_dist = 0.3
26
+
27
+ def __init__(self, *args, obj_init_rot_z=True, obstacle_configs=None, **kwargs):
28
+ self.obj_init_rot_z = obj_init_rot_z
29
+ self.cube_half_size = np.array([0.02] * 3, np.float32)
30
+ self.obstacle_configs = obstacle_configs if obstacle_configs else []
31
+ self.obstacle_point_cloud = None
32
+ self.obstacles = []
33
+ super().__init__(*args, **kwargs)
34
+
35
+ @contextmanager
36
+ def use_ee_controller(self):
37
+ if self._control_mode != "pd_ee_target_delta_pos":
38
+ self.agent.set_control_mode("pd_ee_target_delta_pos")
39
+ ee_controller = self.agent.controller.controllers['arm']
40
+ try:
41
+ yield ee_controller
42
+ finally:
43
+ self.agent.set_control_mode(self._control_mode)
44
+
45
+ def _load_actors(self):
46
+ self._add_ground(render=self.bg_name is None)
47
+ self.goal_site = self._build_sphere_site(radius=0.01)
48
+ self.obstacle_point_cloud = None
49
+
50
+ # Clear previous obstacles
51
+ self.obstacles = []
52
+ all_points = []
53
+ if (self._episode_rng.random() < 0.1):
54
+ print("Randomly skipping obstacle generation for this episode")
55
+ return
56
+ else:
57
+ print("Generating obstacles")
58
+
59
+ # # Random chance to skip adding obstacles
60
+ # if hasattr(self, '_episode_rng'):
61
+ # # Use the environment's RNG if available
62
+ # skip_obstacles = self._episode_rng.random() < 0.3 # 30% chance to skip obstacles
63
+ # else:
64
+ # # Fallback to numpy's global RNG
65
+ # skip_obstacles = np.random.random() < 0.3
66
+
67
+ # if skip_obstacles:
68
+ # print("Randomly skipping obstacle generation for this episode")
69
+ # self.obstacle_configs = []
70
+ # Process each obstacle configuration
71
+ for obstacle_config in self.obstacle_configs:
72
+ obstacle_type = obstacle_config.get('type', 'box')
73
+ if obstacle_type == 'box':
74
+ obstacle, points = self._create_box_obstacle(obstacle_config)
75
+ elif obstacle_type == 'sphere':
76
+ obstacle, points = self._create_sphere_obstacle(obstacle_config)
77
+ elif obstacle_type == 'mesh':
78
+ obstacle, points = self._create_mesh_obstacle(obstacle_config)
79
+ else:
80
+ raise ValueError(f"Unsupported obstacle type: {obstacle_type}")
81
+
82
+ self.obstacles.append(obstacle)
83
+ all_points.append(points)
84
+
85
+ if all_points:
86
+ new_points = np.vstack(all_points)
87
+ if self.obstacle_point_cloud is None:
88
+ self.obstacle_point_cloud = new_points
89
+ else:
90
+ self.obstacle_point_cloud = np.vstack([self.obstacle_point_cloud, new_points])
91
+
92
+ def _create_box_obstacle(self, config):
93
+ obstacle = self._build_box(
94
+ half_size=config['half_size'],
95
+ color=config.get('color', (1, 0, 0)),
96
+ name=config.get('name', 'box_obstacle'),
97
+ static=True
98
+ )
99
+ obstacle.set_pose(sapien.Pose(config['pose'], [1,0,0,0]))
100
+
101
+ # Generate point cloud
102
+ box = trimesh.creation.box(np.array(config['half_size']) * 2)
103
+ points, _ = trimesh.sample.sample_surface(box, config.get('n_points', 500))
104
+ points += config['pose'][:3]
105
+
106
+ return obstacle, points
107
+
108
+ def _create_sphere_obstacle(self, config):
109
+ radius = config['radius']
110
+ builder = self._scene.create_actor_builder()
111
+ builder.add_sphere_collision(radius=radius)
112
+
113
+ material = self._renderer.create_material()
114
+ material.set_base_color(np.hstack([config.get('color', (1, 0, 0)), 1.0]))
115
+
116
+ builder.add_sphere_visual(
117
+ radius=radius,
118
+ material=material
119
+ )
120
+ obstacle = builder.build_static(config.get('name', 'sphere_obstacle'))
121
+ obstacle.set_pose(sapien.Pose(config['pose']))
122
+
123
+ # Generate point cloud
124
+ sphere = trimesh.creation.icosphere(radius=radius)
125
+ points, _ = trimesh.sample.sample_surface(sphere, config.get('n_points', 500))
126
+ points += config['pose'][:3]
127
+
128
+ return obstacle, points
129
+
130
+ def _create_mesh_obstacle(self, config):
131
+ raise NotImplementedError("create_mesh_obstacle method needs to be implemented")
132
+ mesh_path = config['mesh_path']
133
+ scale = config.get('scale', 1.0)
134
+
135
+ # Load mesh using trimesh
136
+ mesh = trimesh.load(mesh_path)
137
+ if scale != 1.0:
138
+ mesh.apply_scale(scale)
139
+
140
+ # Create SAPIEN actor
141
+ builder = self._scene.create_actor_builder()
142
+ builder.add_mesh_collision_from_file(mesh_path, scale=scale)
143
+ builder.add_visual_from_file(
144
+ mesh_path,
145
+ material=self._renderer.create_material(
146
+ base_color=np.hstack([config.get('color', (1, 0, 0)), 1.0])
147
+ ),
148
+ scale=scale
149
+ )
150
+ obstacle = builder.build_static(config.get('name', 'mesh_obstacle'))
151
+ obstacle.set_pose(sapien.Pose(config['pose']))
152
+
153
+ # Generate point cloud
154
+ points, _ = trimesh.sample.sample_surface(mesh, config.get('n_points', 500))
155
+ points += config['pose'][:3]
156
+
157
+ return obstacle, points
158
+
159
+ def _build_box(
160
+ self,
161
+ half_size,
162
+ color=(1, 0, 0),
163
+ name="box",
164
+ static=False,
165
+ render_material = None,
166
+ ):
167
+ if render_material is None:
168
+ render_material = self._renderer.create_material()
169
+ render_material.set_base_color(np.hstack([color, 1.0]))
170
+
171
+ builder = self._scene.create_actor_builder()
172
+ builder.add_box_collision(half_size=half_size)
173
+ builder.add_box_visual(half_size=half_size, material=render_material)
174
+ if static:
175
+ return builder.build_static(name)
176
+ else:
177
+ return builder.build(name)
178
+
179
+ def _generate_perturbed_quaternion(self, base_quat, max_angle_deviation=0.05):
180
+ """Generate a quaternion that's slightly different from the base quaternion.
181
+
182
+ Args:
183
+ base_quat: Base quaternion [w, x, y, z]
184
+ max_angle_deviation: Maximum angle deviation in radians (default: 0.05 ≈ 2.9 degrees)
185
+
186
+ Returns:
187
+ Perturbed quaternion as numpy array
188
+ """
189
+ # Ensure base_quat is properly formatted and normalized
190
+ if len(base_quat) != 4:
191
+ base_quat = np.array([1., 0., 0., 0.])
192
+ else:
193
+ base_quat = base_quat / np.linalg.norm(base_quat)
194
+
195
+ # Generate smaller random rotation
196
+ angle = self._episode_rng.uniform(-max_angle_deviation, max_angle_deviation)
197
+
198
+ # Generate random axis biased towards the original orientation
199
+ random_axis = self._episode_rng.normal(0, 0.1, 3) # Smaller standard deviation
200
+ random_axis = random_axis / np.linalg.norm(random_axis)
201
+
202
+ # Create quaternion for small rotation
203
+ s = np.cos(angle/2)
204
+ v = random_axis * np.sin(angle/2)
205
+ delta_quat = np.array([s, v[0], v[1], v[2]])
206
+
207
+ # Multiply quaternions (quaternion composition)
208
+ w1, x1, y1, z1 = base_quat
209
+ w2, x2, y2, z2 = delta_quat
210
+ result_quat = np.array([
211
+ w1*w2 - x1*x2 - y1*y2 - z1*z2,
212
+ w1*x2 + x1*w2 + y1*z2 - z1*y2,
213
+ w1*y2 - x1*z2 + y1*w2 + z1*x2,
214
+ w1*z2 + x1*y2 - y1*x2 + z1*w2
215
+ ])
216
+
217
+ # Normalize the resulting quaternion
218
+ return result_quat / np.linalg.norm(result_quat)
219
+
220
+ ### Shelf Initialization ###
221
+ def _initialize_agent(self):
222
+ """Initialize agent with uniform random joint positions."""
223
+ # create a ee controller and use it for ik computation
224
+ self.agent.set_control_mode(self._control_mode)
225
+ if np.random.random() < 0.5:
226
+ # set the control mode to pd_ee_pose to get IK solution
227
+ # self.agent.set_control_mode("pd_ee_target_delta_pos")
228
+ # controller = self.agent.controller.controllers['arm'] # has to be ee_controller
229
+ initial_qpos = np.array([1.0, 1.49, -1.78, -1.42, 0.50, 2.74, 1.77, 0.05, 0.05])
230
+ joint_states = None
231
+ while joint_states is None:
232
+ start_x = self._episode_rng.uniform(0.2, 0.7)
233
+ start_y = self._episode_rng.uniform(-0.5, 0.5)
234
+ start_z = self._episode_rng.uniform(0.05, 0.80)
235
+ start_pos = np.hstack([start_x, start_y, start_z])
236
+ start_pose = sapien.Pose(start_pos, [0, 1, 0, 0])
237
+ with self.use_ee_controller() as ee_controller:
238
+ joint_states = ee_controller.compute_ik(start_pose,
239
+ initial_qpos=initial_qpos)
240
+ if joint_states is not None:
241
+ qpos = joint_states
242
+ qpos = np.concatenate([qpos, np.array([0.04, 0.04])])
243
+ self.agent.reset(qpos)
244
+ self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
245
+ else:
246
+ print("Initializing agent with fixed joint positions")
247
+ qpos = np.array([0.0, 0, 0, -np.pi * 2 / 3, 0, np.pi * 2 / 3, np.pi / 4, 0.04, 0.04])
248
+ # Define noise ranges for each joint (7 joints)
249
+ joint_noise_ranges = [
250
+ (-np.pi/2, np.pi/2), # joint 1
251
+ (-np.pi/5, np.pi/5), # joint 2
252
+ (-0.01, 0.01), # joint 3
253
+ (-0.01, 0.01), # joint 4
254
+ (-0.01, 0.01), # joint 5
255
+ (-0.01, 0.01), # joint 6
256
+ (-0.01, 0.01), # joint 7
257
+ ]
258
+ # Apply random noise to each joint individually
259
+ for i, (low, high) in enumerate(joint_noise_ranges):
260
+ qpos[i] += self._episode_rng.uniform(low=low, high=high)
261
+
262
+ self.agent.reset(qpos)
263
+ self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
264
+
265
+ def _initialize_task(self, max_trials=100, verbose=False):
266
+ initial_qpos = np.array([0.20, 1.49, -1.78, -1.42, 0.50, 2.74, 1.77, 0.05, 0.05])
267
+ joint_states = None
268
+ # Sample a goal position far enough from robot start point
269
+ while joint_states is None:
270
+ for i in range(max_trials):
271
+ goal_x = self._episode_rng.uniform(0.2, 0.7)
272
+ goal_y = self._episode_rng.uniform(-0.65, 0.65)
273
+ goal_z = self._episode_rng.uniform(0.05, 0.80)
274
+ goal_pos = np.hstack([goal_x, goal_y, goal_z])
275
+ if np.linalg.norm(goal_pos - self.tcp.pose.p) > self.min_goal_dist:
276
+ if verbose:
277
+ print(f"Found a valid goal at {i}-th trial")
278
+ break
279
+ base_quat = np.array([0.5, 0.5, -0.5, 0.5]) # Your original quaternion
280
+ #self._generate_perturbed_quaternion(base_quat)
281
+ goal_pose = sapien.Pose(goal_pos, base_quat)
282
+ with self.use_ee_controller() as ee_controller:
283
+ joint_states = ee_controller.compute_ik(goal_pose,
284
+ initial_qpos=initial_qpos)
285
+ if joint_states is not None:
286
+ self.goal_pos = goal_pos
287
+ self.goal_site.set_pose(Pose(self.goal_pos))
288
+ self.goal_rot = base_quat
289
+
290
+ def _initialize_actors(self):
291
+ pass
292
+
293
+ # Normal pick and place
294
+ # def _initialize_agent(self):
295
+ # """Initialize agent with uniform random joint positions."""
296
+ # if np.random.random() < 0.5:
297
+ # original_agent_control_mode = self._control_mode # back up the original control mode
298
+ # # set the control mode to pd_ee_pose to get IK solution
299
+ # self.agent.set_control_mode("pd_ee_target_delta_pos")
300
+ # controller = self.agent.controller.controllers['arm'] # has to be ee_controller
301
+ # initial_qpos = np.array(
302
+ # [0.0, -0.1, 0, -np.pi*2/3, 0, np.pi / 2, np.pi / 4, 0.04, 0.04]
303
+ # )
304
+ # joint_states = None
305
+ # while joint_states is None:
306
+ # start_x = self._episode_rng.uniform(0.1, 0.9)
307
+ # start_y = self._episode_rng.uniform(-0.7, 0.7)
308
+ # start_z = self._episode_rng.uniform(0.1, 0.5)
309
+ # start_pos = np.hstack([start_x, start_y, start_z])
310
+ # start_pose = sapien.Pose(start_pos, [0, 1, 0, 0])
311
+ # joint_states = controller.compute_ik(start_pose,
312
+ # initial_qpos=initial_qpos)
313
+ # if joint_states is not None:
314
+ # qpos = joint_states
315
+ # qpos = np.concatenate([qpos, np.array([0.04, 0.04])])
316
+ # self.agent.reset(qpos)
317
+ # self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
318
+ # self.agent.set_control_mode(original_agent_control_mode)
319
+ # else:
320
+ # print("Initializing agent with fixed joint positions")
321
+ # qpos = np.array([0.0, 0, 0, -np.pi * 2 / 3, 0, np.pi * 2 / 3, np.pi / 4, 0.04, 0.04])
322
+ # # Define noise ranges for each joint (7 joints)
323
+ # joint_noise_ranges = [
324
+ # (-np.pi/2, np.pi/2), # joint 1
325
+ # (-np.pi/5, np.pi/5), # joint 2
326
+ # (-0.01, 0.01), # joint 3
327
+ # (-0.01, 0.01), # joint 4
328
+ # (-0.01, 0.01), # joint 5
329
+ # (-0.01, 0.01), # joint 6
330
+ # (-0.01, 0.01), # joint 7
331
+ # ]
332
+
333
+ # # Apply random noise to each joint individually
334
+ # for i, (low, high) in enumerate(joint_noise_ranges):
335
+ # qpos[i] += self._episode_rng.uniform(low=low, high=high)
336
+
337
+ # self.agent.reset(qpos)
338
+ # self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
339
+
340
+ # def _initialize_task(self, max_trials=100, verbose=False):
341
+ # original_agent_control_mode = self._control_mode # back up the original control mode
342
+ # # set the control mode to pd_ee_pose to get IK solution
343
+ # self.agent.set_control_mode("pd_ee_target_delta_pos")
344
+ # controller = self.agent.controller.controllers['arm'] # has to be ee_controller
345
+ # # initial_qpos = np.array(
346
+ # # [1.0, -0.3, -0.29, -2.46, 0.2, 2.7, 0.11, 0.05, 0.05]
347
+ # # )
348
+ # initial_qpos = np.array([0.0, -0.3, 0, -np.pi*2/3, 0, np.pi / 2, np.pi / 4, 0.05, 0.05])
349
+ # joint_states = None
350
+ # # Sample a goal position far enough from robot start point
351
+ # while joint_states is None:
352
+ # for i in range(max_trials):
353
+ # goal_x = self._episode_rng.uniform(0.1, 0.9)
354
+ # goal_y = self._episode_rng.uniform(-0.65, 0.65)
355
+ # goal_z = self._episode_rng.uniform(0.1, 0.3)
356
+ # goal_pos = np.hstack([goal_x, goal_y, goal_z])
357
+ # if np.linalg.norm(goal_pos - self.tcp.pose.p) > self.min_goal_dist:
358
+ # if verbose:
359
+ # print(f"Found a valid goal at {i}-th trial")
360
+ # break
361
+ # base_quat = np.array([0, 1, 0, 0]) # Your original quaternion
362
+ # #self._generate_perturbed_quaternion(base_quat)
363
+ # goal_pose = sapien.Pose(goal_pos, base_quat)
364
+ # joint_states = controller.compute_ik(goal_pose,
365
+ # initial_qpos=initial_qpos)
366
+ # if joint_states is not None:
367
+ # self.goal_pos = goal_pos
368
+ # self.goal_site.set_pose(Pose(self.goal_pos))
369
+ # self.goal_rot = base_quat
370
+
371
+ # self.agent.set_control_mode(original_agent_control_mode)
372
+
373
+ def _get_obs_extra(self, info) -> OrderedDict:
374
+ obs = OrderedDict(
375
+ tcp_pose=vectorize_pose(self.tcp.pose),
376
+ goal_pos=self.goal_pos,
377
+ goal_pose=np.concatenate([self.goal_pos, self.goal_rot]),
378
+ )
379
+ if self._obs_mode in ["state", "state_dict"]:
380
+ obs.update(
381
+ tcp_to_goal_pos=self.goal_pos - self.tcp.pose.p.numpy() if hasattr(self.tcp.pose.p, "numpy") else np.array(self.tcp.pose.p),
382
+ )
383
+ return obs
384
+
385
+ def check_obj_placed(self):
386
+ try:
387
+ return np.linalg.norm(self.goal_pos - self.tcp.pose.p) <= self.goal_thresh
388
+ except:
389
+ # raise RuntimeWarning("Failed to get robot tcp position")
390
+ return False
391
+
392
+ def check_robot_static(self, thresh=0.2):
393
+ # Assume that the last two DoF is gripper
394
+ qvel = self.agent.robot.get_qvel()[:-2]
395
+ if hasattr(qvel, "cpu"): # torch.Tensor
396
+ qvel = qvel.detach().cpu().numpy()
397
+ return np.max(np.abs(qvel)) <= thresh
398
+
399
+ def evaluate(self, **kwargs):
400
+ if not hasattr(self, "goal_site"):
401
+ info = dict(
402
+ is_obj_placed=False,
403
+ is_robot_static=False,
404
+ success=False,
405
+ )
406
+ else:
407
+ is_obj_placed = self.check_obj_placed()
408
+ is_robot_static = self.check_robot_static()
409
+ info = dict(
410
+ is_obj_placed=is_obj_placed,
411
+ is_robot_static=is_robot_static,
412
+ success=is_obj_placed and is_robot_static,
413
+ )
414
+ info["success"] = torch.tensor([int(info["success"])], dtype=torch.bool, device="cpu")
415
+ return info
416
+
417
+ def compute_dense_reward(self, info, **kwargs):
418
+ # well it's not a dense reward so far
419
+ reward = 0.0
420
+
421
+ if info["success"]:
422
+ reward += 5
423
+ return reward
424
+
425
+ return reward
426
+
427
+ def get_points_for_mp(self):
428
+ # return obstacle points
429
+ pass
430
+
431
+ def compute_normalized_dense_reward(self, **kwargs):
432
+ return self.compute_dense_reward(**kwargs) / 5.0
433
+
434
+ def render_human(self):
435
+ if not hasattr(self, "goal_site") or (self.goal_site is None):
436
+ return super().render_human()
437
+ self.goal_site.unhide_visual()
438
+ ret = super().render_human()
439
+ self.goal_site.hide_visual()
440
+ return ret
441
+
442
+ def render_rgb_array(self):
443
+ self.goal_site.unhide_visual()
444
+ ret = super().render_rgb_array()
445
+ self.goal_site.hide_visual()
446
+ return ret
447
+
448
+ def get_state(self) -> np.ndarray:
449
+ state = super().get_state()
450
+ return np.hstack([state, self.goal_pos])
451
+
452
+ def set_state(self, state):
453
+ self.goal_pos = state[-3:]
454
+ super().set_state(state[:-3])
455
+
456
+ def _register_cameras(self):
457
+ pose = look_at([1.3, 0.4, 0.8], [0.0, 0, 0.1])
458
+ return CameraConfig(
459
+ "base_camera", pose.p, pose.q, 128, 128, np.pi / 2, 0.01, 10
460
+ )
461
+
462
+ def _register_render_cameras(self):
463
+ if self.robot_uid in ("panda", "pandasphere"):
464
+ # pose = look_at([1.3, 0.4, 0.8], [0.0, 0.0, 0.4])
465
+ pose = look_at([2.0, 0.5, 0.6], [0, -0.1, 0.2])
466
+ else:
467
+ pose = look_at([0.5, 0.5, 1.0], [0.0, 0.0, 0.5])
468
+ return CameraConfig("render_camera", pose.p, pose.q, 1024, 1024, 1, 0.01, 15)
469
+
470
+ def _setup_viewer(self):
471
+ super()._setup_viewer()
472
+ self._viewer.set_camera_xyz(1.3, 0, 1.0)
473
+ self._viewer.set_camera_rpy(0, -0.5, 3.14)
474
+
475
+ def _build_sphere_site(self, radius, color=(0, 1, 0), name="goal_site"):
476
+ """Build a sphere site (visual only). Used to indicate goal position."""
477
+ builder = self.scene.create_actor_builder()
478
+ builder.add_sphere_visual(radius=radius, material=sapien.render.RenderMaterial(base_color=[0.8, 0.4, 0.3, 0.5]))
479
+ sphere = builder.build_static(name)
480
+ return sphere
481
+
482
+
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/scene_generator_env.py ADDED
@@ -0,0 +1,583 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections import defaultdict
2
+ from functools import partial
3
+ import os
4
+ import pathlib
5
+ from typing import Callable, Final, Literal
6
+
7
+
8
+ import numpy as np
9
+ import json
10
+ import sapien.core as sapien
11
+ from transforms3d.euler import euler2quat
12
+ from sapien.core import Pose
13
+ from transforms3d.quaternions import qmult
14
+
15
+ import yaml
16
+ from mani_skill2 import format_path
17
+ from mani_skill2.envs.sapien_env import BaseEnv
18
+ from mani_skill2.utils.io_utils import load_json
19
+ from mani_skill2.utils.geometry import get_axis_aligned_bbox_for_actor
20
+ from mani_skill2.utils.registration import register_env
21
+ from mani_skill2.sensors.camera import CameraConfig
22
+ from mani_skill2.utils.sapien_utils import (
23
+ look_at,
24
+ vectorize_pose,
25
+ )
26
+ from cfdp.utils.object_placement import PlacementBounds, ObjectBoundingBox, find_valid_position_2d
27
+
28
+
29
+ from cfdp.envs import assets
30
+ from cfdp.envs.random_obstacle_reach_env import RandomObstacleReachEnv
31
+
32
+
33
+ OUT_OF_BOUNDS: Final = np.array([0, 0, -900])
34
+ OBJECTS_KEY = 'objects'
35
+
36
+ @register_env(
37
+ "SceneGenerator-v0",
38
+ max_episode_steps=1,
39
+ )
40
+ class SceneGeneratorEnv(RandomObstacleReachEnv):
41
+ """This environment generates actors at runtime and outputs the new scene to a YAML config.
42
+
43
+ This config can be retrieved in info['gen_scene'] on reset.
44
+ """
45
+ def __init__(
46
+ self,
47
+ *args,
48
+ distractor_count: int,
49
+ object_place_bounds: tuple[tuple[float, float], tuple[float, float], tuple[float]] | None = None,
50
+ asset_root=str(pathlib.Path(assets.__file__).parent),
51
+ base_object_config_path: str | pathlib.Path,
52
+ model_config="asset_tables.yaml",
53
+ scene_config_serialization_mode: Literal["yaml", "json", "dict"] = "yaml",
54
+ distractor_rotation_axes: tuple[bool, bool, bool] = (False, False, True),
55
+ minimum_object_aabb_separation=0.05, # this can be below 0
56
+ table_scale: list[float, float] = [1.0, 1.0],
57
+ **kwargs
58
+
59
+ ):
60
+ self.asset_root = asset_root
61
+ self.model_configs = model_config
62
+ self.base_scene_config_path=base_object_config_path
63
+ self.table_scale = table_scale
64
+
65
+ model_db_path = self._get_asset_path(self.model_configs)
66
+ # Load object configurations before calling parent's __init__
67
+ with open(model_db_path, 'r') as f:
68
+ self.model_db = yaml.safe_load(f)
69
+
70
+ object_config_path = self._get_asset_path(self.base_scene_config_path)
71
+
72
+ # Load object configurations before calling parent's __init__
73
+ with open(object_config_path, 'r') as f:
74
+ self.base_object_configs = yaml.safe_load(f)
75
+ self.base_object_configs[OBJECTS_KEY] = _key_hierarchy_dict(self.base_object_configs[OBJECTS_KEY])
76
+
77
+ self._initial_actor_states = {}
78
+ self._distractor_count = distractor_count
79
+ self._object_place_bounds = object_place_bounds
80
+ self._minimum_object_aabb_separation = minimum_object_aabb_separation
81
+
82
+ self.scene_serializer_func: Callable[[str], dict]
83
+ if scene_config_serialization_mode == "json":
84
+ self.scene_serializer_func = partial(
85
+ json.dumps,
86
+ allow_nan=False,
87
+ )
88
+ elif scene_config_serialization_mode == "yaml":
89
+ self.scene_serializer_func = partial(
90
+ yaml.dump,
91
+ encoding='utf-8',
92
+ allow_unicode=True,
93
+ # sort_keys=False,
94
+ # default_flow_style=None,
95
+ # indent=4,
96
+ # width=120,
97
+ )
98
+ elif scene_config_serialization_mode == "dict":
99
+ # Just passthrough
100
+ self.scene_serializer_func = lambda d: d
101
+ else:
102
+ raise ValueError("Invalid serialization mode. Choose from 'json', 'yaml', or 'dict'")
103
+
104
+ self.new_distractors = []
105
+ self._generated_object_configs = {
106
+ OBJECTS_KEY: defaultdict(dict),
107
+ }
108
+ self._generated_object_configs[OBJECTS_KEY].update(self.base_object_configs[OBJECTS_KEY])
109
+
110
+ self.ycb_objects: dict[str, sapien.Actor] = {}
111
+ self.obstacle_actors: dict[str, sapien.Actor] = {}
112
+ self.distractor_rotation_axes = distractor_rotation_axes
113
+
114
+ super().__init__(*args, **kwargs)
115
+ self.goal_thresh = 0.01
116
+ self.min_goal_dist = 0.2
117
+
118
+ def _get_asset_path(self, asset):
119
+ resolved_asset = format_path(asset)
120
+ return (
121
+ str(pathlib.Path(self.asset_root) / resolved_asset)
122
+ if not os.path.isabs(asset)
123
+ else resolved_asset
124
+ )
125
+
126
+ def _settle(self, t):
127
+ # step the simulation and let the scene settle for t seconds
128
+ settle(self, t)
129
+
130
+ def _load_actors(self):
131
+ """Load actors only, state is set later in _initialize()."""
132
+ self._add_ground(render=self.bg_name is None, altitude=-0.8)
133
+ self.goal_site = self._build_sphere_site(radius=0.01)
134
+
135
+ # Clear previous obstacles
136
+ self.obstacles = []
137
+ all_points = []
138
+
139
+ self._load_base_scene_actors()
140
+ self._load_new_obstacles()
141
+ self._load_new_ycb_distractors()
142
+
143
+ # Process each obstacle configuration
144
+ for obstacle_config in self.obstacle_configs:
145
+ obstacle_type = obstacle_config.get('type', 'box')
146
+ if obstacle_type == 'box':
147
+ obstacle, points = self._create_box_obstacle(obstacle_config)
148
+ elif obstacle_type == 'sphere':
149
+ obstacle, points = self._create_sphere_obstacle(obstacle_config)
150
+ elif obstacle_type == 'mesh':
151
+ obstacle, points = self._create_mesh_obstacle(obstacle_config)
152
+ else:
153
+ raise ValueError(f"Unsupported obstacle type: {obstacle_type}")
154
+
155
+ self.obstacles.append(obstacle)
156
+ all_points.append(points)
157
+
158
+ if all_points:
159
+ self.obstacle_point_cloud = np.vstack(all_points)
160
+
161
+ def _initialize_actors(self):
162
+ """Initialize the actor state."""
163
+ super()._initialize_actors()
164
+
165
+ self._initialize_base_scene_actors()
166
+ if self._object_place_bounds is None:
167
+ # self._discover_table_bounds()
168
+ self._scale_table_bounds(scales=self.table_scale)
169
+ self._initialize_new_scene_actors()
170
+
171
+ def _discover_table_bounds(self):
172
+ """Discover the bounds of the table."""
173
+ bbox_min, bbox_max = get_axis_aligned_bbox_for_actor(self.ycb_objects['table'])
174
+ self._object_place_bounds = [bbox_min[:2].tolist(), bbox_max[:2].tolist(), [2]]
175
+
176
+ def _scale_table_bounds(self, scales: list[float] = [1.0, 1.0]):
177
+ """Scale the table bounds by the given factors.
178
+
179
+ Args:
180
+ scales: Scale factors [scale_x, scale_y] for x and y dimensions
181
+ """
182
+ scale_x, scale_y = scales
183
+ bbox_min, bbox_max = get_axis_aligned_bbox_for_actor(self.ycb_objects['table'])
184
+ center_x = (bbox_max[0] + bbox_min[0]) / 2
185
+ center_y = (bbox_max[1] + bbox_min[1]) / 2
186
+
187
+ half_width = (bbox_max[0] - bbox_min[0]) / 2
188
+ half_length = (bbox_max[1] - bbox_min[1]) / 2
189
+
190
+ scaled_min = [
191
+ center_x - half_width * scale_x,
192
+ center_y - half_length * scale_y
193
+ ]
194
+ scaled_max = [
195
+ center_x + half_width * scale_x,
196
+ center_y + half_length * scale_y
197
+ ]
198
+
199
+ self._object_place_bounds = [scaled_min, scaled_max, [2]]
200
+
201
+ def _set_env_ycb_obj_attr(self, name, obj):
202
+ setattr(self, f"ycb_object_{name}", obj)
203
+ self.ycb_objects[name] = obj
204
+
205
+ def _set_env_obstacle_obj_attr(self, name, obj):
206
+ setattr(self, f"obstacle_object_{name}", obj)
207
+ self.obstacle_actors[name] = obj
208
+
209
+ def _load_actor_helper(self,
210
+ scene: sapien.Scene,
211
+ scale: float | tuple[float, float, float] | None = None,
212
+ physical_material: sapien.PhysicalMaterial = None,
213
+ density: float | None = None,
214
+ visual_mesh_path: str | None = None,
215
+ collision_mesh_path: str | None = None,
216
+ ):
217
+ """Load an actor from a model ID."""
218
+ builder = scene.create_actor_builder()
219
+
220
+ if isinstance(scale, (int, float)):
221
+ scale = (scale, scale, scale)
222
+
223
+ if visual_mesh_path is not None:
224
+ obj_visual_path = self._get_asset_path(visual_mesh_path)
225
+ builder.add_visual_from_file(
226
+ filename=obj_visual_path,
227
+ scale=scale
228
+ )
229
+
230
+ obj_collision_path = self._get_asset_path(collision_mesh_path)
231
+ builder.add_multiple_collisions_from_file(
232
+ filename=obj_collision_path,
233
+ scale=scale,
234
+ material=physical_material,
235
+ density=density or 1000,
236
+ )
237
+
238
+ return builder
239
+
240
+ def _load_base_scene_actors(self):
241
+ for name, obj_config in self.base_object_configs[OBJECTS_KEY].items():
242
+ builder = self._load_actor_helper(
243
+ scene=self._scene,
244
+ scale = obj_config.get('scale', [1.0]*3),
245
+ visual_mesh_path=obj_config.get('visual', {}).get('path'),
246
+ collision_mesh_path = obj_config.get('collision', {}).get('path'),
247
+ )
248
+ # Build actor as static or dynamic based on config
249
+ if obj_config.get('static', True):
250
+ obj = builder.build_static(name)
251
+ else:
252
+ obj = builder.build(name)
253
+
254
+ # Set these object somewhere far away
255
+ # obj.set_pose(sapien.Pose(OUT_OF_BOUNDS))
256
+ self._set_env_ycb_obj_attr(name, obj)
257
+
258
+ def _load_new_ycb_distractors(self):
259
+ ycb_asset_table = self.model_db['ycb']
260
+ model_keys = list(ycb_asset_table.keys())
261
+ self.new_distractors = [
262
+ str(s)
263
+ for s
264
+ in self._episode_rng.choice(
265
+ model_keys,
266
+ self._distractor_count,
267
+ replace=False
268
+ )
269
+ ]
270
+
271
+ for name in self.new_distractors:
272
+ scale=ycb_asset_table[name].get('scale', 1.0)
273
+ visual_mesh_path=ycb_asset_table[name].get('visual_mesh_path')
274
+ collision_mesh_path=ycb_asset_table[name].get('collision_mesh_path')
275
+ builder = self._load_actor_helper(
276
+ scene=self._scene,
277
+ scale=scale,
278
+ visual_mesh_path=visual_mesh_path,
279
+ collision_mesh_path=collision_mesh_path,
280
+ )
281
+ obj = builder.build(name)
282
+ # Set these object somewhere far away
283
+ # obj.set_pose(sapien.Pose(OUT_OF_BOUNDS))
284
+ self._set_env_ycb_obj_attr(name, obj)
285
+
286
+ self._generated_object_configs[OBJECTS_KEY][name].update(
287
+ {
288
+ 'visual': {
289
+ 'path': visual_mesh_path,
290
+ },
291
+ 'collision': {
292
+ 'path': collision_mesh_path,
293
+ },
294
+ 'scale': scale,
295
+ }
296
+ )
297
+
298
+ def _load_new_obstacles(self):
299
+ obstacle_asset_table = self.model_db['obstacles']
300
+ if obstacle_asset_table is None:
301
+ self.new_obstacles = []
302
+ return
303
+ model_keys = list(obstacle_asset_table.keys())
304
+ self.new_obstacles = [str(s) for s in model_keys]
305
+
306
+ for name in self.new_obstacles:
307
+ # scale = [np.random.uniform(low=0.4, high=0.6),
308
+ # np.random.uniform(low=0.4, high=0.7),
309
+ # np.random.uniform(low=0.6, high=1.1)]
310
+ scale = [np.random.uniform(low=0.3, high=0.5),
311
+ np.random.uniform(low=0.4, high=0.6),
312
+ np.random.uniform(low=0.4, high=0.9)]
313
+ print("scale: ", scale)
314
+ scale=obstacle_asset_table[name].get('scale', scale)
315
+ visual_mesh_path=obstacle_asset_table[name].get('visual_mesh_path')
316
+ collision_mesh_path=obstacle_asset_table[name].get('collision_mesh_path')
317
+ builder = self._load_actor_helper(
318
+ scene=self._scene,
319
+ scale=scale,
320
+ visual_mesh_path=visual_mesh_path,
321
+ collision_mesh_path=collision_mesh_path,
322
+ )
323
+ obj = builder.build(name)
324
+ # Set these object somewhere far away
325
+ # obj.set_pose(sapien.Pose(OUT_OF_BOUNDS))
326
+ # self._set_env_ycb_obj_attr(name, obj)
327
+ self._set_env_obstacle_obj_attr(name, obj)
328
+
329
+ self._generated_object_configs[OBJECTS_KEY][name].update(
330
+ {
331
+ 'visual': {
332
+ 'path': visual_mesh_path,
333
+ },
334
+ 'collision': {
335
+ 'path': collision_mesh_path,
336
+ },
337
+ 'scale': scale,
338
+ }
339
+ )
340
+
341
+ def _initialize_base_scene_actors(self):
342
+ actors = {a.name: a for a in self.get_actors()}
343
+
344
+ for name, obj_config in self.base_object_configs[OBJECTS_KEY].items():
345
+ obj = actors.get(name)
346
+ assert isinstance(obj, (sapien.Actor, sapien.ActorStatic))
347
+ obj.set_pose(sapien.Pose(
348
+ obj_config['pose']['position'],
349
+ obj_config['pose']['quaternion']
350
+ ))
351
+
352
+ def _initialize_new_scene_actors(self):
353
+ """Set the initial state of the newly generated objects."""
354
+ assert self._object_place_bounds is not None, f"Table bounds must be initialized."
355
+ placed_objects = [
356
+ (actor, ObjectBoundingBox(*(local_bbox_for_actor(actor=actor))))
357
+ for actor
358
+ in [self.ycb_objects[actor_name] for actor_name in self.base_object_configs[OBJECTS_KEY] if actor_name != 'table']
359
+ ]
360
+ placement_bounds=PlacementBounds(*self._object_place_bounds)
361
+
362
+ for actor_name in self.new_distractors:
363
+ actor = self.ycb_objects[actor_name]
364
+ actor.set_pose(sapien.Pose([100, 100, -50]))
365
+
366
+
367
+ placed_obstacles = [(actor, ObjectBoundingBox(*(local_bbox_for_actor(actor=actor)))) for actor in self.obstacle_actors.values()]
368
+ for obs_actor_name in self.new_obstacles:
369
+ obs_actor = self.obstacle_actors[obs_actor_name]
370
+ # Generate random yaw angle between -30 and 30 degrees
371
+ yaw = self._episode_rng.uniform(-np.pi/4, np.pi/4)
372
+ # Create quaternion with only yaw rotation
373
+ quat = euler2quat(0, 0, yaw)
374
+ obs_actor.set_pose(sapien.Pose(obs_actor.pose.p, quat))
375
+ bb_min, bb_max = local_bbox_for_actor(actor=obs_actor)
376
+ bbox = ObjectBoundingBox(bb_min, bb_max)
377
+ success = False
378
+ while not success:
379
+ valid_position_2d = find_valid_position_2d(
380
+ placement_bounds=placement_bounds,
381
+ actor=obs_actor,
382
+ actor_local_bbox=bbox,
383
+ placed_objects=placed_obstacles,
384
+ rng=self._episode_rng,
385
+ retries=5000, # worst case
386
+ # minimum_aabb_separation=self._minimum_object_aabb_separation,
387
+ minimum_aabb_separation=0.03,
388
+ )
389
+ z = (- bb_min[2])
390
+ valid_position = np.hstack([valid_position_2d, z])
391
+ print(f"Valid position1: {valid_position}")
392
+ obs_actor.set_pose(sapien.Pose(valid_position, quat))
393
+ self._settle_distractor(distractor_obj=obs_actor, motion_lock_axes=(1, 1, 0, 1, 1, 1))
394
+ if obs_actor.pose.p[2] > 0 and obs_actor.pose.p[2] < 0.4: # if z is unnormal resample it
395
+ success = True
396
+
397
+ for actor_name in self.new_distractors:
398
+ actor = self.ycb_objects[actor_name]
399
+ euler = np.random.uniform(low=-np.pi/2, high=np.pi/2, size=(3,))
400
+ euler = np.multiply(euler, np.array(self.distractor_rotation_axes, dtype=np.int8))
401
+ quat = euler2quat(*euler)
402
+ actor.set_pose(sapien.Pose(actor.pose.p, quat))
403
+ bb_min, bb_max = local_bbox_for_actor(actor=actor)
404
+ bbox = ObjectBoundingBox(bb_min, bb_max)
405
+ valid_position_2d = find_valid_position_2d(
406
+ placement_bounds=placement_bounds,
407
+ actor=actor,
408
+ actor_local_bbox=bbox,
409
+ placed_objects=placed_objects,
410
+ rng=self._episode_rng,
411
+ retries=1000, # worst case
412
+ minimum_aabb_separation=self._minimum_object_aabb_separation,
413
+ )
414
+ ground_level = 0
415
+ # Move up by the min z of the bounding box
416
+ z = ground_level + (- bb_min[2])
417
+ # just be lazy and give a little more height
418
+ z += 0.05
419
+ # If there is less than 0 separation we may want objects to be more likely to stack
420
+ if self._minimum_object_aabb_separation < 0:
421
+ z += 0.3
422
+ # valid_position = self._find_valid_position(placed_objects, distractor_model_id, distractor_model_scale, self._distractor_pos_random, retries=100000)
423
+ if valid_position_2d is None:
424
+ print(f"Warning: Default to placing randomly. Could not find a valid position for distractor {actor_name} after maximum attempts.")
425
+ valid_position_2d = placement_bounds.random_in(rng=self._episode_rng)
426
+ ## HACK: add extra height to hopefully stack up
427
+ z += 0.3
428
+ valid_position = np.hstack([valid_position_2d, z])
429
+ # Find a valid position
430
+ actor.set_pose(sapien.Pose(valid_position, actor.pose.q))
431
+ self._settle_distractor(distractor_obj=actor)
432
+
433
+ # get updated AABB
434
+ final_bbox = ObjectBoundingBox(*(local_bbox_for_actor(actor=actor)))
435
+ placed_objects = placed_objects + [(actor, final_bbox)]
436
+
437
+ # Unlock motion
438
+ for actor_name, actor in self.ycb_objects.items():
439
+ if isinstance(actor, sapien.ActorStatic):
440
+ continue
441
+ actor.lock_motion(0, 0, 0, 0, 0, 0)
442
+ actor.set_velocity(np.zeros(3))
443
+ actor.set_angular_velocity(np.zeros(3))
444
+ self._settle(0.5)
445
+
446
+ lin_vel, ang_vel = 0.0, 0.0
447
+ for actor_name, actor in self.ycb_objects.items():
448
+ if isinstance(actor, sapien.ActorStatic):
449
+ continue
450
+ lin_vel += np.linalg.norm(actor.velocity)
451
+ ang_vel += np.linalg.norm(actor.angular_velocity)
452
+ if lin_vel > 1e-3 or ang_vel > 1e-2:
453
+ self._settle(1.5)
454
+
455
+ for obs_actor_name in self.new_obstacles:
456
+ obs_actor = self.obstacle_actors[obs_actor_name]
457
+ print("pose at the end: ", obs_actor.pose)
458
+
459
+
460
+ def _serialize_actors(self) -> dict:
461
+ """Serialize the actors to a hierarchy.
462
+
463
+ This is useful for saving and loading the scene state. Example:
464
+ ```yaml
465
+ # yaml
466
+ objects:
467
+ - name: table
468
+ visual:
469
+ path: object/table/desktable.glb
470
+ collision:
471
+ path: "object/table/desktable.obj" # same as visual in this case
472
+ scale: [2.0, 1.0, 1.5]
473
+ pose:
474
+ position: [0.4, 0, -0.75]
475
+ quaternion: [0, 0, 0.7071068, 0.7071068]
476
+ ```
477
+ """
478
+ actors_dict = self._generated_object_configs.copy()
479
+ for actor_name, actor in self.ycb_objects.items():
480
+ actors_dict[OBJECTS_KEY][actor_name].update({
481
+
482
+ 'pose': {
483
+ 'position': actor.pose.p.tolist(),
484
+ 'quaternion': actor.pose.q.tolist(),
485
+ }
486
+ })
487
+
488
+ for obstacle_name, obstacle in self.obstacle_actors.items():
489
+ actors_dict[OBJECTS_KEY][obstacle_name].update({
490
+ 'pose': {
491
+ 'position': obstacle.pose.p.tolist(),
492
+ 'quaternion': obstacle.pose.q.tolist(),
493
+ }
494
+ })
495
+ # convert back to list version
496
+ actors_dict[OBJECTS_KEY] = _list_hierarchy_dict(actors_dict[OBJECTS_KEY])
497
+
498
+ return self.scene_serializer_func(actors_dict)
499
+
500
+
501
+ def reset(self, seed=None, options=None):
502
+ obs, info = super().reset(seed, options)
503
+ info['scene_config'] = self._serialize_actors()
504
+ return obs, info
505
+
506
+ def _settle_distractor(
507
+ self,
508
+ distractor_obj: sapien.Actor,
509
+ motion_lock_axes=(1, 1, 0, 0, 0, 0),
510
+ ):
511
+ return settle_distractor(
512
+ env=self,
513
+ distractor_obj=distractor_obj,
514
+ t=0.5,
515
+ drop_height=0.5,
516
+ unlock_at_end=False,
517
+ motion_lock_axes=motion_lock_axes,
518
+ )
519
+
520
+ def _initialize_agent(self):
521
+ """Higher EE pos."""
522
+ qpos = np.array(
523
+ [0.0, 0, 0, -np.pi * 2 / 3, 0, np.pi * 2 / 3, np.pi / 4, 0.04, 0.04]
524
+ )
525
+ # fmt: on
526
+ qpos[:-2] += self._episode_rng.normal(
527
+ 0, self.robot_init_qpos_noise, len(qpos) - 2
528
+ )
529
+ self.agent.reset(qpos)
530
+ self.agent.robot.set_pose(Pose([0, 0, 0]))
531
+ #make the robot invisible
532
+ for actor in self.agent.robot.get_links():
533
+ actor.hide_visual()
534
+
535
+ def _register_render_cameras(self):
536
+ if self.robot_uid == "panda":
537
+ # pose = look_at([1.3, 0.4, 0.8], [0.0, 0.0, 0.4])
538
+ # pose = look_at([-0.2, 0.0, 1.5], [0.4, 0.0, 0.0])# Top-down view
539
+ pose = look_at([2.0, 0.5, 0.6], [0, -0.1, 0.2]) #side view
540
+ return CameraConfig("render_camera", pose.p, pose.q, 1024, 1024, 1, 0.01, 10)
541
+
542
+ def _list_hierarchy_dict(dict_obj: dict):
543
+ return [{'name': k, **v} for k, v in dict_obj.items() if isinstance(v, dict)]
544
+
545
+ def _key_hierarchy_dict(list_obj: list, on_key: str = 'name'):
546
+ return {v[on_key]: v for v in list_obj if v.get(on_key) is not None}
547
+
548
+
549
+ def settle_distractor(
550
+ env: BaseEnv,
551
+ distractor_obj: sapien.Actor,
552
+ t: float,
553
+ drop_height: float = 0.5,
554
+ unlock_at_end: bool = False,
555
+ motion_lock_axes: tuple[int, int, int, int, int, int] = (1, 1, 0, 1, 1, 0),
556
+ up: np.ndarray = np.array([0., 0., 1.]),
557
+ ):
558
+ drop = up * drop_height
559
+ distractor_obj.set_pose(sapien.Pose(distractor_obj.pose.p + drop, distractor_obj.pose.q))
560
+ distractor_obj.set_velocity(np.zeros(3))
561
+ distractor_obj.set_angular_velocity(np.zeros(3))
562
+ # Lock x and y and pitch and roll
563
+ assert len(motion_lock_axes) == 6, f"`{motion_lock_axes=}` must be a tuple of length 6"
564
+ distractor_obj.lock_motion(*motion_lock_axes)
565
+
566
+ # Let distractor objects fall onto the table
567
+ settle(env, t)
568
+
569
+ if unlock_at_end:
570
+ distractor_obj.lock_motion(*[0]*6)
571
+
572
+
573
+ def settle(env: BaseEnv, t):
574
+ # step the simulation and let the scene settle for t seconds
575
+ sim_steps = int(env.sim_freq * t)
576
+ for _ in range(sim_steps):
577
+ env._scene.step()
578
+
579
+ def local_bbox_for_actor(actor: sapien.Actor) -> tuple[np.ndarray, np.ndarray]:
580
+ mins, maxs = get_axis_aligned_bbox_for_actor(actor)
581
+ mins -= actor.pose.p
582
+ maxs -= actor.pose.p
583
+ return mins, maxs
project/ManiSkill3/src/maniskill2_benchmark/msx_envs/msx_envs/legacy/shelf_env.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sapien.core as sapien
2
+ from sapien.core import Pose
3
+
4
+ import os
5
+ import numpy as np
6
+ from collections import OrderedDict
7
+ from mani_skill.utils.structs.pose import vectorize_pose
8
+ from mani_skill.utils.registration import register_env
9
+ from msx_envs.legacy.object_pick_env import ObjectPickEnv
10
+ import yaml
11
+ from msx_envs.legacy import ENVS_DIR
12
+
13
+ import trimesh
14
+ import copy
15
+
16
+ OBJECT_CONFIG_PATH = os.path.join(ENVS_DIR, "env_config")
17
+ @register_env("ShelfPick-v0", max_episode_steps=500)
18
+ class ShelfPickEnv(ObjectPickEnv):
19
+ def __init__(self, *args, object_config_path=OBJECT_CONFIG_PATH, create_obstacle_point_cloud=True, is_demo = False, **kwargs):
20
+
21
+ # Call super().__init__ after setting necessary attributes
22
+ self.is_demo = is_demo # set spefic start pose for demo, this variable is not existed in init function, but it calls initialze_episode
23
+ super().__init__(*args, object_config_path=object_config_path, create_obstacle_point_cloud=create_obstacle_point_cloud,**kwargs)
24
+
25
+ # These can be set after super().__init__
26
+ self.goal_thresh = 0.02
27
+ self.min_goal_dist = 0.4
28
+
29
+ def obtain_collision_spheres(self):
30
+ """Extract collision sphere information from all robot links.
31
+
32
+ This method is a wrapper around the agent's obtain_collision_spheres method,
33
+ which returns a dictionary of collision spheres for each link in the robot.
34
+
35
+ Returns:
36
+ dict: A dictionary mapping link names to lists of (position, radius) tuples,
37
+ where position is the global 3D coordinates and radius is in meters.
38
+ Format: {'link_name': [(np.array([x, y, z]), radius), ...]}
39
+ """
40
+ return self.agent.obtain_collision_spheres()
41
+
42
+ def _initialize_task(self, max_trials=100, verbose=False):
43
+ initial_qpos = np.array([0.20, 1.49, -1.78, -1.42, 0.50, 2.74, 1.77, 0.05, 0.05])
44
+ joint_states = None
45
+ # Sample a goal position far enough from robot start point
46
+ found_valid = False
47
+ current_qpos = self.agent.robot.get_qpos().copy()
48
+
49
+ if self.is_demo:
50
+ goal_x = self._episode_rng.uniform(0.45, 0.55)
51
+ goal_y = self._episode_rng.uniform(-0.4, -0.5)
52
+ goal_z = self._episode_rng.uniform(0.3, 0.4)
53
+ goal_pos = np.hstack([goal_x, goal_y, goal_z])
54
+ base_quat = np.array([0.5, 0.5, -0.5, 0.5])
55
+ goal_pose = sapien.Pose(goal_pos, base_quat)
56
+
57
+ # Check if this is a valid starting position
58
+ found_valid, joint_states = self._check_robot_pose_valid(goal_pose, initial_qpos, current_qpos)
59
+
60
+ print(f"Valid task goal pose {goal_pose} joint_states: {joint_states}")
61
+
62
+ while not found_valid:
63
+ for i in range(max_trials):
64
+ ##### Shelf Environment #####
65
+ goal_x = self._episode_rng.uniform(0.4, 0.6)
66
+ goal_y = self._episode_rng.uniform(-0.5, -0.55)
67
+ goal_z = self._episode_rng.uniform(0.4, 0.6)
68
+
69
+ goal_pos = np.hstack([goal_x, goal_y, goal_z])
70
+ if np.linalg.norm(goal_pos - self.tcp.pose.p) > self.min_goal_dist:
71
+ if verbose:
72
+ print(f"Found a valid goal at {i}-th trial")
73
+ break
74
+
75
+ base_quat = np.array([0.5, 0.5, -0.5, 0.5])
76
+ #self._generate_perturbed_quaternion(base_quat)
77
+ goal_pose = sapien.Pose(goal_pos, base_quat)
78
+ found_valid, joint_states = self._check_robot_pose_valid(goal_pose, initial_qpos, current_qpos)
79
+ print("goal qpos is: ", goal_pose, "valid?", found_valid)
80
+
81
+ if found_valid:
82
+ self.goal_pos = goal_pos
83
+ self.goal_site.set_pose(Pose(self.goal_pos))
84
+ self.goal_rot = base_quat
85
+ qpos = np.concatenate([joint_states, np.array([0.04, 0.04])])
86
+ self.goal_joint_state = qpos
87
+ print("goal qpos is: ", qpos)
88
+
89
+
90
+ def _initialize_agent(self):
91
+ # create a ee controller and use it for ik computation
92
+ self.agent.set_control_mode(self._control_mode)
93
+ initial_qpos = np.array(
94
+ [1.0, 1.49, -1.78, -1.42, 0.50, 2.74, 1.77, 0.05, 0.05]
95
+ )
96
+
97
+ found_valid = False
98
+ if self.is_demo:
99
+ # In demo mode, position the robot above the Rubik's cube for grasping
100
+ for obj_name, obj_config in self.ycb_objects.items():
101
+ if obj_name == "rubiks_cube":
102
+ # Get the cube's position and orientation
103
+ obj_position = obj_config['position']
104
+ obj_quaternion = obj_config['quaternion']
105
+
106
+ # Position the robot above the cube with matching orientation
107
+ start_position = obj_position.copy()
108
+ start_position[2] += 0.15
109
+ start_pose = sapien.Pose(start_position, [0, 1, 0, 0])
110
+
111
+ # Check if this is a valid starting position
112
+ found_valid, joint_states = self._check_robot_pose_valid(start_pose, initial_qpos)
113
+ print(f"Valid starting position for {obj_name}: {found_valid}, joint_states: {joint_states}, start_pose: {start_pose}")
114
+
115
+ while not found_valid:
116
+ start_x = self._episode_rng.uniform(0.3, 0.35)
117
+ start_y = self._episode_rng.uniform(0.2, 0.5)
118
+ start_z = self._episode_rng.uniform(0.3, 0.35) # for full observation
119
+
120
+ start_pos = np.hstack([start_x, start_y, start_z])
121
+ # Create a sapien.Pose object using the position (keep default orientation)
122
+ start_pose = sapien.Pose(start_pos, [0, 1, 0, 0])
123
+
124
+ found_valid, joint_states = self._check_robot_pose_valid(start_pose, initial_qpos)
125
+
126
+ if found_valid:
127
+ qpos = np.concatenate([joint_states, np.array([0.04, 0.04])])
128
+ self.agent.reset(qpos)# warning: potential issue here, we change the joint state of the agent
129
+ self.agent.robot.set_pose(Pose([0, 0, 0])) # set base pose
130
+
131
+ def _get_obs_extra(self) -> OrderedDict:
132
+ collided = self._evaluate_collided(primary_objects_ids = self.primary_objects_ids)
133
+ obs = OrderedDict(
134
+ tcp_pose=vectorize_pose(self.tcp.pose),
135
+ goal_pos=self.goal_pos,
136
+ goal_pose=np.concatenate([self.goal_pos, self.goal_rot]),
137
+ goal_qpos=self.goal_joint_state,
138
+ collision = False if collided is None else True,
139
+ )
140
+ if self._obs_mode in ["state", "state_dict"]:
141
+ obs.update(
142
+ tcp_to_goal_pos=self.goal_pos - self.tcp.pose.p,
143
+ )
144
+ if self.create_obstacle_point_cloud:
145
+ # print("obstacle_point_cloud is: ", self.obstacle_point_cloud.shape)
146
+ obs.update({
147
+ 'obstacle_point_cloud': self.obstacle_point_cloud
148
+ })
149
+ return obs
150
+
151
+
152
+ def _evaluate_collided(self, primary_objects_ids: list[int]):
153
+ """Acertain if the robot gripper collided with another object that is not one of the targets."""
154
+ def robot_actor_contact_info(robot_id_and_primary_object_blacklist: set[str], robot_links, contact: sapien.Contact):
155
+ for robot_link in robot_links:
156
+ # Get collision between the robot and an object that is not the robot or a primary manipulation object.
157
+ collided = (
158
+ (robot_link == contact.actor0.id or robot_link == contact.actor1.id)
159
+ and (
160
+ (contact_obj := contact.actor0).id not in robot_id_and_primary_object_blacklist
161
+ or (contact_obj := contact.actor1).id not in robot_id_and_primary_object_blacklist
162
+ )
163
+ )
164
+
165
+ # # TODO: a temporary fix for the table collision
166
+ # if robot_link == (10 or 11 or 12) and contact_obj.name == "table":
167
+ # collided = True
168
+
169
+ if collided:
170
+ print("collided: ", collided, "robot_link: ", robot_link, "contact_obj: ", contact_obj.name)
171
+
172
+ return collided, robot_link, contact_obj.name
173
+ return False, None, None