Skip to content

Commit

Permalink
Run build within poetry virtual environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzyll authored and xusheng6 committed Mar 22, 2024
1 parent d45ca39 commit 679a7fc
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 13 deletions.
112 changes: 112 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "debugger"
version = "1.0.0"
description = "The official Binary Ninja debugger plugin."
authors = ["Xusheng <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"
pathlib = "^1.0.1"
pytest = "^8.1.1"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
11 changes: 2 additions & 9 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,13 @@ def extract_zip(bundle, target):
with open(license_path, 'r') as f:
env["BN_LICENSE"] = f.read()

winpath = ''
if platform.system() == "Linux":
bn_python_path = bn_core_path / 'python'
elif platform.system() == "Darwin":
bn_python_path = bn_core_path.parent / 'Resources' / 'python'
bn_python_path = bn_python_path.resolve()
elif platform.system() == "Windows":
bn_python_path = bn_core_path / 'python'
winpath = os.environ["LOCALAPPDATA"] + "\\Programs\\Python\\Python38\\Scripts\\"

pythonpath = f'{bn_python_path}{os.pathsep}{build_output_path / "plugins"}'
env["PYTHONPATH"] = str(pythonpath)
Expand All @@ -220,15 +218,10 @@ def extract_zip(bundle, target):
str(base_dir / "test" / "debugger_test.py")
]

# Prevents https://github.com/pypa/pipenv/issues/5052
subprocess.run(["pipenv", "--rm"], env=env)

p = subprocess.Popen(["pipenv", "run", winpath + "py.test", "-x", "--junitxml", str(results)] + pytest_sources, env=env)
p = subprocess.Popen(["pytest", "-s", "--junitxml", str(results)] + pytest_sources, env=env)
# wait for process to complete
p_stdout, p_stderr = p.communicate()
assert 0 <= p.returncode < 128, f"pipenv run failed: {p_stdout} {p_stderr}"
p = subprocess.Popen(["pipenv", "--rm"], env=env)
p_stdout, p_stderr = p.communicate()
assert p.returncode == 0, f"pipenv --rm failed: {p_stdout} {p_stderr}"
assert 0 <= p.returncode < 128, f"test run failed: {p_stdout} {p_stderr}"

sys.exit(0)
3 changes: 2 additions & 1 deletion scripts/build_linux
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
export PATH=~/.local/bin:$PATH
export PYTHONUNBUFFERED=1
python3 scripts/build.py "$@"
poetry install --sync --no-root
poetry run python3 scripts/build.py "$@"
3 changes: 2 additions & 1 deletion scripts/build_macosx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
export PATH=/usr/local/bin:~/Library/Python/3.9/bin:$PATH
export PYTHONUNBUFFERED=1
python3 scripts/build.py "$@"
poetry install --sync --no-root
poetry run python3 scripts/build.py "$@"
4 changes: 2 additions & 2 deletions scripts/build_win64.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
set PYTHONUNBUFFERED=1

py -3 scripts\build.py %*
poetry install --sync --no-root
poetry run py -3 scripts\build.py %*

0 comments on commit 679a7fc

Please sign in to comment.