-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scrips for pycompile task in vscode .
- Loading branch information
1 parent
c2436f8
commit 5a315cc
Showing
7 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@echo off | ||
|
||
net session >nul 2>&1 | ||
|
||
if %errorLevel% == 0 ( | ||
echo Pip, setuptools and pyinstaller upgrading | ||
pip install --upgrade pip | ||
pip install --upgrade setuptools | ||
pip uninstall pyinstaller | ||
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz | ||
echo Now you can run pyinstaller | ||
) else ( | ||
echo You need to run this script as admin | ||
) | ||
|
||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
chckusr=$(id -u); | ||
|
||
if [ $chckusr = "0" ] ; then | ||
echo "Pip, setuptools and pyinstaller upgrading"; | ||
pip install --upgrade pip; | ||
pip install --upgrade setuptools; | ||
pip uninstall pyinstaller; | ||
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz; | ||
echo "Now you can run pyinstaller"; | ||
exit; | ||
else | ||
echo "You need to run this script as root"; | ||
fi | ||
|
||
read -p "Press enter to exit"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import shutil | ||
import subprocess | ||
|
||
# ARGS | ||
fileDirname = sys.argv[1] | ||
fileBasename = sys.argv[2] | ||
workspaceFolder = sys.argv[3] | ||
|
||
# TRANSFORMATION | ||
relativeFileDirname = fileDirname[len(workspaceFolder)+1:] | ||
fileBasenameNoExtension = "".join(fileBasename.rsplit(".py", 1)) | ||
distpath = os.path.join(workspaceFolder, "output", relativeFileDirname) | ||
|
||
# COMMAND GENERATOR | ||
def construct(): | ||
COMMAND = [] | ||
COMMAND.append("pyinstaller") | ||
COMMAND.append("--onefile") | ||
COMMAND.append("--clean") | ||
COMMAND.append("--noconsole") | ||
COMMAND.append("--distpath") | ||
COMMAND.append(distpath) | ||
for file in os.listdir(fileDirname): | ||
if file.endswith(".ico"): | ||
COMMAND.append("--icon") | ||
COMMAND.append(os.path.join(fileDirname, file)) | ||
break | ||
COMMAND.append(fileBasename) | ||
return COMMAND | ||
|
||
# CLEANER | ||
def clean(): | ||
path = os.path.join(fileDirname, "__pycache__") | ||
shutil.rmtree(path) | ||
path = os.path.join(fileDirname, "build") | ||
shutil.rmtree(path) | ||
path = os.path.join(fileDirname, "%s.spec" % fileBasenameNoExtension) | ||
os.remove(path) | ||
|
||
if __name__ == "__main__": | ||
COMMAND = construct() | ||
subprocess.check_call(COMMAND, cwd=fileDirname) | ||
clean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "compile python via pyinstaller", | ||
"type": "shell", | ||
"linux": { | ||
"command": "python ${workspaceFolder}/.vscode/compilers/pycompile.py ${fileDirname} ${fileBasename} ${workspaceFolder}" | ||
}, | ||
"windows": { | ||
"command": "python ${workspaceFolder}\\.vscode\\compilers\\pycompile.py ${fileDirname} ${fileBasename} ${workspaceFolder}" | ||
}, | ||
"group": "build", | ||
"presentation": { | ||
"reveal": "silent", | ||
"focus": false, | ||
"clear": true | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "run python file", | ||
"type": "shell", | ||
"linux": { | ||
"command": "python ${file}" | ||
}, | ||
"windows": { | ||
"command": "python ${file}" | ||
}, | ||
"group": "test", | ||
"presentation": { | ||
"reveal": "always", | ||
"focus": false, | ||
"clear": true | ||
} | ||
}, | ||
{ | ||
"label": "test script", | ||
"type": "shell", | ||
"linux": { | ||
"command": "python ${workspaceFolder}/.vscode/testers/testSite.py ${file} ${file}.test ${fileExtname} ${fileDirname} ${workspaceFolder} ${fileBasename}" | ||
}, | ||
"windows": { | ||
"command": "python ${workspaceFolder}/.vscode/testers/testSite.py ${file} ${file}.test ${fileExtname} ${fileDirname} ${workspaceFolder} ${fileBasename}" | ||
}, | ||
"group": "test", | ||
"presentation": { | ||
"reveal": "always", | ||
"focus": false, | ||
"clear": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
Release | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters