Skip to content

Commit 33785e1

Browse files
committed
Test 1
1 parent 8999266 commit 33785e1

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

.github/workflows/update-package.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: update-package
2+
3+
on:
4+
# workflow_dispatch:
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
update:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout package
13+
uses: actions/checkout@v4
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
- name: Install dependencies
19+
run: |
20+
pip install -U pip
21+
pip install mypy
22+
mkdir ../pydicom
23+
git clone https://github.com/pydicom/pydicom ../pydicom
24+
pip install -e ../pydicom
25+
- name: Update package
26+
run: |
27+
ls -l
28+
ls -l ../pydicom
29+
git status
30+
python scripts/update_package.py
31+
git status
32+
- name: Create Pull Request
33+
# Only creates a new PR if there are changes
34+
uses: peter-evans/create-pull-request@v6
35+
with:
36+
token: ${{ secrets.AUTO_UPDATE_PACKAGE }}
37+
title: "Update package"

scripts/generate_stubs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
BASE_DIRECTORY = Path(__file__).parent.parent
88
DS_DST = BASE_DIRECTORY / "custom" / "dataset.pyi"
9-
DS_SRC = BASE_DIRECTORY / "pydicom-stubs" / "dataset.pyi"
9+
DS_SRC = BASE_DIRECTORY / "src" / "pydicom-stubs" / "dataset.pyi"
1010

1111

1212
ElementDictType = dict[int, tuple[str, str, str, str]]

scripts/update_package.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
BASE_DIRECTORY = Path(__file__).parent.parent
1010
SRC_DIRECTORY = BASE_DIRECTORY / "custom"
11-
DST_DIRECTORY = BASE_DIRECTORY / "pydicom-stubs"
11+
DST_DIRECTORY = BASE_DIRECTORY / "src" / "pydicom-stubs"
1212
PYDICOM_DIRECTORY = BASE_DIRECTORY.parent / "pydicom" / "src" / "pydicom"
1313

1414

@@ -36,29 +36,33 @@
3636
if DST_DIRECTORY.exists():
3737
shutil.rmtree(DST_DIRECTORY)
3838

39+
if (BASE_DIRECTORY / "pydicom").exists():
40+
shutil.rmtree(BASE_DIRECTORY / "pydicom")
41+
3942
# Generate basic stub files using mypy's `stubgen`
4043
print("Generating basic stub files with stubgen")
4144
subprocess.run(["which", "stubgen"], shell=True)
42-
returncode = subprocess.run(
45+
p = subprocess.run(
4346
[
44-
f". {os.fspath(BASE_DIRECTORY / 'env' / 'env310' / 'bin' / 'activate')};"
4547
f"stubgen {os.fspath(PYDICOM_DIRECTORY)} -o .",
4648
],
4749
shell=True,
4850
)
4951

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

56+
# Move the basic stubs to the correct location
57+
shutil.move(BASE_DIRECTORY / "pydicom", DST_DIRECTORY)
58+
5459
# Generate the custom stub files
5560
print("Generating custom stub files")
5661
if not SRC_DIRECTORY.exists():
5762
SRC_DIRECTORY.mkdir(parents=True, exist_ok=True)
5863

5964
subprocess.run(
6065
[
61-
f". {os.fspath(BASE_DIRECTORY / 'env' / 'env310' / 'bin' / 'activate')};"
6266
"python scripts/generate_stubs.py",
6367
],
6468
shell=True,

0 commit comments

Comments
 (0)