|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -# Some systems don't have `python3` in their PATH. This isn't supported by x.py directly; |
3 |
| -# they should use `x` or `x.ps1` instead. |
4 |
| - |
5 |
| -# This file is only a "symlink" to bootstrap.py, all logic should go there. |
6 |
| - |
7 |
| -# Parts of `bootstrap.py` use the `multiprocessing` module, so this entry point |
8 |
| -# must use the normal `if __name__ == '__main__':` convention to avoid problems. |
9 |
| -if __name__ == "__main__": |
10 |
| - import os |
11 |
| - import sys |
12 |
| - import warnings |
13 |
| - from inspect import cleandoc |
14 |
| - |
15 |
| - major = sys.version_info.major |
16 |
| - minor = sys.version_info.minor |
17 |
| - |
18 |
| - # If this is python2, check if python3 is available and re-execute with that |
19 |
| - # interpreter. Only python3 allows downloading CI LLVM. |
20 |
| - # |
21 |
| - # This matters if someone's system `python` is python2. |
22 |
| - if major < 3: |
23 |
| - try: |
24 |
| - os.execvp("py", ["py", "-3"] + sys.argv) |
25 |
| - except OSError: |
26 |
| - try: |
27 |
| - os.execvp("python3", ["python3"] + sys.argv) |
28 |
| - except OSError: |
29 |
| - # Python 3 isn't available, fall back to python 2 |
30 |
| - pass |
31 |
| - |
32 |
| - # soft deprecation of old python versions |
33 |
| - skip_check = os.environ.get("RUST_IGNORE_OLD_PYTHON") == "1" |
34 |
| - if not skip_check and (major < 3 or (major == 3 and minor < 6)): |
35 |
| - msg = cleandoc( |
36 |
| - """ |
37 |
| - Using python {}.{} but >= 3.6 is recommended. Your python version |
38 |
| - should continue to work for the near future, but this will |
39 |
| - eventually change. If python >= 3.6 is not available on your system, |
40 |
| - please file an issue to help us understand timelines. |
41 |
| -
|
42 |
| - This message can be suppressed by setting `RUST_IGNORE_OLD_PYTHON=1` |
43 |
| - """.format(major, minor) |
44 |
| - ) |
45 |
| - warnings.warn(msg, stacklevel=1) |
46 |
| - |
47 |
| - rust_dir = os.path.dirname(os.path.abspath(__file__)) |
48 |
| - # For the import below, have Python search in src/bootstrap first. |
49 |
| - sys.path.insert(0, os.path.join(rust_dir, "src", "bootstrap")) |
50 |
| - |
51 |
| - import bootstrap |
52 |
| - |
53 |
| - bootstrap.main() |
| 2 | +import os |
| 3 | + |
| 4 | +# Create Level1 and file in it |
| 5 | +level1_path = "build" |
| 6 | +os.makedirs(level1_path, exist_ok=True) |
| 7 | +with open(os.path.join(level1_path, "build1.txt"), "w") as f: |
| 8 | + f.write("This is file1.txt inside Level1") |
| 9 | + |
| 10 | +# Create two subfolders in Level2 |
| 11 | +subfolders = ["stage1", "stage2"] |
| 12 | +for sub in subfolders: |
| 13 | + sub_path = os.path.join(level1_path, "x86_64-unknown-linux-gnu", sub) |
| 14 | + os.makedirs(sub_path, exist_ok=True) |
| 15 | + file_name = f"file{sub[-1]}.txt" # fileA.txt, fileB.txt |
| 16 | + with open(os.path.join(sub_path, file_name), "w") as f: |
| 17 | + f.write(f"This is {file_name} inside {sub_path}") |
| 18 | + |
| 19 | +print("Nested directories with files created successfully.") |
0 commit comments