-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Scrumplex/refactor/improve-poetry-packaging
refactor: improve poetry packaging
- Loading branch information
Showing
50 changed files
with
471 additions
and
198 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
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
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
This file was deleted.
Oops, something went wrong.
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
127 changes: 55 additions & 72 deletions
127
TrackingBackend/main.py → eyetrackvr_backend/__init__.py
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,72 +1,55 @@ | ||
import os | ||
|
||
if os.pardir != os.path.dirname(__file__): | ||
os.chdir(os.path.dirname(__file__)) | ||
|
||
from fastapi.staticfiles import StaticFiles | ||
from app.logger import setup_logger | ||
from fastapi import FastAPI | ||
from app.etvr import ETVR | ||
|
||
|
||
def setup_app(): | ||
setup_logger() | ||
etvr_app = ETVR() | ||
etvr_app.add_routes() | ||
app = FastAPI() | ||
app.include_router(etvr_app.router) | ||
app.mount("/", StaticFiles(directory="assets/", html=True)) | ||
app.mount("/images", StaticFiles(directory="assets/images")) | ||
return app | ||
|
||
|
||
def main() -> int: | ||
import uvicorn | ||
import sys | ||
|
||
port: int = 8000 | ||
host: str = "127.0.0.1" | ||
args = sys.argv[1:] | ||
for i, v in enumerate(args): | ||
try: | ||
match v: | ||
case "--help" | "-h": | ||
print("Usage: python main.py [OPTIONS]") | ||
print("Options:") | ||
print(f"--port [PORT] Set the port to listen on. Default: {port}") | ||
print(f"--host [HOST] Set the host to listen on. Default: {host}") | ||
print(f"--help, -h Show this help message and exit") # noqa: F541 | ||
return 0 | ||
case "--port": | ||
if int(args[i + 1]) > 65535: | ||
print("Port must be between 0 and 65535!") | ||
return 1 | ||
port = int(args[i + 1]) | ||
case "--host": | ||
host = args[i + 1] | ||
case _: | ||
if v.startswith("-"): | ||
print("Unknown argument " + v) | ||
except IndexError: | ||
print("Missing value for argument " + v) | ||
return 1 | ||
except ValueError: | ||
print("Invalid value for argument " + v) | ||
return 1 | ||
|
||
app = setup_app() | ||
uvicorn.run(app=app, host=host, port=port, reload=False) | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
import multiprocessing | ||
import sys | ||
|
||
# check if we are running directly, if so, warn the user | ||
if not (getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")): | ||
print("WARNING: backend is being run directly but has not been compiled into an executable!") | ||
print("It is recomended to start the backend using uvicorn CLI when not compiled as an executable.") | ||
else: | ||
multiprocessing.freeze_support() | ||
raise SystemExit(main()) | ||
from fastapi.staticfiles import StaticFiles | ||
from fastapi import FastAPI | ||
|
||
from .assets import ASSETS_DIR, IMAGES_DIR | ||
from .etvr import ETVR | ||
from .logger import setup_logger | ||
|
||
def setup_app(): | ||
setup_logger() | ||
etvr_app = ETVR() | ||
etvr_app.add_routes() | ||
app = FastAPI() | ||
app.include_router(etvr_app.router) | ||
app.mount("/", StaticFiles(directory=ASSETS_DIR, html=True)) | ||
app.mount("/images", StaticFiles(directory=IMAGES_DIR)) | ||
return app | ||
|
||
|
||
def main() -> int: | ||
import uvicorn | ||
import sys | ||
|
||
port: int = 8000 | ||
host: str = "127.0.0.1" | ||
args = sys.argv[1:] | ||
for i, v in enumerate(args): | ||
try: | ||
match v: | ||
case "--help" | "-h": | ||
print(f"Usage: {sys.argv[0]} [OPTIONS]") | ||
print("Options:") | ||
print(f"--port [PORT] Set the port to listen on. Default: {port}") | ||
print(f"--host [HOST] Set the host to listen on. Default: {host}") | ||
print(f"--help, -h Show this help message and exit") # noqa: F541 | ||
return 0 | ||
case "--port": | ||
if int(args[i + 1]) > 65535: | ||
print("Port must be between 0 and 65535!") | ||
return 1 | ||
port = int(args[i + 1]) | ||
case "--host": | ||
host = args[i + 1] | ||
case _: | ||
if v.startswith("-"): | ||
print("Unknown argument " + v) | ||
except IndexError: | ||
print("Missing value for argument " + v) | ||
return 1 | ||
except ValueError: | ||
print("Invalid value for argument " + v) | ||
return 1 | ||
|
||
app = setup_app() | ||
uvicorn.run(app=app, host=host, port=port, reload=False) | ||
return 0 |
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,18 @@ | ||
# This is the main script run by pyinstaller | ||
from eyetrackvr_backend import main as real_main | ||
|
||
import multiprocessing | ||
import sys | ||
|
||
def main(): | ||
# check if we are running directly, if so, warn the user | ||
if not (getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS")): | ||
print("WARNING: backend is being run directly but has not been compiled into an executable!") | ||
print("It is recommended to start the backend using uvicorn CLI when not compiled as an executable.") | ||
else: | ||
multiprocessing.freeze_support() | ||
raise SystemExit(real_main()) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
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
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
4 changes: 2 additions & 2 deletions
4
TrackingBackend/app/algorithms/hsrac.py → eyetrackvr_backend/algorithms/hsrac.py
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
Oops, something went wrong.