Skip to content

Commit

Permalink
Test 9
Browse files Browse the repository at this point in the history
  • Loading branch information
scaramallion committed Jun 28, 2024
1 parent 01f6ffd commit 7779d4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from pydicom._dicom_dict import DicomDictionary

BASE_DIRECTORY = Path(__file__).parent.parent
DS_SRC = BASE_DIRECTORY / "src" / "pydicom-stubs" / "dataset.pyi"
DS_DST = BASE_DIRECTORY / "custom" / "dataset.pyi"
DS_SRC = BASE_DIRECTORY / "pydicom-stubs" / "dataset.pyi"


ElementDictType = dict[int, tuple[str, str, str, str]]
Expand Down
13 changes: 9 additions & 4 deletions scripts/update_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

BASE_DIRECTORY = Path(__file__).parent.parent
SRC_DIRECTORY = BASE_DIRECTORY / "custom"
DST_DIRECTORY = BASE_DIRECTORY / "pydicom-stubs"
DST_DIRECTORY = BASE_DIRECTORY / "src" / "pydicom-stubs"
PYDICOM_DIRECTORY = BASE_DIRECTORY.parent / "pydicom" / "src" / "pydicom"


Expand Down Expand Up @@ -36,21 +36,26 @@
if DST_DIRECTORY.exists():
shutil.rmtree(DST_DIRECTORY)

if (BASE_DIRECTORY / "pydicom").exists():
shutil.rmtree(DST_DIRECTORY / "pydicom")

# Generate basic stub files using mypy's `stubgen`
print("Generating basic stub files with stubgen")
subprocess.run(["which", "stubgen"], shell=True)
returncode = subprocess.run(
p = subprocess.run(
[
# f". {os.fspath(BASE_DIRECTORY / 'env' / 'env310' / 'bin' / 'activate')};"
f"stubgen {os.fspath(PYDICOM_DIRECTORY)} -o .",
],
shell=True,
)

if not list(DST_DIRECTORY.glob("*.pyi")):
if p.returncode != 0:
print(" Failed to generate the basic stub files")
sys.exit(1)

# Move the basic stubs to the correct location
shutil.move(BASE_DIRECTORY / "pydicom", DST_DIRECTORY)

# Generate the custom stub files
print("Generating custom stub files")
if not SRC_DIRECTORY.exists():
Expand Down

0 comments on commit 7779d4a

Please sign in to comment.