f3d2solidcraft 0.3.1__tar.gz → 0.3.2__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.1 → f3d2solidcraft-0.3.2}/.github/workflows/ci.yml +1 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/.github/workflows/release.yml +40 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/CHANGELOG.md +11 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/PKG-INFO +1 -1
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/pyproject.toml +1 -1
- f3d2solidcraft-0.3.2/scripts/smoke_packaged.py +151 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/__init__.py +1 -1
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/__main__.py +5 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/runner.py +16 -2
- f3d2solidcraft-0.3.2/src/f3d2solidcraft_app/stdio.py +122 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/window.py +19 -10
- f3d2solidcraft-0.3.2/tests/app/test_stdio.py +101 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_window.py +32 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/LICENSE +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/README.md +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/docs/guia.md +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/docs/media/demo.gif +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/scripts/fetch_cadmpeg.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/__main__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/LICENSE +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/container/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/container/archive.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/parameters.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/sketch.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/timeline.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/manifest.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/primitives.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/segment.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/cli.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/engine.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/fallback.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/geometry.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/bodies.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/combine.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/components.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/edges.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/extrude.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/faces.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/loft.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/outputs.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/params.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/pattern.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/planes.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/primitives.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/records.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/revolve.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/sheet.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/shell.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mappers/sketch.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/mcp.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/model.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/oracle.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/pairing.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/reader/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/reader/cadir.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/reader/fusion.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/reader/locale.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/replay.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/report.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/tools.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/verify.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/visibility.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/engines.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/events.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/opener.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/outcome.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-128.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-16.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-256.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-32.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-512.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon-64.png +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon.icns +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon.ico +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/resources/icon.svg +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/texts.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft_app/winjob.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/__init__.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/conftest.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_engines_runner.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_events_outcome.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_icon.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_opener.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_packaging.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_texts.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/app/test_winjob.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/conftest.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_bench.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_bezier_spans.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_bodies.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_cli.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_combine.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_components.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_condemnation.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_conics.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_declared_edges.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_engine.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_extents.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_faces.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_fetch_cadmpeg.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_geometry.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_inspect_json.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_locations.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_loft.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_mappers.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_mcp.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_naming.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_oracle.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_pairing.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_partial_sketches.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_pattern.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_primitives.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_progress.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_reader.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_replay.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_revolve.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_rollback.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_sheet.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_shell.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_tilted_planes.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_tools.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_trimmed_region.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_unmeasurable.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_unnamed_sketches.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_verify.py +0 -0
- {f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/tests/test_visibility.py +0 -0
|
@@ -150,6 +150,46 @@ jobs:
|
|
|
150
150
|
- run: uv run --no-project python scripts/fetch_cadmpeg.py
|
|
151
151
|
- run: uvx briefcase==0.4.7 create ${{ matrix.platform }} ${{ matrix.format }} ${{ matrix.flags }} --no-input
|
|
152
152
|
- run: uvx briefcase==0.4.7 build ${{ matrix.platform }} ${{ matrix.format }} ${{ matrix.flags }} --no-input
|
|
153
|
+
# The built app itself, run as the window runs it, before it is packaged: `--check`, the worker's
|
|
154
|
+
# inspection and a real conversion with `--progress`, each read with the window's own code and
|
|
155
|
+
# failing on empty output. On Windows from a parent with no console, like the window: Briefcase's
|
|
156
|
+
# stub sends stdout to a log file then, which is how 0.3.1's app lost everything its worker wrote
|
|
157
|
+
# («Could not read the file: exit code 0»). The tests run from source through a console Python and
|
|
158
|
+
# never saw it. SolidCraft is the runner's, pinned like in ci.yml; cadmpeg is the one in the app.
|
|
159
|
+
- name: The built app answers as the window expects
|
|
160
|
+
env:
|
|
161
|
+
SOLIDCRAFT: "0.43.0"
|
|
162
|
+
SAMPLE_URL: https://github.com/user-attachments/files/33617507/test.weird.box_f3d.zip
|
|
163
|
+
run: |
|
|
164
|
+
set -euo pipefail
|
|
165
|
+
tmp=$(mktemp -d)
|
|
166
|
+
url="https://github.com/tangency-labs/solidcraft/releases/download/v$SOLIDCRAFT"
|
|
167
|
+
curl -fsSL -o "$tmp/SHA256SUMS.txt" "$url/SHA256SUMS.txt"
|
|
168
|
+
case "$RUNNER_OS" in
|
|
169
|
+
Linux)
|
|
170
|
+
asset="solidcraft-$SOLIDCRAFT-linux-x86_64.tar.gz"
|
|
171
|
+
curl -fsSL -o "$tmp/$asset" "$url/$asset"
|
|
172
|
+
( cd "$tmp" && grep " $asset\$" SHA256SUMS.txt | sha256sum -c - )
|
|
173
|
+
tar -xzf "$tmp/$asset" -C "$tmp" --strip-components=2 "solidcraft-$SOLIDCRAFT-linux-x86_64/bin/solidcraft-cli"
|
|
174
|
+
cli="$tmp/solidcraft-cli" ;;
|
|
175
|
+
macOS)
|
|
176
|
+
asset="solidcraft-cli-$SOLIDCRAFT-macos-universal.zip"
|
|
177
|
+
curl -fsSL -o "$tmp/$asset" "$url/$asset"
|
|
178
|
+
( cd "$tmp" && grep " $asset\$" SHA256SUMS.txt | shasum -a 256 -c - )
|
|
179
|
+
unzip -q "$tmp/$asset" -d "$tmp"
|
|
180
|
+
cli="$tmp/solidcraft-cli-$SOLIDCRAFT-macos-universal/solidcraft-cli" ;;
|
|
181
|
+
Windows)
|
|
182
|
+
asset="solidcraft-$SOLIDCRAFT-windows-x64-portable.zip"
|
|
183
|
+
curl -fsSL -o "$tmp/$asset" "$url/$asset"
|
|
184
|
+
( cd "$tmp" && grep " $asset\$" SHA256SUMS.txt | sha256sum -c - )
|
|
185
|
+
unzip -q "$tmp/$asset" -d "$tmp"
|
|
186
|
+
cli=$(cygpath -w "$tmp/solidcraft-$SOLIDCRAFT-windows-x64-portable/solidcraft-cli.exe") ;;
|
|
187
|
+
esac
|
|
188
|
+
chmod +x "$cli" 2>/dev/null || true
|
|
189
|
+
export F3D2SC_SOLIDCRAFT_CLI="$cli"
|
|
190
|
+
curl -fsSL -o "$tmp/sample.zip" "$SAMPLE_URL"
|
|
191
|
+
uv run --no-project python -m zipfile -e "$tmp/sample.zip" "$tmp/sample"
|
|
192
|
+
uv run --no-project python scripts/smoke_packaged.py build "$tmp/sample/test weird box.f3d" "$tmp/out"
|
|
153
193
|
- run: uvx briefcase==0.4.7 package ${{ matrix.platform }} ${{ matrix.format }} ${{ matrix.flags }} ${{ matrix.platform == 'macOS' && '--adhoc-sign' || '' }} --no-input
|
|
154
194
|
- uses: actions/upload-artifact@v4
|
|
155
195
|
with:
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
- Windows app: loading a file failed with "Could not read the file: exit code 0", whatever the file. The
|
|
6
|
+
installed app runs its own converter in a second process, and the launcher Briefcase builds sent that process's
|
|
7
|
+
output to a log file instead of back to the window whenever it was started without a console, which is always
|
|
8
|
+
the case from the window. The window now reads the converter's output and errors from one pipe, which survives
|
|
9
|
+
that launcher, and the converter writes back to it.
|
|
10
|
+
- Release: before packaging, each installer's built app is run as the window runs it (from a parent with no
|
|
11
|
+
console on Windows): `--check`, inspecting the public sample and a full conversion with progress, which must
|
|
12
|
+
end verified. A build whose app prints nothing fails the release.
|
|
13
|
+
|
|
3
14
|
## 0.3.1
|
|
4
15
|
|
|
5
16
|
- Desktop app: the "Save as" line and its "Change…" button only appear once a file is loaded.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: f3d2solidcraft
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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
|
|
@@ -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.2" # 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,151 @@
|
|
|
1
|
+
"""Run the app Briefcase built, as the window runs it, before it is packaged (release.yml).
|
|
2
|
+
|
|
3
|
+
python scripts/smoke_packaged.py BUILD_DIR SAMPLE OUT_DIR
|
|
4
|
+
|
|
5
|
+
The tests run the app from source, through a console Python. The installers run the executable
|
|
6
|
+
Briefcase builds, which on Windows is a GUI program: a bug in how that program writes to the pipes
|
|
7
|
+
the window gives it (0.3.1: «Could not read the file: exit code 0» on any file) never reached a test.
|
|
8
|
+
This starts the built executable itself, with pipes, the way the window's QProcess does, and reads
|
|
9
|
+
what comes back with the window's own code (`events.parse`, `outcome_from`):
|
|
10
|
+
|
|
11
|
+
1. `--check`: the engine lines and the worker line, exit 0.
|
|
12
|
+
2. `--worker inspect SAMPLE --json`: the counts line the first step shows.
|
|
13
|
+
3. `--worker convert SAMPLE ... --progress`: feature events, `done` with exit 0, a verified report.
|
|
14
|
+
|
|
15
|
+
On Windows it first lets go of its console: the window is a GUI program and has none, and Briefcase's
|
|
16
|
+
stub decides where the worker's stdout goes by whether its parent has one (`AttachConsole`). Run from
|
|
17
|
+
a CI shell, which has a console, the stub kept the pipes and 0.3.1 passed here. Each run gets one
|
|
18
|
+
pipe for stdout and stderr and `F3D2SC_WORKER_ONE_PIPE=1`, as the window starts the worker
|
|
19
|
+
(`f3d2solidcraft_app.stdio`); `--check` too, as any parent without a console has to.
|
|
20
|
+
|
|
21
|
+
Each fails on empty output, whatever the exit code. SolidCraft is the runner's (`F3D2SC_SOLIDCRAFT_CLI`,
|
|
22
|
+
as the window pins it); cadmpeg is the one inside the built app, as the window points the worker at it.
|
|
23
|
+
Stdlib only, plus the two pure modules of the window it imports from `src/`.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import json
|
|
29
|
+
import os
|
|
30
|
+
import subprocess
|
|
31
|
+
import sys
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
|
|
34
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
|
|
35
|
+
|
|
36
|
+
from f3d2solidcraft_app.events import Done, Feature, parse
|
|
37
|
+
from f3d2solidcraft_app.outcome import outcome_from
|
|
38
|
+
from f3d2solidcraft_app.stdio import ONE_PIPE
|
|
39
|
+
|
|
40
|
+
#: What `test weird box.f3d`, the public sample the CI uses, holds.
|
|
41
|
+
EXPECTED = {"parameters": 32, "sketches": 8, "features": 26}
|
|
42
|
+
TIMEOUT = 900
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SmokeFailed(SystemExit):
|
|
46
|
+
pass
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def built_app(build: Path) -> tuple[Path, Path]:
|
|
50
|
+
"""The executable Briefcase built for this system, and the cadmpeg inside it."""
|
|
51
|
+
if sys.platform == "win32":
|
|
52
|
+
candidates = list(build.glob("*/windows/app/src/*.exe"))
|
|
53
|
+
elif sys.platform == "darwin":
|
|
54
|
+
candidates = [p for p in build.glob("*/macos/app/*.app/Contents/MacOS/*") if p.is_file()]
|
|
55
|
+
else:
|
|
56
|
+
# The AppImage users run, wherever this Briefcase leaves it; else the folder it is made from.
|
|
57
|
+
images = [
|
|
58
|
+
*build.rglob("f3d2solidcraft*.AppImage"),
|
|
59
|
+
*build.parent.joinpath("dist").glob("f3d2solidcraft*.AppImage"),
|
|
60
|
+
]
|
|
61
|
+
candidates = images or list(build.glob("*/linux/appimage/*.AppDir/AppRun"))
|
|
62
|
+
if len(candidates) != 1:
|
|
63
|
+
raise SmokeFailed(f"expected one built executable under {build}, found {candidates}")
|
|
64
|
+
name = "cadmpeg.exe" if sys.platform == "win32" else "cadmpeg"
|
|
65
|
+
cadmpegs = [p for p in build.rglob(name) if p.parent.parts[-2:] == ("resources", "bin")]
|
|
66
|
+
if not cadmpegs:
|
|
67
|
+
raise SmokeFailed(f"no bundled {name} under {build}")
|
|
68
|
+
return candidates[0], cadmpegs[0]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def without_console() -> None:
|
|
72
|
+
"""Windows: be a parent with no console, as the window is, for every program started from here.
|
|
73
|
+
|
|
74
|
+
Our own output is a pipe to the CI log, which `FreeConsole` leaves alone.
|
|
75
|
+
"""
|
|
76
|
+
if sys.platform == "win32":
|
|
77
|
+
import ctypes
|
|
78
|
+
|
|
79
|
+
ctypes.windll.kernel32.FreeConsole()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def run(command: list[str], env: dict[str, str]) -> tuple[int, str, str]:
|
|
83
|
+
"""Exit code, the whole pipe, and its lines that are not progress events (the window's `stderr`)."""
|
|
84
|
+
print("$", " ".join(command), flush=True)
|
|
85
|
+
done = subprocess.run(
|
|
86
|
+
command,
|
|
87
|
+
stdout=subprocess.PIPE,
|
|
88
|
+
stderr=subprocess.STDOUT,
|
|
89
|
+
env={**env, ONE_PIPE: "1"},
|
|
90
|
+
timeout=TIMEOUT,
|
|
91
|
+
check=False,
|
|
92
|
+
)
|
|
93
|
+
out = done.stdout.decode("utf-8", "replace")
|
|
94
|
+
print(f"exit {done.returncode}\n--- stdout and stderr ---\n{out}--------------", flush=True)
|
|
95
|
+
if not out.strip():
|
|
96
|
+
raise SmokeFailed(f"{command[1:3]}: nothing on the pipe (exit {done.returncode})")
|
|
97
|
+
text = "".join(line + "\n" for line in out.splitlines() if parse(line) is None)
|
|
98
|
+
return done.returncode, out, text
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def main(argv: list[str]) -> int:
|
|
102
|
+
build, sample, out_dir = (Path(a).resolve() for a in argv)
|
|
103
|
+
exe, cadmpeg = built_app(build)
|
|
104
|
+
without_console()
|
|
105
|
+
print(f"built app: {exe}\nbundled cadmpeg: {cadmpeg}", flush=True)
|
|
106
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
base = dict(os.environ)
|
|
108
|
+
base.pop("F3D2SC_CADMPEG", None)
|
|
109
|
+
if sys.platform.startswith("linux"):
|
|
110
|
+
base["APPIMAGE_EXTRACT_AND_RUN"] = "1" # no FUSE on the runner
|
|
111
|
+
|
|
112
|
+
# 1. `--check` finds the bundled cadmpeg on its own, like the window's first screen.
|
|
113
|
+
code, out, _ = run([str(exe), "--check"], base)
|
|
114
|
+
if code != 0 or "worker:" not in out or "cadmpeg:" not in out:
|
|
115
|
+
raise SmokeFailed(f"--check did not pass (exit {code})")
|
|
116
|
+
# The window starts `worker_command(..., sys.executable)`: it must be this same executable, or the
|
|
117
|
+
# runs below would test a worker the window never starts. (An AppImage runs from a mount or an
|
|
118
|
+
# extracted copy, so on Linux the path differs by design.)
|
|
119
|
+
if not sys.platform.startswith("linux") and f"worker: {exe} --worker " not in out:
|
|
120
|
+
raise SmokeFailed(f"the window would not start {exe} as its worker")
|
|
121
|
+
|
|
122
|
+
# The worker gets what the window puts in its environment (`Wizard._new_process`).
|
|
123
|
+
worker = {**base, "F3D2SC_CADMPEG": str(cadmpeg), "F3D2SC_WORKER_OWN_GROUP": "1"}
|
|
124
|
+
|
|
125
|
+
# 2. The first step's inspection.
|
|
126
|
+
code, out, _ = run([str(exe), "--worker", "inspect", str(sample), "--json"], worker)
|
|
127
|
+
counts = next((json.loads(line) for line in out.splitlines() if line.startswith("{")), None)
|
|
128
|
+
if code != 0 or counts != EXPECTED:
|
|
129
|
+
raise SmokeFailed(f"inspect: exit {code}, counts {counts}, expected {EXPECTED}")
|
|
130
|
+
|
|
131
|
+
# 3. The conversion, read as the window reads it.
|
|
132
|
+
output = out_dir / "sample.solidcraft"
|
|
133
|
+
report = out_dir / "sample.report.json"
|
|
134
|
+
command = [str(exe), "--worker", "convert", str(sample), "-o", str(output)]
|
|
135
|
+
code, out, err = run([*command, "--report", str(report), "--force", "--progress"], worker)
|
|
136
|
+
events = [e for e in map(parse, out.splitlines()) if e is not None]
|
|
137
|
+
features = [e for e in events if isinstance(e, Feature)]
|
|
138
|
+
if not features or events[-1] != Done(0):
|
|
139
|
+
raise SmokeFailed(f"convert: {len(features)} feature events, last event {events[-1:]}")
|
|
140
|
+
data = json.loads(report.read_text(encoding="utf-8"))
|
|
141
|
+
if code != 0 or not output.is_file() or data["verification"]["ok"] is not True:
|
|
142
|
+
raise SmokeFailed(f"convert: exit {code}, verification {data['verification']}")
|
|
143
|
+
outcome = outcome_from(code, data, err)
|
|
144
|
+
if outcome.kind != "verified":
|
|
145
|
+
raise SmokeFailed(f"the window would show {outcome.kind}: {outcome.message}")
|
|
146
|
+
print(f"ok: {len(features)} feature events, verified, {outcome.editable}/{outcome.total} editable")
|
|
147
|
+
return 0
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
if __name__ == "__main__":
|
|
151
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -5,6 +5,11 @@ import sys
|
|
|
5
5
|
|
|
6
6
|
def main(argv: list[str] | None = None) -> int:
|
|
7
7
|
argv = sys.argv[1:] if argv is None else argv
|
|
8
|
+
if argv[:1] in (["--worker"], ["--check"]):
|
|
9
|
+
# Packaged on Windows, the launcher may have moved stdout off the window's pipe (`stdio`).
|
|
10
|
+
from f3d2solidcraft_app.stdio import attach_std_streams
|
|
11
|
+
|
|
12
|
+
attach_std_streams()
|
|
8
13
|
if argv[:1] == ["--worker"]:
|
|
9
14
|
from f3d2solidcraft_app.runner import lead_own_group
|
|
10
15
|
|
|
@@ -6,6 +6,8 @@ import subprocess
|
|
|
6
6
|
import sys
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
+
from f3d2solidcraft_app.stdio import ONE_PIPE
|
|
10
|
+
|
|
9
11
|
#: Set by the window in the worker's environment: the worker then leads a process group of its own,
|
|
10
12
|
#: so cancelling can reach the engines it starts (`kill_tree`). A worker run by hand from a terminal
|
|
11
13
|
#: does not get it and stays in the terminal's group, where Ctrl-C reaches it.
|
|
@@ -27,11 +29,23 @@ def check_worker(executable: str = sys.executable) -> tuple[list[str], str | Non
|
|
|
27
29
|
"""
|
|
28
30
|
command = worker_command(["--help"], executable)
|
|
29
31
|
try:
|
|
30
|
-
|
|
32
|
+
# One pipe for both streams, as the window starts it (`stdio`: that is what lets a packaged
|
|
33
|
+
# Windows worker keep its stdout).
|
|
34
|
+
done = subprocess.run(
|
|
35
|
+
command,
|
|
36
|
+
env={**os.environ, ONE_PIPE: "1"},
|
|
37
|
+
stdout=subprocess.PIPE,
|
|
38
|
+
stderr=subprocess.STDOUT,
|
|
39
|
+
text=True,
|
|
40
|
+
encoding="utf-8",
|
|
41
|
+
errors="replace",
|
|
42
|
+
timeout=120,
|
|
43
|
+
check=False,
|
|
44
|
+
)
|
|
31
45
|
except (OSError, subprocess.SubprocessError) as exc:
|
|
32
46
|
return command, f"does not run: {exc}"
|
|
33
47
|
if done.returncode != 0 or "convert" not in done.stdout:
|
|
34
|
-
return command, f"did not answer as the converter (exit {done.returncode}): {done.
|
|
48
|
+
return command, f"did not answer as the converter (exit {done.returncode}): {done.stdout[-300:]}"
|
|
35
49
|
return command, None
|
|
36
50
|
|
|
37
51
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""The worker's output, back on the pipe the window reads (Windows, packaged app).
|
|
2
|
+
|
|
3
|
+
The packaged Windows app is Briefcase's GUI stub (stub b14 under Briefcase 0.4.7), and it is also its
|
|
4
|
+
own worker. Before Python starts, the stub asks for its parent's console (`AttachConsole`). The window
|
|
5
|
+
has none, so the stub reopens the C runtime's stdout onto a log file under
|
|
6
|
+
`%LOCALAPPDATA%\\<author>\\f3d2solidcraft\\Logs`: that closes the pipe the window passed as stdout and
|
|
7
|
+
makes the log the process's standard output handle. Everything the worker printed (the counts line,
|
|
8
|
+
the progress events) went into that log, with exit code 0 and nothing on the pipe: «Could not read the
|
|
9
|
+
file: exit code 0» in 0.3.1. Measured on the release runner with a parent that has no console.
|
|
10
|
+
|
|
11
|
+
The stub leaves stderr alone. So the window starts the worker with stdout and stderr merged into one
|
|
12
|
+
pipe (`QProcess.MergedChannels`; `stderr=STDOUT` in `runner.check_worker`) and says so in `ONE_PIPE`.
|
|
13
|
+
The C runtime does not close a handle that stdout shares with stderr, so the pipe survives the stub's
|
|
14
|
+
redirect as stderr, and `attach_std_streams` points `sys.stdout` at it too.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import os
|
|
20
|
+
import sys
|
|
21
|
+
from collections.abc import MutableMapping
|
|
22
|
+
|
|
23
|
+
#: Set by whoever starts the worker with stdout and stderr in one pipe (the window, `check_worker`).
|
|
24
|
+
ONE_PIPE = "F3D2SC_WORKER_ONE_PIPE"
|
|
25
|
+
|
|
26
|
+
STD_OUTPUT_HANDLE = -11
|
|
27
|
+
STD_ERROR_HANDLE = -12
|
|
28
|
+
FILE_TYPE_UNKNOWN = 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _os_handle(stream) -> int | None:
|
|
32
|
+
"""The Windows handle under a Python stream, or None if it has no usable descriptor."""
|
|
33
|
+
import msvcrt
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
return msvcrt.get_osfhandle(stream.fileno())
|
|
37
|
+
except (AttributeError, OSError, ValueError):
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _kernel32():
|
|
42
|
+
import ctypes
|
|
43
|
+
from ctypes import wintypes
|
|
44
|
+
|
|
45
|
+
kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
46
|
+
kernel32.GetCurrentProcess.restype = wintypes.HANDLE
|
|
47
|
+
kernel32.GetStdHandle.restype = wintypes.HANDLE
|
|
48
|
+
kernel32.GetFileType.argtypes = [wintypes.HANDLE]
|
|
49
|
+
kernel32.DuplicateHandle.argtypes = [
|
|
50
|
+
wintypes.HANDLE,
|
|
51
|
+
wintypes.HANDLE,
|
|
52
|
+
wintypes.HANDLE,
|
|
53
|
+
ctypes.POINTER(wintypes.HANDLE),
|
|
54
|
+
wintypes.DWORD,
|
|
55
|
+
wintypes.BOOL,
|
|
56
|
+
wintypes.DWORD,
|
|
57
|
+
]
|
|
58
|
+
return kernel32
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _open_handle(handle: int, errors: str):
|
|
62
|
+
"""A UTF-8, line-buffered text stream on a duplicate of `handle`, which stays open on its own.
|
|
63
|
+
|
|
64
|
+
A duplicate, so closing this stream (Python does at exit) never closes the handle stderr is on.
|
|
65
|
+
"""
|
|
66
|
+
import ctypes
|
|
67
|
+
import msvcrt
|
|
68
|
+
from ctypes import wintypes
|
|
69
|
+
|
|
70
|
+
kernel32 = _kernel32()
|
|
71
|
+
duplicate = wintypes.HANDLE()
|
|
72
|
+
me = kernel32.GetCurrentProcess()
|
|
73
|
+
if not kernel32.DuplicateHandle(me, handle, me, ctypes.byref(duplicate), 0, False, 2): # SAME_ACCESS
|
|
74
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
75
|
+
fd = msvcrt.open_osfhandle(duplicate.value, os.O_WRONLY)
|
|
76
|
+
return open(fd, "w", encoding="utf-8", errors=errors, buffering=1)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _std_handle(which: int) -> int | None:
|
|
80
|
+
"""The process's standard handle `which`, or None when there is none usable (a double click)."""
|
|
81
|
+
kernel32 = _kernel32()
|
|
82
|
+
handle = kernel32.GetStdHandle(which)
|
|
83
|
+
if not handle or handle in (-1, 2**64 - 1): # NULL, INVALID_HANDLE_VALUE
|
|
84
|
+
return None
|
|
85
|
+
return handle if kernel32.GetFileType(handle) != FILE_TYPE_UNKNOWN else None
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def attach_std_streams(environ: MutableMapping[str, str] = os.environ) -> None:
|
|
89
|
+
"""Windows: make the worker's `sys.stdout` and `sys.stderr` reach whoever started it.
|
|
90
|
+
|
|
91
|
+
- Started with one pipe for both (`ONE_PIPE`) and stdout is somewhere else: stdout joins stderr
|
|
92
|
+
on that pipe. This is the stub's log-file redirect undone.
|
|
93
|
+
- A stream that is None (a GUI program started with no console): onto the process's standard
|
|
94
|
+
handle when there is one, else onto a null sink, so a print never fails.
|
|
95
|
+
|
|
96
|
+
`ONE_PIPE` is taken out of the environment, so the engines the worker starts do not inherit it.
|
|
97
|
+
A no-op on macOS and Linux, from a console, and whenever stdout already shares stderr's pipe.
|
|
98
|
+
"""
|
|
99
|
+
one_pipe = environ.pop(ONE_PIPE, None) == "1"
|
|
100
|
+
if sys.platform != "win32":
|
|
101
|
+
return
|
|
102
|
+
if one_pipe and sys.stderr is not None:
|
|
103
|
+
err = _os_handle(sys.stderr)
|
|
104
|
+
if err is not None and _os_handle(sys.stdout) != err:
|
|
105
|
+
try:
|
|
106
|
+
sys.stdout = _open_handle(err, "strict")
|
|
107
|
+
except OSError:
|
|
108
|
+
pass # left where it was: no worse than before
|
|
109
|
+
for name, which, errors in (
|
|
110
|
+
("stdout", STD_OUTPUT_HANDLE, "strict"),
|
|
111
|
+
("stderr", STD_ERROR_HANDLE, "backslashreplace"),
|
|
112
|
+
):
|
|
113
|
+
if getattr(sys, name) is not None:
|
|
114
|
+
continue
|
|
115
|
+
handle = _std_handle(which)
|
|
116
|
+
if handle is not None:
|
|
117
|
+
try:
|
|
118
|
+
setattr(sys, name, _open_handle(handle, errors))
|
|
119
|
+
continue
|
|
120
|
+
except OSError:
|
|
121
|
+
pass
|
|
122
|
+
setattr(sys, name, open(os.devnull, "w", encoding="utf-8")) # noqa: SIM115 (lives as long as the process)
|
|
@@ -36,6 +36,7 @@ from f3d2solidcraft_app.events import Feature, parse
|
|
|
36
36
|
from f3d2solidcraft_app.opener import open_design
|
|
37
37
|
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
|
+
from f3d2solidcraft_app.stdio import ONE_PIPE
|
|
39
40
|
from f3d2solidcraft_app.texts import language, t
|
|
40
41
|
|
|
41
42
|
if sys.platform == "win32":
|
|
@@ -104,7 +105,7 @@ class Wizard(QMainWindow):
|
|
|
104
105
|
self._checker = _Checker()
|
|
105
106
|
self._checker.done.connect(self._engines_checked)
|
|
106
107
|
self.buffer = ""
|
|
107
|
-
self.stderr = ""
|
|
108
|
+
self.stderr = "" # the worker's text: every line of its one pipe that is not a progress event
|
|
108
109
|
self.cancelled = False
|
|
109
110
|
self.setWindowTitle(t("title", self.lang))
|
|
110
111
|
self.setAcceptDrops(True)
|
|
@@ -306,7 +307,12 @@ class Wizard(QMainWindow):
|
|
|
306
307
|
groups instead, or if Windows refused to make one (then `kill_tree` falls back to taskkill).
|
|
307
308
|
"""
|
|
308
309
|
process = QProcess(self)
|
|
310
|
+
# stdout and stderr in one pipe: packaged on Windows, the worker's launcher moves its stdout
|
|
311
|
+
# off the pipe it was given, and only a pipe shared with stderr survives that (`stdio`). The
|
|
312
|
+
# window tells the two apart by line: JSON lines are the converter's, the rest is its text.
|
|
313
|
+
process.setProcessChannelMode(QProcess.ProcessChannelMode.MergedChannels)
|
|
309
314
|
environment = QProcessEnvironment.systemEnvironment()
|
|
315
|
+
environment.insert(ONE_PIPE, "1")
|
|
310
316
|
environment.insert(OWN_GROUP, "1") # so `kill_tree` reaches the engines too
|
|
311
317
|
if self.solidcraft is not None and self.solidcraft.ok and self.solidcraft.path is not None:
|
|
312
318
|
environment.insert("F3D2SC_SOLIDCRAFT_CLI", str(self.solidcraft.path))
|
|
@@ -492,8 +498,12 @@ class Wizard(QMainWindow):
|
|
|
492
498
|
continue
|
|
493
499
|
break
|
|
494
500
|
if code != 0 or not isinstance(counts, dict):
|
|
495
|
-
err =
|
|
496
|
-
why =
|
|
501
|
+
err = "\n".join(line for line in out.splitlines() if not line.startswith("{")).strip()
|
|
502
|
+
why = (
|
|
503
|
+
_error_line(err).strip().splitlines()[-1].removeprefix("error: ")
|
|
504
|
+
if err
|
|
505
|
+
else f"exit code {code}"
|
|
506
|
+
)
|
|
497
507
|
self._forget_file()
|
|
498
508
|
self.holds_label.setText(t("inspect_failed", self.lang, why=why))
|
|
499
509
|
return
|
|
@@ -532,7 +542,6 @@ class Wizard(QMainWindow):
|
|
|
532
542
|
job = _Job(process, 0, self.output, self.report)
|
|
533
543
|
self.job = job
|
|
534
544
|
process.readyReadStandardOutput.connect(self._read_progress)
|
|
535
|
-
process.readyReadStandardError.connect(self._read_errors)
|
|
536
545
|
process.finished.connect(lambda code, status: self._finished(job, code, status))
|
|
537
546
|
process.errorOccurred.connect(lambda error: self._failed_to_start(job, error))
|
|
538
547
|
args = [
|
|
@@ -556,6 +565,8 @@ class Wizard(QMainWindow):
|
|
|
556
565
|
*lines, self.buffer = self.buffer.split("\n")
|
|
557
566
|
for line in lines:
|
|
558
567
|
event = parse(line)
|
|
568
|
+
if event is None: # the converter's own text (stderr and stdout share the pipe)
|
|
569
|
+
self.stderr += line.rstrip("\r") + "\n"
|
|
559
570
|
if isinstance(event, Feature):
|
|
560
571
|
self.bar.setRange(0, event.total)
|
|
561
572
|
self.bar.setValue(event.index)
|
|
@@ -563,11 +574,6 @@ class Wizard(QMainWindow):
|
|
|
563
574
|
t("progress", self.lang, index=event.index, total=event.total, name=event.name)
|
|
564
575
|
)
|
|
565
576
|
|
|
566
|
-
def _read_errors(self) -> None:
|
|
567
|
-
if self.process is None:
|
|
568
|
-
return
|
|
569
|
-
self.stderr += bytes(self.process.readAllStandardError()).decode("utf-8", "replace")
|
|
570
|
-
|
|
571
577
|
def _kill(self, job: _Job) -> None:
|
|
572
578
|
"""The worker and the engines under it: `QProcess.kill()` alone reaches only the worker."""
|
|
573
579
|
pid = job.process.processId() or job.pid
|
|
@@ -596,7 +602,10 @@ class Wizard(QMainWindow):
|
|
|
596
602
|
def _finished(self, job: _Job, code: int, status: QProcess.ExitStatus) -> None:
|
|
597
603
|
if job is not self.job:
|
|
598
604
|
return
|
|
599
|
-
self.
|
|
605
|
+
self._read_progress()
|
|
606
|
+
if self.buffer.strip() and parse(self.buffer) is None:
|
|
607
|
+
self.stderr += self.buffer # a last line without its newline
|
|
608
|
+
self.buffer = ""
|
|
600
609
|
crashed = status == QProcess.ExitStatus.CrashExit
|
|
601
610
|
if self.cancelled or crashed:
|
|
602
611
|
kill_group(job.pid) # whatever the worker left behind keeps its group id
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""`stdio.attach_std_streams`: the worker's stdout back on the window's pipe (Windows, packaged).
|
|
2
|
+
|
|
3
|
+
What the packaged Windows app does to its stdout (Briefcase's stub reopens it onto a log file before
|
|
4
|
+
Python starts) is reproduced here with real processes: the child moves its own fd 1 onto a file with
|
|
5
|
+
`os.dup2`, the same C runtime call path as the stub's `freopen`. The stub itself, started by a parent
|
|
6
|
+
with no console, is only reached by the packaged smoke in release.yml (scripts/smoke_packaged.py).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import subprocess
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
import pytest
|
|
16
|
+
|
|
17
|
+
from f3d2solidcraft_app.stdio import ONE_PIPE, attach_std_streams
|
|
18
|
+
|
|
19
|
+
windows = pytest.mark.skipif(sys.platform != "win32", reason="the stub's redirect is a Windows launcher's")
|
|
20
|
+
|
|
21
|
+
# The child: stdout taken off the pipe onto `log` (as the stub does), then the worker's first call.
|
|
22
|
+
HIJACKED = """
|
|
23
|
+
import os, sys
|
|
24
|
+
fd = os.open(sys.argv[1], os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
|
|
25
|
+
os.dup2(fd, 1)
|
|
26
|
+
from f3d2solidcraft_app.stdio import attach_std_streams
|
|
27
|
+
attach_std_streams()
|
|
28
|
+
print('{"parameters": 1}')
|
|
29
|
+
print("error: on stderr", file=sys.stderr)
|
|
30
|
+
print("flag left:", os.environ.get("F3D2SC_WORKER_ONE_PIPE"), file=sys.stderr)
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _run_hijacked(log: Path, one_pipe: bool) -> str:
|
|
35
|
+
env = {k: v for k, v in os.environ.items() if k != ONE_PIPE}
|
|
36
|
+
if one_pipe:
|
|
37
|
+
env[ONE_PIPE] = "1"
|
|
38
|
+
done = subprocess.run(
|
|
39
|
+
[sys.executable, "-c", HIJACKED, str(log)],
|
|
40
|
+
stdout=subprocess.PIPE,
|
|
41
|
+
stderr=subprocess.STDOUT,
|
|
42
|
+
env=env,
|
|
43
|
+
timeout=60,
|
|
44
|
+
check=True,
|
|
45
|
+
)
|
|
46
|
+
return done.stdout.decode("utf-8")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.skipif(sys.platform == "win32", reason="on Windows it would re-point pytest's own streams")
|
|
50
|
+
def test_elsewhere_the_flag_is_taken_out_and_nothing_else_changes():
|
|
51
|
+
environ = {ONE_PIPE: "1", "OTHER": "x"}
|
|
52
|
+
before = sys.stdout, sys.stderr
|
|
53
|
+
attach_std_streams(environ)
|
|
54
|
+
assert (sys.stdout, sys.stderr) == before
|
|
55
|
+
assert environ == {"OTHER": "x"}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@windows
|
|
59
|
+
def test_without_the_flag_the_redirect_loses_stdout(tmp_path):
|
|
60
|
+
# The control: this is 0.3.1's packaged worker, the counts line in a log and not on the pipe.
|
|
61
|
+
log = tmp_path / "stub.log"
|
|
62
|
+
out = _run_hijacked(log, one_pipe=False)
|
|
63
|
+
assert '{"parameters": 1}' not in out
|
|
64
|
+
assert '{"parameters": 1}' in log.read_text(encoding="utf-8")
|
|
65
|
+
assert "error: on stderr" in out
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@windows
|
|
69
|
+
def test_with_one_pipe_stdout_comes_back_to_the_pipe(tmp_path):
|
|
70
|
+
log = tmp_path / "stub.log"
|
|
71
|
+
out = _run_hijacked(log, one_pipe=True)
|
|
72
|
+
assert '{"parameters": 1}' in out.splitlines()[0]
|
|
73
|
+
assert "error: on stderr" in out
|
|
74
|
+
assert "flag left: None" in out # the engines the worker starts do not inherit it
|
|
75
|
+
assert log.read_text(encoding="utf-8") == ""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@windows
|
|
79
|
+
def test_a_gui_python_without_streams_gets_some_and_can_print(tmp_path):
|
|
80
|
+
"""pythonw, detached: whatever streams it starts with, after the call a print works."""
|
|
81
|
+
pythonw = Path(sys.executable).with_name("pythonw.exe")
|
|
82
|
+
if not pythonw.is_file():
|
|
83
|
+
pytest.skip(f"no pythonw.exe beside {sys.executable}")
|
|
84
|
+
result = tmp_path / "result.json"
|
|
85
|
+
script = f"""
|
|
86
|
+
import json, sys
|
|
87
|
+
before = [sys.stdout is None, sys.stderr is None]
|
|
88
|
+
from f3d2solidcraft_app.stdio import attach_std_streams
|
|
89
|
+
attach_std_streams()
|
|
90
|
+
print("printed")
|
|
91
|
+
print("printed", file=sys.stderr)
|
|
92
|
+
json.dump({{"before": before, "after": [sys.stdout is None, sys.stderr is None]}}, open({str(result)!r}, "w"))
|
|
93
|
+
"""
|
|
94
|
+
subprocess.run(
|
|
95
|
+
[str(pythonw), "-c", script],
|
|
96
|
+
creationflags=subprocess.DETACHED_PROCESS,
|
|
97
|
+
timeout=60,
|
|
98
|
+
check=True,
|
|
99
|
+
)
|
|
100
|
+
data = json.loads(result.read_text())
|
|
101
|
+
assert data["after"] == [False, False], data
|
|
@@ -815,3 +815,35 @@ def test_there_is_no_report_to_save_after_an_error_without_one(qtbot, tools, sam
|
|
|
815
815
|
qtbot.waitUntil(lambda: wizard.pages.currentIndex() == RESULT, timeout=10_000)
|
|
816
816
|
assert wizard.outcome.kind == "error"
|
|
817
817
|
assert not wizard.save_report_button.isVisibleTo(wizard)
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
def test_the_converters_error_reaches_the_first_step(qtbot, tools, sample_f3d, tmp_path):
|
|
821
|
+
# The worker's stdout and stderr share one pipe (`stdio`): its error line still names the problem,
|
|
822
|
+
# never a bare "exit code".
|
|
823
|
+
wizard = Wizard(lang="en", settings_path=tmp_path / "settings.json")
|
|
824
|
+
qtbot.addWidget(wizard)
|
|
825
|
+
wizard.load_file(sample_f3d)
|
|
826
|
+
qtbot.waitUntil(lambda: wizard.convert_button.isEnabled(), timeout=120_000)
|
|
827
|
+
broken = tmp_path / "broken.f3d"
|
|
828
|
+
broken.write_bytes(sample_f3d.read_bytes()[:4096])
|
|
829
|
+
wizard.load_file(broken)
|
|
830
|
+
qtbot.waitUntil(lambda: wizard.inspecting is None and wizard.holds_label.text() != "", timeout=60_000)
|
|
831
|
+
shown = wizard.holds_label.text()
|
|
832
|
+
assert shown.startswith("Could not read the file: ") and "exit code" not in shown, shown
|
|
833
|
+
assert not shown.endswith(": "), shown
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
def test_the_converters_error_reaches_the_result_step(qtbot, tools, sample_f3d, tmp_path):
|
|
837
|
+
design = tmp_path / "box.f3d"
|
|
838
|
+
design.write_bytes(sample_f3d.read_bytes())
|
|
839
|
+
wizard = Wizard(lang="en", settings_path=tmp_path / "settings.json")
|
|
840
|
+
qtbot.addWidget(wizard)
|
|
841
|
+
wizard.load_file(design)
|
|
842
|
+
wizard.output = tmp_path / "box.solidcraft"
|
|
843
|
+
qtbot.waitUntil(lambda: wizard.convert_button.isEnabled(), timeout=120_000)
|
|
844
|
+
design.unlink() # gone between the inspection and the conversion: the converter says so
|
|
845
|
+
wizard.start_conversion()
|
|
846
|
+
qtbot.waitUntil(lambda: wizard.pages.currentIndex() == RESULT, timeout=120_000)
|
|
847
|
+
assert wizard.outcome.kind == "error"
|
|
848
|
+
assert wizard.outcome.message and "stopped with code" not in wizard.outcome.message, wizard.outcome
|
|
849
|
+
assert "{" not in wizard.outcome.message # no progress event taken for the error
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/container/__init__.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/container/archive.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/__init__.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/parameters.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/sketch.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/model/timeline.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/__init__.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/manifest.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/primitives.py
RENAMED
|
File without changes
|
{f3d2solidcraft-0.3.1 → f3d2solidcraft-0.3.2}/src/f3d2solidcraft/_vendor/ezf3d/streams/segment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|