mirror of
https://github.com/mandiant/capa.git
synced 2026-01-13 05:16:54 -08:00
include rule caching in PyInstaller build process (#2097)
* include rule caching in PyInstaller build process The following commit introduces a new function that caches the capa rule set, so that users don't have to manually run ./scripts/cache- ruleset.py, before running pyinstaller. * ci: omit Cache rule set step from build.yml workflow * refactor: move cache generation to cache.py * mkdir cache directory when it does not exist --------- Co-authored-by: Soufiane Fariss <soufiane.fariss@um5s.net.ma> Co-authored-by: Moritz <mr-tz@users.noreply.github.com>
This commit is contained in:
15
.github/pyinstaller/pyinstaller.spec
vendored
15
.github/pyinstaller/pyinstaller.spec
vendored
@@ -1,10 +1,19 @@
|
||||
# -*- mode: python -*-
|
||||
# Copyright (C) 2020 Mandiant, Inc. All Rights Reserved.
|
||||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import wcwidth
|
||||
import capa.rules.cache
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# SPECPATH is a global variable which points to .spec file path
|
||||
capa_dir = Path(SPECPATH).parent.parent
|
||||
rules_dir = capa_dir / 'rules'
|
||||
cache_dir = capa_dir / 'cache'
|
||||
|
||||
if not capa.rules.cache.generate_rule_cache(rules_dir, cache_dir):
|
||||
sys.exit(-1)
|
||||
|
||||
a = Analysis(
|
||||
# when invoking pyinstaller from the project root,
|
||||
@@ -26,7 +35,7 @@ a = Analysis(
|
||||
# so we manually embed the wcwidth resources here.
|
||||
#
|
||||
# ref: https://stackoverflow.com/a/62278462/87207
|
||||
(os.path.dirname(wcwidth.__file__), "wcwidth"),
|
||||
(Path(wcwidth.__file__).parent, "wcwidth"),
|
||||
],
|
||||
# when invoking pyinstaller from the project root,
|
||||
# this gets run from the project root.
|
||||
|
||||
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -52,8 +52,6 @@ jobs:
|
||||
run: python -m pip install --upgrade pip setuptools
|
||||
- name: Install capa with build requirements
|
||||
run: pip install -e .[build]
|
||||
- name: Cache the rule set
|
||||
run: python ./scripts/cache-ruleset.py ./rules/ ./cache/
|
||||
- name: Build standalone executable
|
||||
run: pyinstaller --log-level DEBUG .github/pyinstaller/pyinstaller.spec
|
||||
- name: Does it run (PE)?
|
||||
|
||||
Reference in New Issue
Block a user