Skip to content

Commit

Permalink
Distribute flameshow with PyOxidizer (pyinstaller does not work)
Browse files Browse the repository at this point in the history
  • Loading branch information
azat committed Nov 24, 2023
1 parent 6dc4d43 commit 41117d6
Show file tree
Hide file tree
Showing 10 changed files with 374 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Install dependencies
run: |
pip install pyinstaller
pip install PyOxidizer
# nfpm
curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb"
sudo dpkg -i /tmp/nfpm.deb
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Install dependencies
run: |
pip install pyinstaller
pip install PyOxidizer
# nfpm
curl -sS -Lo /tmp/nfpm.deb "https://github.com/goreleaser/nfpm/releases/download/v2.25.0/nfpm_amd64.deb"
sudo dpkg -i /tmp/nfpm.deb
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# cargo
/target
/vendor
# pyinstaller
/build
/dist
*.spec
# PyOxidizer
build
# distribution
dist
# packages
*.deb
*.tar.*
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,24 @@ $(info target = $(target))

ifdef debug
cargo_build_opts :=
pyoxidizer_build_opts :=
target_type := debug
extension := -debug
else
cargo_build_opts := --release
pyoxidizer_build_opts := --release
target_type = release
extension :=
endif

ifneq ($(target),)
cargo_build_opts += --target $(target)

# NOTE: right now PyOxidizer does not work with Musl, due to the following error:
# thread 'main' panicked at 'already borrowed: BorrowMutError', /home/azat/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.17.3/src/gil.rs:433:45
# note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#
# pyoxidizer_build_opts += --target-triple $(target)
endif

.PHONY: build flameshow chdig install deb rpm archlinux packages
Expand All @@ -40,10 +48,13 @@ chdig:

.ONESHELL:
flameshow:
poetry -C $(PWD)/contrib/flameshow install --no-root --all-extras
source $(shell poetry -C $(PWD)/contrib/flameshow env info --path)/bin/activate && pyinstaller --noconfirm --onefile contrib/flameshow/flameshow/main.py
# main is the flameshow
ln -r -f -s dist/main dist/chdig-flameshow
# NOTE: we can make it fully static as well
pyoxidizer build $(pyoxidizer_build_opts) --path contrib/flameshow
mkdir -p dist
cp contrib/flameshow/build/x86_64-unknown-linux-gnu/release/install/flameshow dist/chdig-flameshow
# strip: 98MiB -> 76MiB
# gzip compression: 76MiB -> 25MiB
strip dist/chdig-flameshow

build: chdig flameshow link

Expand Down
2 changes: 1 addition & 1 deletion chdig-nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description: |
contents:
- src: target/chdig
dst: /usr/bin/chdig
- src: dist/flameshow
- src: dist/chdig-flameshow
dst: /usr/bin/chdig-flameshow
- src: dist/chdig.bash-completion
dst: /usr/share/bash-completion/completions/chdig
Expand Down
1 change: 0 additions & 1 deletion contrib/flameshow
Submodule flameshow deleted from ccffe0
Loading

0 comments on commit 41117d6

Please sign in to comment.