Repository: sail-sg/envpool (language: python)

Issue:
[BUG] Failed to make several Atari environments list in the docs
## Describe the bug

Failed to make serveral Atari environments and 'Wrap ROM error' pops out.

List of envs:
```bash
Combat-v5
Joust-v5
MazeCraze-v5
Warlords-v5
```
## To Reproduce

```python
import envpool
envpool.make_gym('Combat-v5')
```

```bash
Attempt to wrap ROM "/home/benjamin/anaconda3/envs/envpool/lib/python3.8/site-packages/envpool/atari/atari_roms/combat/combat.bin"(0ef64cdbecccb7049752a3de0b7ade14) failed.
If you're using an MD5 mismatched ROM, please make sure the filename is in snake case.
e.g., space_invaders.bin

For a list of supported ROMs see https://github.com/mgbellemare/Arcade-Learning-Environment
```

## Expected behavior

Make those envs successfully

## Screenshots

<img width="1426" alt="image" src="https://user-images.githubusercontent.com/32269413/170885595-845adb1b-2db0-4a69-ad0d-5b72a7d231f5.png">


## System info

Describe the characteristic of your environment:
 * envpool is installed via pip
 * envpool version: '0.6.1.post1
 * numpy version: '1.22.4
 * Python version: 3.8.8

```bash
0.6.1.post1 1.22.4 3.8.8 (default, Apr 13 2021, 19:58:26)
[GCC 7.3.0] linux
```

## Checklist

