Skip to content

Commit 5492f4b

Browse files
authored
fix: error handle in initial configuration (#89)
When post installation script is triggered during installation, the initialization check file (init.txt) is not present, which raises an exception. This leads to the failed installation. The issue is fixed by catching the error and suppressing it (which is okay because it is only happening during the installation).
1 parent 0067182 commit 5492f4b

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ The framework is built on top of PyTorch, a widely-used deep learning framework,
4242

4343
## Installation
4444

45-
### Step 1: Install multiworld package
46-
4745
To use the latest official package,
4846

4947
```bash
@@ -56,12 +54,6 @@ To install the package from source,
5654
pip install .
5755
```
5856

59-
### Step 2: Run post installation script
60-
61-
```bash
62-
m8d-post-setup
63-
```
64-
6557
## Running Examples
6658

6759
The list of all examples that are available can be found in the [`examples`](/examples) folder.

multiworld/post_setup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222

2323

2424
def configure_once():
25+
"""Configure multiworld once when it is used for the first time."""
2526
package_name = __name__.split(".")[0]
2627
path_to_sitepackages = site.getsitepackages()[0]
2728

2829
init_file_path = os.path.join(path_to_sitepackages, package_name, "init.txt")
2930

30-
with open(init_file_path, "r") as file:
31-
patch_applied = file.read()
31+
try:
32+
with open(init_file_path, "r") as file:
33+
patch_applied = file.read()
34+
except FileNotFoundError:
35+
message = "WARNING: initialization check file not found; "
36+
message += f"{package_name} is not installed correctly; "
37+
message += "please reinstall."
38+
print(message)
39+
return
3240

3341
if patch_applied == "true":
3442
return

0 commit comments

Comments
 (0)