Skip to content

Commit 9b83506

Browse files
committed
pyInstaller tutorial
1 parent e992ff4 commit 9b83506

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed

pyInstaller_tutorial/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source bin/activate
2+
pyinstaller src/wsgi.py -F \
3+
--name "dsc-os-linux" \
4+
--add-data "src/data/*:data" \
5+
--add-data "src/data/*.jpeg:data" \
6+
--hidden-import waitress\
7+
--clean

pyInstaller_tutorial/pyvenv.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
home = /home/kumar/anaconda3/bin
2+
include-system-site-packages = false
3+
version = 3.8.3
209 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from dsc_os.main import *
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pathlib
2+
3+
from flask import Flask
4+
5+
from .resources import get_resources_path
6+
7+
BASE_DIR = pathlib.Path(__file__).resolve().parent
8+
DATA_DIR = get_resources_path("data")
9+
IMG_PATH = DATA_DIR / 'beach.jpeg'
10+
11+
12+
web_app = Flask(__name__)
13+
14+
15+
@web_app.route("/", methods=["GET"])
16+
def index():
17+
return {"dir": str(BASE_DIR)}, 200
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pathlib
2+
import sys
3+
4+
5+
def get_resources_path(relative_path):
6+
"""get_resources_path
7+
8+
Args:
9+
relative_path ([type]): "data/beach.jpeg"
10+
relative_path ([type]):
11+
relative_path ([type]):
12+
"""
13+
14+
rel_path = pathlib.Path(relative_path)
15+
dev_bash_path = pathlib.Path(__file__).resolve().parent.parent
16+
base_path = getattr(sys, "_MEIPASS", dev_bash_path)
17+
return base_path / rel_path

pyInstaller_tutorial/src/wsgi.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from waitress import serve
2+
3+
from dsc_os import web_app
4+
5+
if __name__ == "__main__":
6+
serve(
7+
web_app,
8+
host='127.0.0.1',
9+
port=5002,
10+
threads=2
11+
)

0 commit comments

Comments
 (0)