build: switch build framework to pyoxidizer

This commit is contained in:
Daylin Morgan 2022-06-16 01:18:13 -05:00
parent 4aeddafc96
commit 8b28c000b3
3 changed files with 70 additions and 24 deletions

View File

@ -1,6 +1,7 @@
SRC_FILES = $(wildcard yartsu/*)
SRC_FILES := $(wildcard yartsu/*)
VERSION := $(shell pdm show | grep "Installed" | awk -F ":" 'gsub(/ /, ""){print $$2}')
.PHONY: list lint build typing format dist check-tag
.PHONY: list lint build typing format dist check-tag release-asset
lint: format typing
@ -14,8 +15,12 @@ check-tag:
@[ "${TAG}" ] || ( echo ">> TAG is not set"; exit 1 )
@git describe HEAD --tags --exact-match
release: build/yartsu check-tag
gh release create $(TAG) build/yartsu -p -d
release-assets: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
tar czf build/yartsu-$(VERSION)-x86_64-linux.tar.gz \
build/x86_64-unknown-linux-gnu/release/install/yartsu
release: build/yartsu check-tag release-asset
gh release create $(TAG) build/yartsu-$(VERSION)-x86_64-linux.tar.gz -p -d
publish: dist
twine upload dist/*
@ -25,17 +30,23 @@ dist:
build: build/yartsu
build/yartsu: $(SRC_FILES)
mkdir -p build
build/shiv/yartsu: $(SRC_FILES)
mkdir -p build/shiv
shiv \
-c yartsu \
-o ./build/yartsu \
--preamble scripts/preamble.py \
--reproducible \
.
-c yartsu \
-o ./build/shiv/yartsu \
--preamble scripts/preamble.py \
--reproducible \
.
install-bin: build/yartsu
cp ./build/yartsu ~/bin
build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu: $(SRC_FILES)
pyoxidizer build --release
install-bin: build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu
cp ./build/x86_64-unknown-linux-gnu/release/install/yartsu/yartsu ~/bin
install-shiv: build/shiv/yartsu
cp ./build/shiv/yartsu ~/bin
.PHONY: svg-docs theme-docs diff-docs demo-docs docs
@ -45,7 +56,7 @@ theme-docs:
./scripts/theme-showcase-gen
diff-docs:
./scripts/code_svg_format_diff.py > docs/rich-diff.md
./scripts/code_svg_format_diff.py >docs/rich-diff.md
svg-docs:
lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg
@ -54,13 +65,13 @@ svg-docs:
demo-docs:
python -c \
"from rich.console import Console; \
console = Console(force_terminal=True); \
console.print('\n:snake: [b i]Emoji\'s!'); \
console.print(' [cyan]Nerd Fonts!');" \
| yartsu -w 25 -o assets/demo.svg
console = Console(force_terminal=True); \
console.print('\n:snake: [b i]Emoji\'s!'); \
console.print(' [cyan]Nerd Fonts!');" | \
yartsu -w 25 -o assets/demo.svg
clean:
rm -rf build dist
rm -rf build dist capture.svg
# https://stackoverflow.com/a/26339924
list:

View File

@ -37,16 +37,15 @@ If you come across anything unexpected please submit an issue.
pip install yartsu
```
There is a standalone binary available for linux :
Optionally with [`eget`](https://github.com/zyedidia/eget):
There is a standalone binary available for linux in the [releases](https://github.com/daylinmorgan/yartsu/releases).
Optionally install with [`eget`](https://github.com/zyedidia/eget):
```bash
eget daylinmorgan/yartsu
```
This version will bundle dependencies and unpack them at `~/.shiv` at first runtime.
You can change this location by setting the `SHIV_ROOT` environment variable.
See `shiv` for more info.
Otherwise you can download an extract manually to somewhere on your path.
## Usage

36
pyoxidizer.bzl Normal file
View File

@ -0,0 +1,36 @@
# This file defines how PyOxidizer application building and packaging is
# performed. See PyOxidizer's documentation at
# https://pyoxidizer.readthedocs.io/en/stable/ for details of this
# configuration file format.
def make_exe():
dist = default_python_distribution()
python_config = dist.make_python_interpreter_config()
python_config.run_command = "from yartsu.cli import main;main()"
exe = dist.to_python_executable(name="yartsu", config=python_config)
exe.add_python_resources(exe.pip_install(["."]))
return exe
def make_embedded_resources(exe):
return exe.to_embedded_resources()
def make_install(exe):
# Create an object that represents our installed application file layout.
files = FileManifest()
# Add the generated executable to our install layout in the root directory.
files.add_python_resource("yartsu", exe)
return files
# Tell PyOxidizer about the build targets defined above.
register_target("exe", make_exe)
# register_target("resources", make_embedded_resources, depends=["exe"], default_build_script=True)
register_target("install", make_install, depends=["exe"], default=True)
resolve_targets()