add uv self project
This commit is contained in:
parent
21f9d619dd
commit
d2efa162ca
@ -1,3 +0,0 @@
|
||||
recursive-include flandre *.ui
|
||||
recursive-include flandre/assets *.png
|
||||
recursive-include flandre/assets *.svg
|
||||
@ -1,6 +1,47 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
import platformdirs
|
||||
|
||||
MODULE_FOLDER = Path(__file__).parent
|
||||
ASSETS = MODULE_FOLDER / 'assets'
|
||||
PYQT = MODULE_FOLDER / 'pyqt'
|
||||
DEV_PROJECT_FOLDER = MODULE_FOLDER.parent
|
||||
DEV_PROJECT_FOLDER = MODULE_FOLDER.parent
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--data_folder', default=None)
|
||||
@click.option('--generate_pyqt', default=True)
|
||||
@click.option('--dev/--no-dev', default=True)
|
||||
@click.option('-p', '--path', type=str,
|
||||
default=platformdirs.user_config_path('Flandre', 'Scarlet') / 'launch.toml',
|
||||
help='Path to launch.toml'
|
||||
)
|
||||
def entrypoint(data_folder, generate_pyqt, dev, path):
|
||||
from flandre.config import C
|
||||
from flandre.launcher import launch_from_file
|
||||
if dev and '--dev' not in sys.argv:
|
||||
sys.argv.append('--dev')
|
||||
|
||||
if (pyuic6 := shutil.which('pyuic6')) is None:
|
||||
print('pyuic6 is not installed')
|
||||
return
|
||||
if generate_pyqt:
|
||||
subprocess.run([pyuic6, '-o', PYQT / 'Main.py', PYQT / 'Main.ui'])
|
||||
subprocess.run([pyuic6, '-o', PYQT / 'Image.py', PYQT / 'Image.ui'])
|
||||
if data_folder is not None:
|
||||
C.data_folder = Path(data_folder)
|
||||
|
||||
path = Path(path)
|
||||
if not path.exists():
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text('[MainUI]\n')
|
||||
print('Use launch config', path)
|
||||
launch_from_file(path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
entrypoint()
|
||||
|
||||
@ -92,9 +92,7 @@ def launch(arg: dict[LaunchComponent, dict]):
|
||||
|
||||
|
||||
def launch_from_file(file: Path):
|
||||
if not file.exists():
|
||||
file.parent.mkdir(parents=True, exist_ok=True)
|
||||
file.write_text('[MainUI]\n')
|
||||
assert file.exists()
|
||||
r = tomllib.loads(file.read_text())
|
||||
arg_d = dict()
|
||||
for k, v in r.items():
|
||||
|
||||
33
launch.py
33
launch.py
@ -1,33 +0,0 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--data_folder', default=None)
|
||||
@click.option('--generate_pyqt', default=True)
|
||||
@click.option('--dev/--no-dev', default=True)
|
||||
def main(data_folder, generate_pyqt, dev):
|
||||
if dev:
|
||||
sys.argv.append('--dev')
|
||||
import flandre
|
||||
from flandre.launcher import launch_from_file
|
||||
from flandre.config import C
|
||||
|
||||
if (pyuic6 := shutil.which('pyuic6')) is None:
|
||||
print('pyuic6 is not installed')
|
||||
return
|
||||
if generate_pyqt:
|
||||
subprocess.run([pyuic6, '-o', flandre.PYQT / 'Main.py', flandre.PYQT / 'Main.ui'])
|
||||
subprocess.run([pyuic6, '-o', flandre.PYQT / 'Image.py', flandre.PYQT / 'Image.ui'])
|
||||
if data_folder is not None:
|
||||
C.data_folder = Path(data_folder)
|
||||
|
||||
launch_from_file(Path(__file__).parent / 'launch.toml')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@ -1,3 +1,7 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=70.0.0", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "flandre"
|
||||
version = "0.1.0"
|
||||
@ -23,6 +27,9 @@ dependencies = [
|
||||
"websockets>=15.0.1",
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
exclude = ["bak", "test"]
|
||||
include = ["flandre*"]
|
||||
[tool.setuptools] # configuration specific to the `setuptools` build backend.
|
||||
packages = { find = { where = ["."], include = ["flandre", "flandre.*"] } }
|
||||
package-data = { "flandre.assets" = ["*.svg", "*.png"], "flandre.pyqt" = ["*.ui"] }
|
||||
|
||||
[project.scripts]
|
||||
flandre = "flandre:entrypoint"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user