Skip to content

Refactored .sh script to Python#142

Open
liammcknightt wants to merge 1 commit intothoth-tech:mainfrom
liammcknightt:refactor-install-script
Open

Refactored .sh script to Python#142
liammcknightt wants to merge 1 commit intothoth-tech:mainfrom
liammcknightt:refactor-install-script

Conversation

@liammcknightt
Copy link
Copy Markdown

Description

Refactored buildAndCopy.sh script to Python, have not deleted the original script, have preserved identical build and copy behavior.

Fixes # (issue)

Replaces Unix-only C# install shell script with cross-platform Python implementation to fix Windows compatibility.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I tested by running the script locally to see it completes as expected without any errors and behaves the same as the original script. Can test by cd to CSharpWasm and running the script via python buildAndCopy.py

Testing Checklist

  • Tested in latest Chrome
  • Tested in latest Safari
  • Tested in latest Firefox

Not needed.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have requested a review from ... on the Pull Request

@rabail-aamir
Copy link
Copy Markdown
Contributor

rabail-aamir commented Jan 12, 2026

Approved. This PR cleanly replaces the Unix-only shell script with a cross-platform Python script, improving Windows compatibility without changing core behaviour. The implementation is clear and well-structured.
Non-blocking: build paths are hardcoded to Debug/net8.0 and _framework assumes dotnet build these can be revisited if build targets change.

Copy link
Copy Markdown
Contributor

@cameronhum cameronhum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

ran the python code with no errors and everything seems to build/copy as intended. made a few suggestions to change. I am happy to approve after they are resolved or your current solution is justified as the functionality within this file and the original .sh is functionally the same

import shutil

# Paths are defined relative to this script's location
HERE = Path(__file__).resolve().parent
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit confusing. maybe we can name it something more clear like SCRIPT_DIR etc. that way it follows the standards in the below constants and is more explanatory as to what "here" means

TARGET_DIR = HERE.parent / "CSharpWasmExpo" / "bin"
FRAMEWORK_SRC = BIN_DIR / "wwwroot" / "_framework"
FRAMEWORK_DEST = HERE.parent / "CSharpWasmExpo" / "wwwroot" / "_framework"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and a few other places some comments are included in the original which are not explained here. I would recommend copying them for consistency. however some you replaced with function names which I believe make it much more readable and understandable

FRAMEWORK_DEST.mkdir(parents=True, exist_ok=True)

# Copy contents of _framework (not the directory itself)
for item in FRAMEWORK_SRC.iterdir():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is a bit complex for the task. also the rmtree is there but this isn't present in the original. If this is for stale files from an earlier build then we should delete everything in the folder to start with since files that aren't in the new build but were in old wont be deleted and will remain there forever.

however if not then rmtree should be removed.

also to address the complexity of the loop and better follow the cp -r from the original you can add this flag to the end of copytree dirs_exist_ok=True and copy the full directory with no loop. otherwise if you are going ahead with removing stale files/folder structures then you could remove the full loop, remove the FRAMEWORK_DEST.mkdir(parents=True, exist_ok=True) and just do a copytree allowing it to make the directory and copy the contents with no previous build beforehand

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.

3 participants