Skip to content

Commit

Permalink
Added the ability to define the py files to be taken over to the outp…
Browse files Browse the repository at this point in the history
…ut folder. (sometimes ) you want to keep some py files instead of having only the binarys) Most times the entry script need to be a py script do get it started.
  • Loading branch information
Fleischkuechle committed May 19, 2024
1 parent 526df42 commit c742424
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
@echo off

@REM %~dp0: Breaks down as follows:
@REM %~d0: Extracts the drive letter from %0.
@REM %~p0: Extracts the path (directory) from %0.
@REM Combining the above two (%~d0 and %~p0) gives the drive and path of the batch file.

REM this is getting the path where the bat file is.
cd /D "%~dp0"

@REM REM this is getting the parent path fro where the bat file is.
@REM cd /D "%~dp0.."

set PATH=%PATH%;%SystemRoot%\system32

echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end

@rem fix failed install when installing to a separate drive
set TMP=%cd%\dev_env
set TEMP=%cd%\dev_env

@rem deactivate existing conda envs as needed to avoid conflicts
(call conda deactivate && call conda deactivate && call conda deactivate) 2>nul

@rem config
set CONDA_ROOT_PREFIX=%cd%\dev_env\conda
set INSTALL_ENV_DIR=%cd%\dev_env\env
@REM set "inputFolder=C:\Path\to\inputFolder"
@REM set "outputFolder=C:\Path\to\outputFolder"
set input=%cd%\input
set output=%cd%\output
REM copy from input to output folder
xcopy "%input%\*" "%output%\" /s /e



@rem activate installer env
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )

call python -m compileall -b -f %output%


@REM rem Generate .pyc files for existing .py files
@REM for %%f in ("%output%\*.py") do (
@REM python -m compileall "%%f"
@REM )

@REM rem Delete all .py files inside the output folder
@REM del "%outputFolder%\*.py"



@REM rem Delete all .py files inside the output folder and its subfolders
@REM for /R "%output%" %%f in (*.py) do (
@REM del "%%f"
@REM )

REM put here the python files you dont want to delete.
set "excluded_files=__Init__.py MoResive004.py"

for /R "%output%" %%f in (*.py) do (
set "exclude_file="
for %%x in (%excluded_files%) do (
if /I "%%~nxf" == "%%~x" set "exclude_file=1"
)
if not defined exclude_file (
del "%%f"
)
)




echo All operations completed successfully.
pause




@echo off
set "output=C:\Path\to\Output\Folder"
set "excluded_files=exclude1.py exclude2.py"

for /R "%output%" %%f in (*.py) do (
set "exclude_file="
for %%x in (%excluded_files%) do (
if /I "%%~nxf" == "%%~x" set "exclude_file=1"
)
if not defined exclude_file (
del "%%f"
)
)

















REM Using build in compiler to compile all python files.
@REM call python -m compileall -b -f .
REM comileall -l means not recursive that means it only compiles the files
REM that are inside the . folder it ignores sub folders
@REM call python -m compileall -b -f -l .
@REM call python -m compileall -b -f -l BackendCoreClassLib\InBlenderRunningLib




@REM @echo off
@REM set "inputFolder=C:\Path\to\inputFolder"
@REM set "outputFolder=C:\Path\to\outputFolder"

@REM rem Copy all files from input folder to output folder
@REM xcopy "%inputFolder%\*" "%outputFolder%\" /s /e

@REM rem Generate .pyc files for existing .py files
@REM for %%f in ("%outputFolder%\*.py") do (
@REM python -m compileall "%%f"
@REM )

@REM rem Delete all .py files inside the output folder
@REM del "%outputFolder%\*.py"

@REM echo All operations completed successfully.
@REM pause
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@echo off

@REM %~dp0: Breaks down as follows:
@REM %~d0: Extracts the drive letter from %0.
@REM %~p0: Extracts the path (directory) from %0.
@REM Combining the above two (%~d0 and %~p0) gives the drive and path of the batch file.

REM this is getting the path where the bat file is.
cd /D "%~dp0"

@REM REM this is getting the parent path fro where the bat file is.
@REM cd /D "%~dp0.."

set PATH=%PATH%;%SystemRoot%\system32

echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end

@rem fix failed install when installing to a separate drive
set TMP=%cd%\dev_env
set TEMP=%cd%\dev_env

@rem deactivate existing conda envs as needed to avoid conflicts
(call conda deactivate && call conda deactivate && call conda deactivate) 2>nul

@rem config
set CONDA_ROOT_PREFIX=%cd%\dev_env\conda
set INSTALL_ENV_DIR=%cd%\dev_env\env
@REM set "inputFolder=C:\Path\to\inputFolder"
@REM set "outputFolder=C:\Path\to\outputFolder"
set input=%cd%\input
set output=%cd%\output
REM copy from input to output folder
xcopy "%input%\*" "%output%\" /s /e



@rem activate installer env
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )

call python -m compileall -b -f %output%


@REM rem Generate .pyc files for existing .py files
@REM for %%f in ("%output%\*.py") do (
@REM python -m compileall "%%f"
@REM )

@REM rem Delete all .py files inside the output folder
@REM del "%outputFolder%\*.py"



@REM rem Delete all .py files inside the output folder and its subfolders
@REM for /R "%output%" %%f in (*.py) do (
@REM del "%%f"
@REM )

@REM REM put here the python files you dont want to delete.
@REM set "excluded_files=__Init__.py MoResive004.py"

@REM for /R "%output%" %%f in (*.py) do (
@REM set "exclude_file="
@REM for %%x in (%excluded_files%) do (
@REM if /I "%%~nxf" == "%%~x" set "exclude_file=1"
@REM )
@REM if not defined exclude_file (
@REM del "%%f"
@REM )
@REM )

@REM echo All operations completed successfully.
@REM pause


set "excluded_files_file=excluded_files.txt"

for /R "%output%" %%f in (*.py) do (
set "exclude_file="
for /F "tokens=*" %%x in (%excluded_files_file%) do (
if /I "%%~nxf" == "%%~x" set "exclude_file=1"
)
if not defined exclude_file (
del "%%f"
)
)


echo All operations completed successfully.
pause












3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ It does it recursive so all files in the subfolder will also be converted.
![alt text](image-2.png)


added the ability to keep py files by adding the filenames in the text file so the py files will also be in the output folder.

![alt text](image-3.png)
14 changes: 14 additions & 0 deletions excluded_files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
__Init__.py
OP_OT_Auto_Anim_Pro_highlight_in_outliner.py
OP_OT_run_motion_blend_pro.py
OP_OT_lock_all_bones.py
OP_OT_run_motion_blend_pro.py
OP_OT_run_mo_resive.py
OP_OT_unlock_all_bones.py
test_script_animate_operator.py
AUTO_ANIMATE_PRO_PT_Auto_Animate_PRO_TOOL.py
My_MotionBlend_Pro_Settings_Processor.py
download_demo_file.py
reqirement_installer.py
MoResive004.py
MainApp.py
Binary file added image-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c742424

Please sign in to comment.