f3d2solidcraft 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/.github/workflows/release.yml +76 -11
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/CHANGELOG.md +13 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/PKG-INFO +3 -1
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/README.md +2 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/docs/guia.md +2 -0
- f3d2solidcraft-0.3.1/docs/media/demo.gif +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/pyproject.toml +1 -1
- f3d2solidcraft-0.3.1/scripts/fetch_cadmpeg.py +125 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/__init__.py +1 -1
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/cli.py +17 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/sketch.py +2 -2
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/__main__.py +1 -1
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/runner.py +16 -4
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/window.py +81 -14
- f3d2solidcraft-0.3.1/src/f3d2solidcraft_app/winjob.py +181 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_window.py +280 -33
- f3d2solidcraft-0.3.1/tests/app/test_winjob.py +84 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_cli.py +85 -0
- f3d2solidcraft-0.3.1/tests/test_fetch_cadmpeg.py +77 -0
- f3d2solidcraft-0.3.0/scripts/fetch_cadmpeg.py +0 -81
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/.github/workflows/ci.yml +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/LICENSE +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/__main__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/LICENSE +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/container/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/container/archive.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/model/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/model/parameters.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/model/sketch.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/model/timeline.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/streams/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/streams/manifest.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/streams/primitives.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/_vendor/ezf3d/streams/segment.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/engine.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/fallback.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/geometry.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/bodies.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/combine.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/components.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/edges.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/extrude.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/faces.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/loft.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/outputs.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/params.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/pattern.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/planes.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/primitives.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/records.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/revolve.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/sheet.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mappers/shell.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/mcp.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/model.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/oracle.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/pairing.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/reader/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/reader/cadir.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/reader/fusion.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/reader/locale.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/replay.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/report.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/tools.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/verify.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft/visibility.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/engines.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/events.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/opener.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/outcome.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-128.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-16.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-256.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-32.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-512.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon-64.png +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon.icns +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon.ico +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/resources/icon.svg +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/src/f3d2solidcraft_app/texts.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/__init__.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/conftest.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_engines_runner.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_events_outcome.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_icon.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_opener.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_packaging.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/app/test_texts.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/conftest.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_bench.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_bezier_spans.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_bodies.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_combine.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_components.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_condemnation.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_conics.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_declared_edges.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_engine.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_extents.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_faces.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_geometry.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_inspect_json.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_locations.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_loft.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_mappers.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_mcp.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_naming.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_oracle.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_pairing.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_partial_sketches.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_pattern.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_primitives.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_progress.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_reader.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_replay.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_revolve.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_rollback.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_sheet.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_shell.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_tilted_planes.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_tools.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_trimmed_region.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_unmeasurable.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_unnamed_sketches.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_verify.py +0 -0
- {f3d2solidcraft-0.3.0 → f3d2solidcraft-0.3.1}/tests/test_visibility.py +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
name: release
|
|
2
2
|
# A tag `vX.Y.Z` publishes that version to PyPI and attaches the three desktop installers to its GitHub
|
|
3
|
-
# release.
|
|
3
|
+
# release. The release is created as a draft, each installer leg uploads to the draft, and only when all
|
|
4
|
+
# three legs succeeded does the last job publish it: a leg that fails leaves a draft nobody sees, never a
|
|
5
|
+
# public release with an installer missing.
|
|
4
6
|
#
|
|
5
7
|
# Run by hand (Actions -> release -> Run workflow), it is a rehearsal that publishes nothing: it builds
|
|
6
8
|
# and checks the package and builds the three desktop installers, kept only as downloadable workflow
|
|
@@ -44,6 +46,7 @@ jobs:
|
|
|
44
46
|
uv venv /tmp/smoke
|
|
45
47
|
uv pip install --python /tmp/smoke/bin/python dist/*.whl
|
|
46
48
|
/tmp/smoke/bin/f3d2solidcraft --help
|
|
49
|
+
/tmp/smoke/bin/f3d2solidcraft --version
|
|
47
50
|
/tmp/smoke/bin/python -c "import f3d2solidcraft; print(f3d2solidcraft.__version__)"
|
|
48
51
|
- uses: actions/upload-artifact@v4
|
|
49
52
|
with:
|
|
@@ -68,7 +71,9 @@ jobs:
|
|
|
68
71
|
|
|
69
72
|
pypi:
|
|
70
73
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # a dispatch, even from a tag, never publishes
|
|
71
|
-
|
|
74
|
+
# Last, after the GitHub release is out with all three installers: PyPI cannot be undone, so it
|
|
75
|
+
# waits until nothing else can still fail and leave PyPI ahead of the installers.
|
|
76
|
+
needs: [build, publish]
|
|
72
77
|
runs-on: ubuntu-latest
|
|
73
78
|
environment: pypi
|
|
74
79
|
permissions:
|
|
@@ -98,10 +103,15 @@ jobs:
|
|
|
98
103
|
# libxcb-cursor0 is needed to load the Qt xcb platform plugin".
|
|
99
104
|
#
|
|
100
105
|
# Run by hand, this job is the installers' rehearsal: it builds them and uploads them as workflow
|
|
101
|
-
# artifacts, and the release
|
|
106
|
+
# artifacts, and the release steps are skipped. A tag does both.
|
|
102
107
|
installers:
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
# `!cancelled()` so a hand run, where `draft` is skipped, still builds; the result checks keep a
|
|
109
|
+
# failed build or a draft that was not made from going on.
|
|
110
|
+
if: >-
|
|
111
|
+
!cancelled() && needs.build.result == 'success' &&
|
|
112
|
+
(needs.draft.result == 'success' || needs.draft.result == 'skipped') &&
|
|
113
|
+
(startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch')
|
|
114
|
+
needs: [build, draft]
|
|
105
115
|
runs-on: ${{ matrix.os }}
|
|
106
116
|
strategy:
|
|
107
117
|
fail-fast: false
|
|
@@ -119,8 +129,8 @@ jobs:
|
|
|
119
129
|
platform: linux
|
|
120
130
|
format: appimage
|
|
121
131
|
flags: --no-docker -C 'template_branch="v0.4.4"'
|
|
122
|
-
# `write` is only used by the
|
|
123
|
-
# on the event, so a hand run gets it too; it uploads artifacts and nothing else.
|
|
132
|
+
# `write` is only used by the upload to the draft, which runs on tags alone. A job's permissions cannot
|
|
133
|
+
# depend on the event, so a hand run gets it too; it uploads artifacts and nothing else.
|
|
124
134
|
permissions:
|
|
125
135
|
contents: write
|
|
126
136
|
defaults:
|
|
@@ -146,7 +156,62 @@ jobs:
|
|
|
146
156
|
name: installer-${{ matrix.platform }}
|
|
147
157
|
path: dist/*
|
|
148
158
|
if-no-files-found: error
|
|
149
|
-
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
- name: Upload to the draft release
|
|
160
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
161
|
+
env:
|
|
162
|
+
GH_TOKEN: ${{ github.token }}
|
|
163
|
+
run: gh release upload "$GITHUB_REF_NAME" dist/* --clobber --repo "$GITHUB_REPOSITORY"
|
|
164
|
+
|
|
165
|
+
# The tag's release, as a draft, before any installer is built: the three legs upload into this one
|
|
166
|
+
# release instead of racing to create it. A draft left from an earlier attempt at the same tag is used
|
|
167
|
+
# as it is; a release already published is not turned back into a draft.
|
|
168
|
+
draft:
|
|
169
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
170
|
+
needs: build
|
|
171
|
+
runs-on: ubuntu-latest
|
|
172
|
+
permissions:
|
|
173
|
+
contents: write
|
|
174
|
+
steps:
|
|
175
|
+
- uses: actions/checkout@v4
|
|
176
|
+
- name: Create the draft release
|
|
177
|
+
env:
|
|
178
|
+
GH_TOKEN: ${{ github.token }}
|
|
179
|
+
run: |
|
|
180
|
+
set -euo pipefail
|
|
181
|
+
if gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
182
|
+
echo "release $GITHUB_REF_NAME already exists; the legs upload to it"
|
|
183
|
+
exit 0
|
|
184
|
+
fi
|
|
185
|
+
# The notes are the version's own section of CHANGELOG.md, from its heading to the next one.
|
|
186
|
+
awk -v v="## ${GITHUB_REF_NAME#v}" '
|
|
187
|
+
index($0, v) == 1 && (length($0) == length(v) || substr($0, length(v) + 1, 1) == " ") { on = 1; next }
|
|
188
|
+
on && /^## / { exit }
|
|
189
|
+
on { print }
|
|
190
|
+
' CHANGELOG.md > notes.md
|
|
191
|
+
test -s notes.md || { echo "CHANGELOG.md has no section for ${GITHUB_REF_NAME#v}"; exit 1; }
|
|
192
|
+
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft --verify-tag \
|
|
193
|
+
--title "$GITHUB_REF_NAME" --notes-file notes.md
|
|
194
|
+
|
|
195
|
+
# Publishes the draft once every installer leg succeeded. A failed or cancelled leg skips this job, so
|
|
196
|
+
# the release stays a draft with whatever was uploaded, for a re-run of the failed leg to complete.
|
|
197
|
+
publish:
|
|
198
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
199
|
+
needs: [draft, installers]
|
|
200
|
+
runs-on: ubuntu-latest
|
|
201
|
+
permissions:
|
|
202
|
+
contents: write
|
|
203
|
+
steps:
|
|
204
|
+
- name: Every installer is attached
|
|
205
|
+
env:
|
|
206
|
+
GH_TOKEN: ${{ github.token }}
|
|
207
|
+
run: |
|
|
208
|
+
set -euo pipefail
|
|
209
|
+
assets=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json assets -q '.assets[].name')
|
|
210
|
+
echo "$assets"
|
|
211
|
+
for suffix in .msi .dmg .AppImage; do
|
|
212
|
+
grep -q -- "$suffix\$" <<< "$assets" || { echo "no $suffix attached to $GITHUB_REF_NAME"; exit 1; }
|
|
213
|
+
done
|
|
214
|
+
- name: Publish the release
|
|
215
|
+
env:
|
|
216
|
+
GH_TOKEN: ${{ github.token }}
|
|
217
|
+
run: gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
- Desktop app: the "Save as" line and its "Change…" button only appear once a file is loaded.
|
|
6
|
+
- Desktop app on Windows: cancelling, closing the window or a converter that crashes now ends every process the
|
|
7
|
+
conversion started, SolidCraft included. Before, an engine could be left running after a crash.
|
|
8
|
+
- File and folder names with accents, ñ or other non-ASCII letters convert from the command line and the desktop
|
|
9
|
+
app on Windows, macOS and Linux. The command now writes its output as UTF-8 on every system.
|
|
10
|
+
- `f3d2solidcraft --version` prints the version.
|
|
11
|
+
- The report says "not supported yet" for sketch constraints and dimensions it cannot rebuild, instead of an
|
|
12
|
+
internal milestone name.
|
|
13
|
+
- Release: the installers are attached to a draft release, published only once all three are built; the cadmpeg
|
|
14
|
+
download for the installers times out instead of hanging, and refuses a Linux machine that is not x86_64.
|
|
15
|
+
|
|
3
16
|
## 0.3.0 — first public release
|
|
4
17
|
|
|
5
18
|
- A desktop program for Windows, macOS and Linux (`f3d2solidcraft[gui]`, or the installers attached to each
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: f3d2solidcraft
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Convert Autodesk Fusion .f3d/.f3z designs into editable SolidCraft designs
|
|
5
5
|
Project-URL: Homepage, https://github.com/cristiancarterm/f3d2solidcraft
|
|
6
6
|
Project-URL: Issues, https://github.com/cristiancarterm/f3d2solidcraft/issues
|
|
@@ -38,6 +38,8 @@ bounding box and centre of mass (within 0.01 mm), same face count.
|
|
|
38
38
|
|
|
39
39
|
*Guía en español: [docs/guia.md](docs/guia.md).*
|
|
40
40
|
|
|
41
|
+

|
|
42
|
+
|
|
41
43
|
## Status
|
|
42
44
|
|
|
43
45
|
Early, and honest about it. On the corpus of 15 real designs it is developed against:
|
|
@@ -9,6 +9,8 @@ bounding box and centre of mass (within 0.01 mm), same face count.
|
|
|
9
9
|
|
|
10
10
|
*Guía en español: [docs/guia.md](docs/guia.md).*
|
|
11
11
|
|
|
12
|
+

|
|
13
|
+
|
|
12
14
|
## Status
|
|
13
15
|
|
|
14
16
|
Early, and honest about it. On the corpus of 15 real designs it is developed against:
|
|
@@ -9,6 +9,8 @@ Cada conversión se compara con el original antes de entregártela: los mismos c
|
|
|
9
9
|
margen de 0,1 %), la misma caja envolvente y el mismo centro de masa (con un margen de 0,01 mm) y la misma cantidad de
|
|
10
10
|
caras.
|
|
11
11
|
|
|
12
|
+

|
|
13
|
+
|
|
12
14
|
*English: [README.md](../README.md).*
|
|
13
15
|
|
|
14
16
|
## Estado
|
|
Binary file
|
|
@@ -59,7 +59,7 @@ packages = ["src/f3d2solidcraft", "src/f3d2solidcraft_app"]
|
|
|
59
59
|
[tool.briefcase]
|
|
60
60
|
project_name = "f3d2solidcraft"
|
|
61
61
|
bundle = "cl.mitocondria"
|
|
62
|
-
version = "0.3.
|
|
62
|
+
version = "0.3.1" # the package's own version: tests/app/test_packaging.py keeps the two equal
|
|
63
63
|
url = "https://github.com/cristiancarterm/f3d2solidcraft"
|
|
64
64
|
# The license comes from [project] (PEP 639: `license` + `license-files`); Briefcase refuses both forms.
|
|
65
65
|
author = "Cristián Carter"
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Put a verified cadmpeg inside the app before Briefcase packages it (spec, Empaque).
|
|
2
|
+
|
|
3
|
+
uv run python scripts/fetch_cadmpeg.py [--dest DIR]
|
|
4
|
+
|
|
5
|
+
Downloads the release asset for this system, checks it against the sha256 pinned here (the same
|
|
6
|
+
numbers the plan's Global Constraints carry), and installs the binary. On macOS it fetches both
|
|
7
|
+
architectures and joins them with `lipo`, so the .dmg runs on Apple silicon and Intel alike.
|
|
8
|
+
|
|
9
|
+
cadmpeg publishes Linux binaries for x86_64 only: on any other Linux machine this stops with a
|
|
10
|
+
message instead of putting an x86_64 binary in an app that could never run it.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import hashlib
|
|
14
|
+
import platform
|
|
15
|
+
import shutil
|
|
16
|
+
import subprocess
|
|
17
|
+
import sys
|
|
18
|
+
import tarfile
|
|
19
|
+
import tempfile
|
|
20
|
+
import urllib.error
|
|
21
|
+
import urllib.request
|
|
22
|
+
import zipfile
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
VERSION = "0.6.11"
|
|
26
|
+
BASE = f"https://github.com/cadmpeg/cadmpeg/releases/download/v{VERSION}"
|
|
27
|
+
SHA256 = {
|
|
28
|
+
"cadmpeg-x86_64-pc-windows-msvc.zip": "4e1ec1f697b089f7ea9a8f8637e1242607b172f502333569a794a8191ecb47f1",
|
|
29
|
+
"cadmpeg-aarch64-apple-darwin.tar.xz": "71b9ba0b224977774e09f5d1374219623401e13c01f695b341dae6de673c0ee6",
|
|
30
|
+
"cadmpeg-x86_64-apple-darwin.tar.xz": "304a6ca4de389a8935601a3a43312eaca8e29b7ec2314e44a8d63de6f6e1123e",
|
|
31
|
+
"cadmpeg-x86_64-unknown-linux-gnu.tar.xz": "cdc95d3e6f07944f8a9a80c99259bd957d5afeecd4337d1a80ed6659e37a3abd",
|
|
32
|
+
}
|
|
33
|
+
DEFAULT_DEST = Path(__file__).resolve().parents[1] / "src/f3d2solidcraft_app/resources/bin"
|
|
34
|
+
#: Seconds a connection may stay silent (connecting, or between two reads) before the download stops.
|
|
35
|
+
TIMEOUT = 60
|
|
36
|
+
#: How `platform.machine()` spells x86_64 on the systems that build the app.
|
|
37
|
+
X86_64 = {"x86_64", "amd64"}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class FetchError(SystemExit):
|
|
41
|
+
"""A download or a machine this script cannot serve: the message is what the user reads."""
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def assets_for(system: str, machine: str) -> list[str]:
|
|
45
|
+
"""The release assets to fetch for `platform.system()` and `platform.machine()`.
|
|
46
|
+
|
|
47
|
+
Windows takes the x86_64 build on any machine (Windows on Arm runs it emulated); macOS takes both
|
|
48
|
+
and joins them. Linux has no emulation to fall back on, so anything but x86_64 is refused.
|
|
49
|
+
"""
|
|
50
|
+
if system == "Windows":
|
|
51
|
+
return ["cadmpeg-x86_64-pc-windows-msvc.zip"]
|
|
52
|
+
if system == "Darwin":
|
|
53
|
+
return ["cadmpeg-aarch64-apple-darwin.tar.xz", "cadmpeg-x86_64-apple-darwin.tar.xz"]
|
|
54
|
+
if system == "Linux" and machine.lower() in X86_64:
|
|
55
|
+
return ["cadmpeg-x86_64-unknown-linux-gnu.tar.xz"]
|
|
56
|
+
if system == "Linux":
|
|
57
|
+
raise FetchError(
|
|
58
|
+
f"cadmpeg {VERSION} publishes a Linux binary for x86_64 only, and this machine is "
|
|
59
|
+
f"{machine or 'of an unknown architecture'}: build the Linux app on an x86_64 machine"
|
|
60
|
+
)
|
|
61
|
+
raise FetchError(f"cadmpeg {VERSION} publishes no binary for {system or 'this system'}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def download(url: str, target: Path, timeout: float = TIMEOUT) -> None:
|
|
65
|
+
"""`url` into `target`; a server that does not answer within `timeout` seconds stops it."""
|
|
66
|
+
try:
|
|
67
|
+
with urllib.request.urlopen(url, timeout=timeout) as response, target.open("wb") as sink:
|
|
68
|
+
shutil.copyfileobj(response, sink)
|
|
69
|
+
except TimeoutError:
|
|
70
|
+
raise FetchError(f"downloading {url} timed out: no answer for {timeout:g} s") from None
|
|
71
|
+
except urllib.error.URLError as exc:
|
|
72
|
+
# A timeout while connecting arrives wrapped in a URLError.
|
|
73
|
+
if isinstance(exc.reason, TimeoutError):
|
|
74
|
+
raise FetchError(f"downloading {url} timed out: no answer for {timeout:g} s") from None
|
|
75
|
+
raise FetchError(f"could not download {url}: {exc.reason}") from None
|
|
76
|
+
except OSError as exc:
|
|
77
|
+
raise FetchError(f"could not download {url}: {exc}") from None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _fetch(asset: str, into: Path) -> Path:
|
|
81
|
+
target = into / asset
|
|
82
|
+
download(f"{BASE}/{asset}", target)
|
|
83
|
+
digest = hashlib.sha256(target.read_bytes()).hexdigest()
|
|
84
|
+
if digest != SHA256[asset]:
|
|
85
|
+
raise FetchError(f"{asset}: sha256 {digest} is not the pinned {SHA256[asset]}")
|
|
86
|
+
return target
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _binary(archive: Path, into: Path, name: str) -> Path:
|
|
90
|
+
out = into / archive.name.split(".")[0]
|
|
91
|
+
if archive.suffix == ".zip":
|
|
92
|
+
with zipfile.ZipFile(archive) as z:
|
|
93
|
+
z.extractall(out)
|
|
94
|
+
else:
|
|
95
|
+
with tarfile.open(archive) as t:
|
|
96
|
+
t.extractall(out, filter="data")
|
|
97
|
+
return next(p for p in out.rglob(name) if p.is_file())
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def main(argv: list[str], system: str | None = None, machine: str | None = None) -> int:
|
|
101
|
+
dest = Path(argv[argv.index("--dest") + 1]) if "--dest" in argv else DEFAULT_DEST
|
|
102
|
+
system = platform.system() if system is None else system
|
|
103
|
+
machine = platform.machine() if machine is None else machine
|
|
104
|
+
assets = assets_for(system, machine) # refuses before anything is written or downloaded
|
|
105
|
+
dest.mkdir(parents=True, exist_ok=True)
|
|
106
|
+
name = "cadmpeg.exe" if system == "Windows" else "cadmpeg"
|
|
107
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
108
|
+
work = Path(tmp)
|
|
109
|
+
binaries = [_binary(_fetch(asset, work), work, name) for asset in assets]
|
|
110
|
+
if len(binaries) > 1:
|
|
111
|
+
subprocess.run(["lipo", "-create", *map(str, binaries), "-output", str(dest / name)], check=True)
|
|
112
|
+
else:
|
|
113
|
+
shutil.copy2(binaries[0], dest / name)
|
|
114
|
+
installed = dest / name
|
|
115
|
+
installed.chmod(0o755)
|
|
116
|
+
print(
|
|
117
|
+
subprocess.run(
|
|
118
|
+
[str(installed), "--version"], capture_output=True, text=True, check=True
|
|
119
|
+
).stdout.strip()
|
|
120
|
+
)
|
|
121
|
+
return 0
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
if __name__ == "__main__":
|
|
125
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -16,6 +16,7 @@ from pathlib import Path
|
|
|
16
16
|
|
|
17
17
|
import zstandard
|
|
18
18
|
|
|
19
|
+
from f3d2solidcraft import __version__
|
|
19
20
|
from f3d2solidcraft.engine import BodyUnmeasurable, CommandRefused, Engine, EngineError
|
|
20
21
|
from f3d2solidcraft.fallback import apply_fallback, name_bodies, original_step
|
|
21
22
|
from f3d2solidcraft.mappers import MAPPERS
|
|
@@ -495,8 +496,24 @@ def _event(payload: dict) -> None:
|
|
|
495
496
|
print(json.dumps(payload), flush=True)
|
|
496
497
|
|
|
497
498
|
|
|
499
|
+
def _utf8_output() -> None:
|
|
500
|
+
"""Write UTF-8 on every system, as the desktop app's worker does.
|
|
501
|
+
|
|
502
|
+
On Windows a pipe or a file gets the ANSI code page otherwise: a design named with a letter that
|
|
503
|
+
code page lacks (`Ω` in cp1252) stopped the command with UnicodeEncodeError after the conversion
|
|
504
|
+
was done, and a script reading the output had to guess its encoding. A Windows console is not
|
|
505
|
+
affected: Python writes to it in UTF-16 whatever this says.
|
|
506
|
+
"""
|
|
507
|
+
for stream in (sys.stdout, sys.stderr):
|
|
508
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
509
|
+
if reconfigure is not None and (stream.encoding or "").lower().replace("-", "") != "utf8":
|
|
510
|
+
reconfigure(encoding="utf-8", errors=stream.errors)
|
|
511
|
+
|
|
512
|
+
|
|
498
513
|
def main(argv: list[str] | None = None) -> int:
|
|
514
|
+
_utf8_output()
|
|
499
515
|
parser = argparse.ArgumentParser(prog="f3d2solidcraft")
|
|
516
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
|
500
517
|
sub = parser.add_subparsers(dest="cmd", required=True)
|
|
501
518
|
c = sub.add_parser("convert", help="convert a .f3d or .f3z into a .solidcraft design")
|
|
502
519
|
c.add_argument("f3d", type=Path)
|
|
@@ -267,7 +267,7 @@ def _dimension(ctx: Context, sketch_entities: list[SketchEntity], used: set[str]
|
|
|
267
267
|
elif role.startswith("linear"):
|
|
268
268
|
kinds, want, kind = ("line",), abs(p.value_mm), "length"
|
|
269
269
|
else:
|
|
270
|
-
return [f"dimension {p.name} ({p.role}) skipped:
|
|
270
|
+
return [f"dimension {p.name} ({p.role}) skipped: this kind of dimension is not supported yet"]
|
|
271
271
|
matches = [
|
|
272
272
|
e
|
|
273
273
|
for e in sketch_entities
|
|
@@ -400,7 +400,7 @@ def build_sketch(sketch: Sketch, name: str | None, ctx: Context) -> list[str]:
|
|
|
400
400
|
elif c.kind == "coincident_loci":
|
|
401
401
|
warnings.append(_coincident_loci(sketch, c))
|
|
402
402
|
elif c.kind != "coincident": # coincident is implicit: sketch.line connects shared points
|
|
403
|
-
warnings.append(f"constraint {c.kind} not
|
|
403
|
+
warnings.append(f"constraint {c.kind} not supported yet")
|
|
404
404
|
used: set[str] = set()
|
|
405
405
|
for p in sketch.dimensions:
|
|
406
406
|
warnings += _dimension(ctx, drawable, used, p)
|
|
@@ -15,7 +15,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
15
15
|
for stream in (sys.stdout, sys.stderr):
|
|
16
16
|
reconfigure = getattr(stream, "reconfigure", None)
|
|
17
17
|
if reconfigure is not None:
|
|
18
|
-
reconfigure(encoding="utf-8")
|
|
18
|
+
reconfigure(encoding="utf-8", errors=stream.errors)
|
|
19
19
|
from f3d2solidcraft.cli import main as cli
|
|
20
20
|
|
|
21
21
|
return cli(argv[1:])
|
|
@@ -40,12 +40,22 @@ def partial_paths(output: Path, report: Path) -> list[Path]:
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def lead_own_group() -> None:
|
|
43
|
-
"""Called first thing in `--worker`: become a session (and group) leader when the window asked.
|
|
43
|
+
"""Called first thing in `--worker`: become a session (and group) leader when the window asked.
|
|
44
|
+
|
|
45
|
+
On Windows the window holds the worker in a Job object instead (`winjob`): the worker joins it
|
|
46
|
+
unless the window has put it there already, so no engine it starts is born outside the job.
|
|
47
|
+
"""
|
|
44
48
|
if os.environ.pop(OWN_GROUP, None) and hasattr(os, "setsid"):
|
|
45
49
|
try:
|
|
46
50
|
os.setsid()
|
|
47
51
|
except OSError:
|
|
48
52
|
pass # already a group leader: its group is its own anyway
|
|
53
|
+
if os.name == "nt":
|
|
54
|
+
from f3d2solidcraft_app.winjob import JOB_VARIABLE, join
|
|
55
|
+
|
|
56
|
+
job = os.environ.pop(JOB_VARIABLE, None)
|
|
57
|
+
if job:
|
|
58
|
+
join(job)
|
|
49
59
|
|
|
50
60
|
|
|
51
61
|
def kill_tree(pid: int) -> None:
|
|
@@ -57,7 +67,9 @@ def kill_tree(pid: int) -> None:
|
|
|
57
67
|
if pid <= 0:
|
|
58
68
|
return
|
|
59
69
|
if os.name == "nt":
|
|
60
|
-
#
|
|
70
|
+
# Only when the window could not hold the worker in a Job object (`winjob`), which is what
|
|
71
|
+
# kills the tree on Windows. /T takes the children still linked to `pid`, /F does not ask; an
|
|
72
|
+
# engine whose worker already died is out of its reach. No test reaches this path.
|
|
61
73
|
subprocess.run(
|
|
62
74
|
["taskkill", "/T", "/F", "/PID", str(pid)],
|
|
63
75
|
capture_output=True,
|
|
@@ -80,8 +92,8 @@ def kill_tree(pid: int) -> None:
|
|
|
80
92
|
def kill_group(pgid: int) -> None:
|
|
81
93
|
"""Sweep what is left of a worker's group after the worker itself is gone (Unix only).
|
|
82
94
|
|
|
83
|
-
The engines keep the group id when the worker dies, so this still reaches them. On Windows
|
|
84
|
-
|
|
95
|
+
The engines keep the group id when the worker dies, so this still reaches them. On Windows the
|
|
96
|
+
worker's Job object does this instead (`winjob.ProcessTree.close`).
|
|
85
97
|
"""
|
|
86
98
|
if pgid <= 0 or os.name == "nt":
|
|
87
99
|
return
|
|
@@ -38,6 +38,9 @@ from f3d2solidcraft_app.outcome import Outcome, outcome_from
|
|
|
38
38
|
from f3d2solidcraft_app.runner import OWN_GROUP, kill_group, kill_tree, partial_paths, worker_command
|
|
39
39
|
from f3d2solidcraft_app.texts import language, t
|
|
40
40
|
|
|
41
|
+
if sys.platform == "win32":
|
|
42
|
+
from f3d2solidcraft_app.winjob import JOB_VARIABLE, ProcessTree
|
|
43
|
+
|
|
41
44
|
FILE, CONVERT, RESULT, ENGINES = range(4)
|
|
42
45
|
DESIGN_SUFFIXES = {".f3d", ".f3z"}
|
|
43
46
|
DOWNLOAD_URL = "https://github.com/tangency-labs/solidcraft/releases"
|
|
@@ -68,6 +71,8 @@ class _Job:
|
|
|
68
71
|
pid: int
|
|
69
72
|
output: Path
|
|
70
73
|
report: Path
|
|
74
|
+
# Windows: the Job object the worker and its engines live in; closing it ends them all.
|
|
75
|
+
tree: "ProcessTree | None" = None
|
|
71
76
|
|
|
72
77
|
@property
|
|
73
78
|
def partials(self) -> list[Path]:
|
|
@@ -90,6 +95,7 @@ class Wizard(QMainWindow):
|
|
|
90
95
|
# Python in development; packaged, the app itself (`worker_command`).
|
|
91
96
|
self.executable = sys.executable
|
|
92
97
|
self.inspecting: QProcess | None = None
|
|
98
|
+
self.inspecting_tree: ProcessTree | None = None # Windows: the inspection's job
|
|
93
99
|
# The SolidCraft the check chose; None until a check has been answered.
|
|
94
100
|
self.solidcraft: EngineStatus | None = None
|
|
95
101
|
self.checking = False
|
|
@@ -141,8 +147,8 @@ class Wizard(QMainWindow):
|
|
|
141
147
|
choose.clicked.connect(self._choose_file)
|
|
142
148
|
self.holds_label = _plain(QLabel(""))
|
|
143
149
|
self.save_label = _plain(QLabel(""))
|
|
144
|
-
change_output = QPushButton(t("change_output", self.lang))
|
|
145
|
-
change_output.clicked.connect(self._choose_output)
|
|
150
|
+
self.change_output = QPushButton(t("change_output", self.lang))
|
|
151
|
+
self.change_output.clicked.connect(self._choose_output)
|
|
146
152
|
self.engines_label = _plain(QLabel("")) # versions as the engines print them
|
|
147
153
|
self.convert_button = QPushButton(t("convert", self.lang))
|
|
148
154
|
self.convert_button.setEnabled(False)
|
|
@@ -152,10 +158,11 @@ class Wizard(QMainWindow):
|
|
|
152
158
|
choose,
|
|
153
159
|
self.holds_label,
|
|
154
160
|
self.save_label,
|
|
155
|
-
change_output,
|
|
161
|
+
self.change_output,
|
|
156
162
|
self.engines_label,
|
|
157
163
|
):
|
|
158
164
|
box.addWidget(widget)
|
|
165
|
+
self._show_output_choice(False) # nothing to save, nor to change, before a file is loaded
|
|
159
166
|
row = QHBoxLayout()
|
|
160
167
|
row.addStretch()
|
|
161
168
|
row.addWidget(self.convert_button)
|
|
@@ -287,20 +294,60 @@ class Wizard(QMainWindow):
|
|
|
287
294
|
self._update_convert_button()
|
|
288
295
|
self.engines_checked.emit()
|
|
289
296
|
|
|
290
|
-
def _new_process(self) -> QProcess:
|
|
291
|
-
"""A converter process pinned to the SolidCraft the check chose.
|
|
297
|
+
def _new_process(self) -> tuple[QProcess, "ProcessTree | None"]:
|
|
298
|
+
"""A converter process pinned to the SolidCraft the check chose, and on Windows its job.
|
|
292
299
|
|
|
293
300
|
The converter resolves SolidCraft on its own with `locate_solidcraft()`, the first copy on
|
|
294
301
|
the PATH; the check picks the first one new enough. Passing the choice in
|
|
295
302
|
`F3D2SC_SOLIDCRAFT_CLI` makes both the same engine.
|
|
303
|
+
|
|
304
|
+
On Windows the job is made here, before the worker starts, so its name can go in the
|
|
305
|
+
worker's environment (`winjob`); `_start` puts the worker in it. None where there are process
|
|
306
|
+
groups instead, or if Windows refused to make one (then `kill_tree` falls back to taskkill).
|
|
296
307
|
"""
|
|
297
308
|
process = QProcess(self)
|
|
298
309
|
environment = QProcessEnvironment.systemEnvironment()
|
|
299
310
|
environment.insert(OWN_GROUP, "1") # so `kill_tree` reaches the engines too
|
|
300
311
|
if self.solidcraft is not None and self.solidcraft.ok and self.solidcraft.path is not None:
|
|
301
312
|
environment.insert("F3D2SC_SOLIDCRAFT_CLI", str(self.solidcraft.path))
|
|
313
|
+
tree = None
|
|
314
|
+
if sys.platform == "win32":
|
|
315
|
+
try:
|
|
316
|
+
tree = ProcessTree()
|
|
317
|
+
except OSError as exc:
|
|
318
|
+
print(f"f3d2solidcraft: no job object for the worker: {exc}", file=sys.stderr)
|
|
319
|
+
else:
|
|
320
|
+
environment.insert(JOB_VARIABLE, tree.name)
|
|
302
321
|
process.setProcessEnvironment(environment)
|
|
303
|
-
return process
|
|
322
|
+
return process, tree
|
|
323
|
+
|
|
324
|
+
@staticmethod
|
|
325
|
+
def _start(process: QProcess, tree: "ProcessTree | None", command: list[str]) -> "ProcessTree | None":
|
|
326
|
+
"""Start `process` and put it in `tree` at once; the tree, or None if there is none to keep.
|
|
327
|
+
|
|
328
|
+
A worker the window could not assign still joins the job itself (`winjob.join`), so the
|
|
329
|
+
tree is kept: closing it is still what ends whatever is inside.
|
|
330
|
+
"""
|
|
331
|
+
process.start(command[0], command[1:])
|
|
332
|
+
if tree is None:
|
|
333
|
+
return None
|
|
334
|
+
pid = process.processId()
|
|
335
|
+
if not pid: # it did not start: nothing can be inside
|
|
336
|
+
tree.close()
|
|
337
|
+
return None
|
|
338
|
+
try:
|
|
339
|
+
tree.add(pid)
|
|
340
|
+
except OSError as exc:
|
|
341
|
+
print(f"f3d2solidcraft: could not put the worker in its job object: {exc}", file=sys.stderr)
|
|
342
|
+
return tree
|
|
343
|
+
|
|
344
|
+
@staticmethod
|
|
345
|
+
def _end_tree(tree: "ProcessTree | None", pid: int) -> None:
|
|
346
|
+
"""Kill a running worker with every process under it: its job on Windows, its group elsewhere."""
|
|
347
|
+
if tree is not None:
|
|
348
|
+
tree.close()
|
|
349
|
+
else:
|
|
350
|
+
kill_tree(pid)
|
|
304
351
|
|
|
305
352
|
def _update_convert_button(self) -> None:
|
|
306
353
|
self.convert_button.setEnabled(self.engines_ready and self.inspected and self.input is not None)
|
|
@@ -372,6 +419,11 @@ class Wizard(QMainWindow):
|
|
|
372
419
|
self.save_label.setText(t("save_as", self.lang, name=path.name))
|
|
373
420
|
return True
|
|
374
421
|
|
|
422
|
+
def _show_output_choice(self, shown: bool) -> None:
|
|
423
|
+
"""The "Save as" line and its «Change…» button: only with a file loaded, which gives them a name."""
|
|
424
|
+
self.save_label.setVisible(shown)
|
|
425
|
+
self.change_output.setVisible(shown)
|
|
426
|
+
|
|
375
427
|
def _forget_file(self) -> None:
|
|
376
428
|
"""No file loaded: nothing the card no longer shows can be converted."""
|
|
377
429
|
self.input = self.output = None
|
|
@@ -379,6 +431,7 @@ class Wizard(QMainWindow):
|
|
|
379
431
|
self.inspected = False
|
|
380
432
|
self.drop_label.setText(t("drop_here", self.lang))
|
|
381
433
|
self.save_label.setText("")
|
|
434
|
+
self._show_output_choice(False)
|
|
382
435
|
self._update_convert_button()
|
|
383
436
|
|
|
384
437
|
def load_file(self, path: Path) -> None:
|
|
@@ -393,6 +446,7 @@ class Wizard(QMainWindow):
|
|
|
393
446
|
self.inspected = False
|
|
394
447
|
self._update_convert_button()
|
|
395
448
|
self.save_label.setText(t("save_as", self.lang, name=self.output.name))
|
|
449
|
+
self._show_output_choice(True)
|
|
396
450
|
self.drop_label.setText(path.name)
|
|
397
451
|
self.holds_label.setText("")
|
|
398
452
|
# Before the check answers there is no engine to pin yet: `_engines_checked` inspects then.
|
|
@@ -400,12 +454,18 @@ class Wizard(QMainWindow):
|
|
|
400
454
|
self._inspect()
|
|
401
455
|
|
|
402
456
|
def _inspect(self) -> None:
|
|
403
|
-
inspect = self._new_process()
|
|
457
|
+
inspect, tree = self._new_process()
|
|
404
458
|
self.inspecting = inspect
|
|
405
459
|
command = worker_command(["inspect", str(self.input), "--json"], self.executable)
|
|
406
|
-
|
|
460
|
+
|
|
461
|
+
def finished(code: int, _status: QProcess.ExitStatus) -> None:
|
|
462
|
+
if tree is not None:
|
|
463
|
+
tree.close() # Windows: nothing the inspection started outlives it
|
|
464
|
+
self._inspected(inspect, code)
|
|
465
|
+
|
|
466
|
+
inspect.finished.connect(finished)
|
|
407
467
|
inspect.errorOccurred.connect(lambda error: self._inspect_error(inspect, error))
|
|
408
|
-
|
|
468
|
+
self.inspecting_tree = self._start(inspect, tree, command)
|
|
409
469
|
|
|
410
470
|
def _inspect_error(self, process: QProcess, error: QProcess.ProcessError) -> None:
|
|
411
471
|
# Only a start failure: anything later also ends in `finished`, which answers it.
|
|
@@ -468,7 +528,7 @@ class Wizard(QMainWindow):
|
|
|
468
528
|
self.progress_label.setText(t("starting", self.lang))
|
|
469
529
|
self.bar.setRange(0, 0)
|
|
470
530
|
self._show(CONVERT)
|
|
471
|
-
process = self._new_process()
|
|
531
|
+
process, tree = self._new_process()
|
|
472
532
|
job = _Job(process, 0, self.output, self.report)
|
|
473
533
|
self.job = job
|
|
474
534
|
process.readyReadStandardOutput.connect(self._read_progress)
|
|
@@ -486,7 +546,7 @@ class Wizard(QMainWindow):
|
|
|
486
546
|
"--progress",
|
|
487
547
|
]
|
|
488
548
|
command = worker_command(args, self.executable)
|
|
489
|
-
|
|
549
|
+
job.tree = self._start(process, tree, command)
|
|
490
550
|
job.pid = process.processId() # the fork happens in start(); 0 if it failed
|
|
491
551
|
|
|
492
552
|
def _read_progress(self) -> None:
|
|
@@ -511,7 +571,9 @@ class Wizard(QMainWindow):
|
|
|
511
571
|
def _kill(self, job: _Job) -> None:
|
|
512
572
|
"""The worker and the engines under it: `QProcess.kill()` alone reaches only the worker."""
|
|
513
573
|
pid = job.process.processId() or job.pid
|
|
514
|
-
if job.
|
|
574
|
+
if job.tree is not None:
|
|
575
|
+
job.tree.close() # whatever state the worker is in: its engines may outlive it
|
|
576
|
+
elif job.process.state() != QProcess.ProcessState.NotRunning:
|
|
515
577
|
kill_tree(pid)
|
|
516
578
|
job.process.kill()
|
|
517
579
|
|
|
@@ -538,6 +600,10 @@ class Wizard(QMainWindow):
|
|
|
538
600
|
crashed = status == QProcess.ExitStatus.CrashExit
|
|
539
601
|
if self.cancelled or crashed:
|
|
540
602
|
kill_group(job.pid) # whatever the worker left behind keeps its group id
|
|
603
|
+
if job.tree is not None:
|
|
604
|
+
# Windows: whatever the worker left behind is still in its job, however it ended (a worker
|
|
605
|
+
# ended from outside exits with the code it was given, not as a crash).
|
|
606
|
+
job.tree.close()
|
|
541
607
|
self.job = None
|
|
542
608
|
job.process.deleteLater()
|
|
543
609
|
self.output, self.report = job.output, job.report
|
|
@@ -567,13 +633,13 @@ class Wizard(QMainWindow):
|
|
|
567
633
|
self.cancelled = True
|
|
568
634
|
self._kill(job)
|
|
569
635
|
job.process.waitForFinished(5_000) # delivers `finished`, which removes the partials
|
|
570
|
-
kill_group(job.pid)
|
|
636
|
+
kill_group(job.pid) # Windows: `_kill` has closed the job, which ended the whole tree
|
|
571
637
|
for partial in job.partials:
|
|
572
638
|
_remove(partial)
|
|
573
639
|
inspecting = self.inspecting
|
|
574
640
|
if inspecting is not None and inspecting.state() != QProcess.ProcessState.NotRunning:
|
|
575
641
|
self.inspecting = None
|
|
576
|
-
|
|
642
|
+
self._end_tree(self.inspecting_tree, inspecting.processId())
|
|
577
643
|
inspecting.kill()
|
|
578
644
|
inspecting.waitForFinished(2_000)
|
|
579
645
|
super().closeEvent(event)
|
|
@@ -635,6 +701,7 @@ class Wizard(QMainWindow):
|
|
|
635
701
|
self.drop_label.setText(t("drop_here", self.lang))
|
|
636
702
|
self.holds_label.setText("")
|
|
637
703
|
self.save_label.setText("")
|
|
704
|
+
self._show_output_choice(False)
|
|
638
705
|
self.convert_button.setEnabled(False)
|
|
639
706
|
self._show(FILE)
|
|
640
707
|
|