|
9 | 9 | import sys |
10 | 10 | import shutil |
11 | 11 | import datetime |
| 12 | +import zipfile |
| 13 | +from importlib import metadata |
12 | 14 | from urllib.parse import urljoin |
| 15 | +from urllib.request import urlretrieve |
13 | 16 | from pathlib import Path |
14 | 17 | # -- Project information ----------------------------------------------------- |
15 | 18 | # Add any Sphinx extension module names here, as strings. They can be |
|
47 | 50 | templates_path = ['_templates'] |
48 | 51 |
|
49 | 52 | # -- Setup example files ----------------------------------------------------- |
50 | | -PYTHON_RAT_RELEASE = "0.0.0.dev4" |
| 53 | +PYTHON_RAT_RELEASE = metadata.version("RATapi") |
51 | 54 |
|
52 | 55 | if not os.path.isdir("./python_examples/data"): |
53 | | - os.system(f'git clone --depth 1 --branch {PYTHON_RAT_RELEASE} https://github.com/RascalSoftware/python-RAT') |
| 56 | + zip_dir, headers = urlretrieve("https://github.com/RascalSoftware/python-RAT/archive/refs/tags/0.0.0.dev4.zip") |
| 57 | + with zipfile.ZipFile(zip_dir) as zf: |
| 58 | + zf.extractall() |
54 | 59 | print("Copying Jupyter notebooks...") |
55 | 60 | for directory in ['normal_reflectivity', 'domains', 'absorption']: |
56 | | - for file in Path(f"./python-RAT/RATapi/examples/{directory}/").glob('*'): |
| 61 | + for file in Path(f"./python-RAT-{PYTHON_RAT_RELEASE}/RATapi/examples/{directory}/").glob('*'): |
57 | 62 | shutil.copy(file, "./python_examples/notebooks/") |
58 | 63 |
|
59 | | - shutil.copytree("./python-RAT/RATapi/examples/data", "./python_examples/data", dirs_exist_ok=True) |
| 64 | + shutil.copytree(f"./python-RAT-{PYTHON_RAT_RELEASE}/RATapi/examples/data", "./python_examples/data", dirs_exist_ok=True) |
60 | 65 |
|
61 | | - shutil.rmtree("./python-RAT") |
| 66 | + shutil.rmtree(f"./python-RAT-{PYTHON_RAT_RELEASE}") |
62 | 67 |
|
63 | 68 | if not os.path.isfile("./matlab_examples/standardLayersDSPCSheet.html"): |
64 | 69 | try: |
|
134 | 139 |
|
135 | 140 | <div class="admonition note"> |
136 | 141 | This page was generated from the notebook {{ env.docname.split('/')|last|e + '.ipynb' }} found in |
137 | | - <a class="reference external" href="https://github.com/RascalSoftware/python-RAT/blob/"""+PYTHON_RAT_RELEASE+r"""/RATapi/examples/">the Python-RAT repository. </a> |
| 142 | + <a class="reference external" href="https://github.com/RascalSoftware/python-RAT/blob/"""+PYTHON_RAT_RELEASE+r"""/RATapi/examples/">the Python-RAT repository</a>. |
138 | 143 | <a href="{{ env.docname.split('/')|last|e + '.ipynb' }}" class="reference download internal" download>Download notebook</a>. |
139 | 144 | </div> |
140 | 145 |
|
|
0 commit comments