- [x] I have checked that there is no similar issue in the repo (**required**)
- [x] I have read the [documentation](https://envpool.readthedocs.io/) (**required**)
- [x] I have provided a minimal working example to reproduce the bug (**required**)



Discussion / hints:

Fix patch:
diff --git a/docs/content/new_env.rst b/docs/content/new_env.rst
index 5d80a412..389c5e44 100644
--- a/docs/content/new_env.rst
+++ b/docs/content/new_env.rst
@@ -698,7 +698,7 @@ The dependency string format is ``@<package>`` or ``@<package>//:<name>``.
 For ``genrule()`` and ``data = [...]``, please refer to `Bazel official
 documentation
 <https://docs.bazel.build/versions/main/be/general.html#genrule>`_ or
-`Atari BUILD example <https://github.com/sail-sg/envpool/blob/v0.4.1/envpool/atari/BUILD>`_.
+`Atari BUILD example <https://github.com/sail-sg/envpool/blob/v0.6.1.post1/envpool/atari/BUILD>`_.
 
 
 Register CartPole-v0/1 in EnvPool
@@ -774,7 +774,7 @@ successfully. In ``setup.cfg``:
 
     [options.package_data]
     envpool = atari/*.so
-        atari/atari_roms/*/*.bin
+        atari/roms/*.bin
    +    classic_control/*.so
 
 Now you can run ``envpool.make("CartPole-v0")`` by re-installing EnvPool:
diff --git a/docs/env/atari.rst b/docs/env/atari.rst
index 84843271..654f55a1 100644
--- a/docs/env/atari.rst
+++ b/docs/env/atari.rst
@@ -96,7 +96,6 @@ related discussions at
 * ``Casino-v5``
 * ``Centipede-v5``
 * ``ChopperCommand-v5``
-* ``Combat-v5``
 * ``CrazyClimber-v5``
 * ``Crossbow-v5``
 * ``Darkchambers-v5``
@@ -124,7 +123,6 @@ related discussions at
 * ``IceHockey-v5``
 * ``Jamesbond-v5``
 * ``JourneyEscape-v5``
-* ``Joust-v5``
 * ``Kaboom-v5``
 * ``Kangaroo-v5``
 * ``KeystoneKapers-v5``
@@ -136,7 +134,6 @@ related discussions at
 * ``LaserGates-v5``
 * ``LostLuggage-v5``
 * ``MarioBros-v5``
-* ``MazeCraze-v5``
 * ``MiniatureGolf-v5``
 * ``MontezumaRevenge-v5``
 * ``MrDo-v5``
@@ -176,7 +173,6 @@ related discussions at
 * ``VideoChess-v5``
 * ``VideoCube-v5``
 * ``VideoPinball-v5``
-* ``Warlords-v5``
 * ``WizardOfWor-v5``
 * ``WordZapper-v5``
 * ``YarsRevenge-v5``
diff --git a/envpool/atari/BUILD b/envpool/atari/BUILD
index be5f2071..9d5d8680 100644
--- a/envpool/atari/BUILD
+++ b/envpool/atari/BUILD
@@ -6,8 +6,8 @@ package(default_visibility = ["//visibility:public"])
 genrule(
     name = "gen_atari_roms",
     srcs = ["@atari_roms//:roms"],
-    outs = ["atari_roms"],
-    cmd = "cp -r $(SRCS) $(OUTS)",
+    outs = ["roms"],
+    cmd = "mkdir -p $(OUTS) && cp $(SRCS) $(OUTS)",
 )
 
 genrule(
diff --git a/envpool/atari/atari_env.h b/envpool/atari/atari_env.h
index 5bff4e4d..d417ea2a 100644
--- a/envpool/atari/atari_env.h
+++ b/envpool/atari/atari_env.h
@@ -42,7 +42,7 @@ static bool verbosity_off = TurnOffVerbosity();
 std::string GetRomPath(const std::string& base_path, const std::string& task) {
   std::stringstream ss;
   // hardcode path here :(
-  ss << base_path << "/atari/atari_roms/" << task << "/" << task << ".bin";
+  ss << base_path << "/atari/roms/" << task << ".bin";
   return ss.str();
 }
 
diff --git a/envpool/atari/registration.py b/envpool/atari/registration.py
index 4dd06f14..f664b5ec 100644
--- a/envpool/atari/registration.py
+++ b/envpool/atari/registration.py
@@ -19,8 +19,10 @@
 
 base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
 
-atari_rom_path = os.path.join(base_path, "atari", "atari_roms")
-atari_game_list = sorted(os.listdir(atari_rom_path))
+atari_rom_path = os.path.join(base_path, "atari", "roms")
+atari_game_list = sorted(
+  [i.replace(".bin", "") for i in os.listdir(atari_rom_path)]
+)
 
 for game in atari_game_list:
   name = "".join([g.capitalize() for g in game.split("_")])
diff --git a/setup.cfg b/setup.cfg
index 7f711296..be170f80 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -33,7 +33,7 @@ include = envpool*
 
 [options.package_data]
 envpool = atari/*.so
-    atari/atari_roms/*/*.bin
+    atari/roms/*.bin
     classic_control/*.so
     toy_text/*.so
     vizdoom/bin/*
diff --git a/third_party/atari_roms/atari_roms.BUILD b/third_party/atari_roms/atari_roms.BUILD
index e5216e19..c55497e5 100644
--- a/third_party/atari_roms/atari_roms.BUILD
+++ b/third_party/atari_roms/atari_roms.BUILD
@@ -1,5 +1,13 @@
 filegroup(
     name = "roms",
-    srcs = ["ROM"],
+    srcs = glob(
+        ["ROM/*/*.bin"],
+        exclude = [
+            "ROM/combat/combat.bin",
+            "ROM/joust/joust.bin",
+            "ROM/maze_craze/maze_craze.bin",
+            "ROM/warlords/warlords.bin",
+        ],
+    ),
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/pip_requirements/requirements.txt b/third_party/pip_requirements/requirements.txt
index 76213e6f..d5f3adbb 100644
--- a/third_party/pip_requirements/requirements.txt
+++ b/third_party/pip_requirements/requirements.txt
@@ -15,14 +15,12 @@ jinja2
 numpy
 opencv-python-headless
 scipy
-setuptools<=59.5.0
+setuptools
 six
 tensorboard
 tianshou
 torch
 tqdm
-types-filelock
-types-protobuf
 numba
 llvmlite
 wheel
@@ -35,7 +33,7 @@ google-auth-oauthlib
 tensorboard-data-server
 typing-extensions
 werkzeug
-protobuf
+protobuf<=4.20.0
 rsa
 requests_oauthlib
 idna


Test patch:
diff --git a/envpool/make_test.py b/envpool/make_test.py
index 73cad487..7ac7f163 100644
--- a/envpool/make_test.py
+++ b/envpool/make_test.py
@@ -43,6 +43,9 @@ def test_make_atari(self) -> None:
     self.assertEqual(spec.action_space.n, 18)
     self.assertEqual(env_gym.action_space.n, 18)
     self.assertEqual(env_dm.action_spec().num_values, 18)
+    # not work for wrong bin, see issue #146
+    for wrong in ["Combat", "Joust", "MazeCraze", "Warlords"]:
+      self.assertRaises(AssertionError, envpool.make_gym, f"{wrong}-v5")
 
   def test_make_vizdoom(self) -> None:
     spec = envpool.make_spec("MyWayHome-v1")