Skip to content

Commit

Permalink
Use py2exe instead of pyinstaller on Windows because Windows Defender…
Browse files Browse the repository at this point in the history
… antivirus shows a false positive warning Closes #1
  • Loading branch information
hlorand committed May 19, 2021
1 parent 50006d9 commit 78f936d
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*.trf
*.app
ffmpeg

dist/
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@ A simple graphical user interface for the [VidStab](https://github.com/georgmart

You can download the application to Windows or OSX at the [releases page](https://github.com/hlorand/vidstabgui/releases)

![](https://raw.githubusercontent.com/hlorand/vidstabgui/assets/screenshot.png)
![](https://raw.githubusercontent.com/hlorand/vidstabgui/assets/screenshot.gif)

## Build

Requirements:
**Windows**

- [pyinstaller](https://pypi.org/project/pyinstaller/)
Requirements:

**Windows**
- [py2exe](https://pypi.org/project/py2exe/)

- Open an administrative Power Shell
- Run `.\build.ps1`
- Run `.\build-scripts\win\build-py2exe.ps1`
- The configuration file for the script is `build-scripts\win\setup.py`

**OSX**

Requirements:

- [pyinstaller](https://pypi.org/project/pyinstaller/)

- Open a Terminal
- `chmod +x build.sh`
- Run `./build.sh`
- `chmod +x ./build-scripts/osx/build-pyinstaller.sh`
- Run `./build-scripts/osx/build-pyinstaller.sh`
3 changes: 3 additions & 0 deletions build.sh → build-scripts/osx/build-pyinstaller.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash

cd ../../

# Install Pyinstaller
pip3 install pyinstaller
Expand Down
31 changes: 31 additions & 0 deletions build-scripts/win/build-py2exe.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

cd ..\..\

# Install Py2exe
pip3 install py2exe
pip3 install --upgrade py2exe

# Download ffmpeg
Invoke-WebRequest -Uri https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip -OutFile .\ffmpeg-release-essentials.zip
Expand-Archive .\ffmpeg-release-essentials.zip -DestinationPath .
Invoke-WebRequest -Uri https://www.gyan.dev/ffmpeg/builds/release-version -OutFile .\version.txt
$version = cat version.txt
Remove-Item ffmpeg.exe
Move-Item "ffmpeg-$version-essentials_build\bin\ffmpeg.exe" .
Remove-Item "ffmpeg-$version-essentials_build" -Recurse
Remove-Item ffmpeg-release-essentials.zip
Remove-Item version.txt

# Build Using Py2exe
python .\build-scripts\win\setup.py install
python .\build-scripts\win\setup.py py2exe

# Remove unnecessary folders
Remove-Item ffmpeg.exe

# Create zip file
$date = Get-Date -Format "yyyy-MM-dd"
Remove-Item "vidstabgui-win-$date.zip"
Compress-Archive -Path .\dist\* -DestinationPath "vidstabgui-win-$date.zip"

explorer .
2 changes: 2 additions & 0 deletions build.ps1 → build-scripts/win/build-pyinstaller.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

cd ..\..\

# Install Pyinstaller
pip3 install pyinstaller
pip3 install --upgrade pyinstaller
Expand Down
29 changes: 29 additions & 0 deletions build-scripts/win/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# http://www.py2exe.org/index.cgi/ListOfOptions

from distutils.core import setup
import py2exe

setup(
windows=[{
"script":"vidstabgui.py",
"icon_resources": [(1, "icon/icon.ico")]
}],
data_files = [(
'.', ['ffmpeg.exe']
)],
options={
"py2exe":{
'bundle_files': 1,
'compressed': True,
"unbuffered": True,
'dist_dir': './dist',
"optimize": 2,
'includes': [
'tkinter',
'subprocess',
'time',
'os'
]
}
}
)
Binary file added icon/icon.ico
Binary file not shown.
13 changes: 7 additions & 6 deletions vidstabgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ def stabilize():
Messagebox.showerror(title="Error", message="No files selected")
return

# Change directory to script directory
abspath = os.path.abspath(__file__)
dirname = os.path.dirname(abspath)
os.chdir(dirname)
print("Working directory:", os.getcwd())

# Change directory to script directory - remove the "if" condition if building with pyinstaller on Windows
if os.name == "posix":
abspath = os.path.abspath(__file__)
dirname = os.path.dirname(abspath)
os.chdir(dirname)
print("Working directory:", os.getcwd())

# Check if ffmpeg.exe is present
if os.path.isfile("./ffmpeg.exe"):
ffmpeg = "ffmpeg.exe"
Expand Down

0 comments on commit 78f936d

Please sign in to comment.