Skip to content

Commit

Permalink
Merge pull request #38 from atstarke/update-setup-files
Browse files Browse the repository at this point in the history
This fix resolves an issue in the magent2 library where, after running pip install magent2, the environments were not copied over correctly, preventing users from importing and utilizing these environments. The merge ensures that all necessary environment files are properly included during installation.
  • Loading branch information
atstarke authored Aug 16, 2024
2 parents d4ec94d + 216a869 commit 34cafaa
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
12 changes: 12 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Include the CMakeLists.txt file
include CMakeLists.txt

# Recursively include everything in the src directory
recursive-include src *

# Include all files in the environments, config, and scenarios directories within the magent2 package
recursive-include magent2/environments *
recursive-include magent2/config *
recursive-include magent2/scenarios *

# Include dynamic library files
include *.dylib
include *.dll
include *.so

# Include gif files
include *.gif
6 changes: 1 addition & 5 deletions docs/scripts/gen_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@
f"{file_name}.md",
)

front_matter = f"""---
autogenerated:
title: {file_name}
---
"""
front_matter = f"---\n" f"autogenerated: \n" f"title: {file_name}\n" f"---\n"
title = f"# {file_name}"

if docstring is None or docstring == "":
Expand Down
2 changes: 1 addition & 1 deletion magent2/gridworld.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,4 +912,4 @@ def __init__(self, radius, angle):
raise Exception("the angle of a sector should be smaller than 180 degree")

def __str__(self):
return f"sector({self.radius:g}, {self.angle:g})"
return f"sector({self.radius: g}, {self.angle: g})"
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,6 @@ def build_extensions(self):
packages=setuptools.find_packages(),
ext_modules=[CMakeExtension("magent2.libmagent", ".", [])],
cmdclass={"build_ext": CMakeBuild},
package_data={"magent2": ["environments/*", "config/*", "scenarios/*"]},
include_package_data=True,
)
27 changes: 27 additions & 0 deletions tests/test_magent2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import importlib

import magent2


def test_version():
assert hasattr(magent2, "__version__"), "Version should not be None"
assert isinstance(magent2.__version__, str), "Version should be a string"


def test_import_environments():
envs = [
"adversarial_pursuit_v4",
"battle_v4",
"battlefield_v5",
"combined_arms_v6",
"gather_v5",
"magent_env",
"tiger_deer_v4",
]

for env in envs:
try:
# Dynamically import the environment module
importlib.import_module(f"magent2.environments.{env}")
except ImportError:
assert False, f"{env} should be importable"

0 comments on commit 34cafaa

Please sign in to comment.