Skip to content

Align Python in the Windows dev tree with the install layout#262

Open
OlafRocket wants to merge 1 commit into
AcademySoftwareFoundation:developfrom
OlafRocket:python-dev-tree-alignment
Open

Align Python in the Windows dev tree with the install layout#262
OlafRocket wants to merge 1 commit into
AcademySoftwareFoundation:developfrom
OlafRocket:python-dev-tree-alignment

Conversation

@OlafRocket
Copy link
Copy Markdown

Linked issues

None.

Summarize your change.

Makes embedded Python initialize and the xstudio Python package
importable when running build\run_xstudio.bat directly from a fresh
Windows dev build (no cmake --install required).

Describe the reason for the change.

Follow a previous PR which aligned the Windows dev tree with the
install layout for resources under share/xstudio/. Python was the last
broken piece: xstudio_root()-derived PYTHONHOME is
build/bin/python3/, but nothing stages vcpkg's tools/python3/ to that
location at build time (only at install time). Py_Initialize fails;
EmbeddedPython::setup() catches the exception and logs "Failed to setup
API"; Python features are unavailable for the rest of the dev session.

This PR mirrors the install rules' destinations in the dev build tree on
Windows.

Describe what you have tested and on which operating system.

Windows 10 Pro x64 with Visual Studio 2022, Qt 6.5.3 (msvc2019_64),
vcpkg, Ninja generator (preset WinNinjaReleaseLocal):

  • Clean rebuild from empty build/: cmake configure + ninja build
    succeed. build/bin/python3/ populated with vcpkg's tools/python3
    contents plus xstudio package and __pybind_xstudio.pyd.
  • Standalone build/bin/python3/python.exe -c "import xstudio; from xstudio.core import *" succeeds, confirming the package layout and
    .pyd are reachable.
  • build\run_xstudio.bat: launches with no "Failed to setup API"
    warning. The picture_in_picture toggle in the bottom bar is
    functional, confirming stock Python plugins are loaded via
    XSTUDIO_LOCAL_PLUGIN_PATHload_plugins_in_path().
  • cmake --install build --prefix install_test: install tree byte-identical
    to current develop. install_test/python/xstudio/ is not present,
    but this was already true on upstream/develop since the rule that
    produced that location was removed before this PR.

macOS and Linux: not retested as those code paths are untouched. All new
branches are guarded with if(WIN32).

Add a list of changes, and note any that might need special attention during the review.

  1. src/embedded_python/src/CMakeLists.txt: add a Windows-only build-time
    stage step that copies vcpkg's tools/python3/ to
    build/bin/python3/ using cmake -E copy_directory_if_different.

  2. python/CMakeLists.txt:

    • Windows branch: replace the existing python -m pip install .
      invocation with cmake -E copy_directory_if_different of
      python/src/xstudio/ to
      build/bin/python3/Lib/site-packages/xstudio/. Update the
      python_module custom target's DEPENDS to track the new output
      path.
    • Add an explicit Windows install(DIRECTORY ${WIN_PYTHON_SITE} DESTINATION bin/python3/Lib/site-packages) rule. Previously no
      explicit Windows install rule existed for the xstudio .py files;
      they reached the installer only as a side-effect of pip install .
      mutating vcpkg's tools/python3/ tree before the wholesale install
      rule for that tree ran.
    • Linux/macOS branches untouched.
  3. src/python_module/src/CMakeLists.txt: add WIN32 branch in
    OUTPUT_DIR selection so LIBRARY_OUTPUT_DIRECTORY for
    __pybind_xstudio.pyd is the dev-tree mirror of its install location.

The build-tree source paths of install rules changed (POSIX-style
bin/python/lib/python3.11/site-packages/ is gone on Windows; replaced
with Windows-style bin/python3/Lib/site-packages/), but the install
destination paths are byte-identical.

If possible, provide screenshots.

N/A — build system change with no UI impact.

Mirrors the install-time Python layout in the build tree on Windows so
embedded Python initializes and the xstudio Python package is importable
when running build/run_xstudio.bat from a fresh dev build (no
cmake --install required).

- src/embedded_python/src/CMakeLists.txt: stage vcpkg's tools/python3 into
  build/bin/python3/ at build time via cmake -E copy_directory_if_different
  (incremental; ~150 MB on first build, near-zero on subsequent builds).
  Add configure-time guard for missing vcpkg python tree.
- python/CMakeLists.txt: on Windows, replace pip install . with
  cmake -E copy_directory_if_different of python/src/xstudio/ into
  build/bin/python3/Lib/site-packages/xstudio/. Update python_module
  target's DEPENDS for the new output path. Add an explicit Windows
  install(DIRECTORY ...) rule for the xstudio package (previously
  absent. Linux/macOS branches untouched.
- src/python_module/src/CMakeLists.txt: on Windows, route the
  __pybind_xstudio.pyd LIBRARY_OUTPUT_DIRECTORY to
  build/bin/python3/Lib/site-packages/xstudio/core/ built directly at
  the final location, .pdb co-located for debugger.

macOS and Linux unchanged. Install destination contents unchanged.

Signed-off-by: Olaf Razzoli <olaf.razzoli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant