-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PyPANDA: update setup scripts to use debian package instead of self-i…
…nstalling
- Loading branch information
Andrew Fasano
committed
Dec 19, 2023
1 parent
9a7209f
commit 3840250
Showing
3 changed files
with
37 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
#!/usr/bin/env python | ||
# Install with python setup.py (develop|install) | ||
|
||
from setuptools import setup, find_packages | ||
from setuptools.command.install import install as install_orig | ||
from setuptools.command.develop import develop as develop_orig | ||
from setuptools.dist import Distribution | ||
from subprocess import check_output | ||
import shutil | ||
|
||
import os | ||
import shutil | ||
################################################ | ||
# 1) Copy panda object files: libpanda-XYZ.so, # | ||
# pc-bios/*, all .so files for plugins, # | ||
# pypanda's include directory, llvm-helpers # | ||
################################################ | ||
arches = ['arm', 'aarch64', 'i386', 'x86_64', 'ppc', 'mips', 'mipsel', 'mips64'] | ||
|
||
# Check for PANDA binaries in /usr/local/bin/ or in our build directory | ||
#panda_binaries = ['/usr/local/bin/panda-system-{arch}' for arch in arches] | ||
# Do we actually care at this point? | ||
|
||
root_dir = os.path.join(*[os.path.dirname(__file__), "..", "..", ".."]) # panda-git/ root dir | ||
|
||
|
@@ -28,16 +27,9 @@ def copy_objs(): | |
build_root = os.path.join(root_dir, "build") | ||
|
||
if os.path.isdir(lib_dir): | ||
assert('panda' in lib_dir), "Refusing to rm -rf directory without 'panda' in it" | ||
shutil.rmtree(lib_dir) | ||
os.mkdir(lib_dir) | ||
|
||
# Copy bios directory | ||
biosdir = os.path.join(root_dir, "pc-bios") | ||
if not os.path.isdir(biosdir): | ||
raise RuntimeError(f"Could not find PC-bios directory at {biosdir}") | ||
shutil.copytree(biosdir, lib_dir+"/pc-bios") | ||
|
||
# Copy pypanda's include directory (different than core panda's) into a datadir | ||
pypanda_inc = os.path.join(*[root_dir, "panda", "python", "core", "pandare", "include"]) | ||
if not os.path.isdir(pypanda_inc): | ||
|
@@ -47,21 +39,18 @@ def copy_objs(): | |
shutil.rmtree(pypanda_inc_dest) | ||
shutil.copytree(pypanda_inc, pypanda_inc_dest) | ||
|
||
# For each arch, copy llvm-helpers | ||
# XXX Should these be in standard panda deb? | ||
# What actually uses these? Taint? Disabling for now | ||
''' | ||
# Check if we have llvm-support | ||
with open(os.path.join(*[build_root, 'config-host.mak']), 'r') as cfg: | ||
llvm_enabled = True if 'CONFIG_LLVM=y' in cfg.read() else False | ||
# For each arch, copy library, plugins, plog_pb2.py and llvm-helpers | ||
arches = ['arm', 'aarch64', 'i386', 'x86_64', 'ppc', 'mips', 'mipsel', 'mips64'] | ||
if pypi_build: | ||
# Nobody really wants mips32 anymore, shrink our distribution size by dropping | ||
arches = ['arm', 'aarch64', 'i386', 'x86_64', 'ppc', 'mips64'] | ||
|
||
for arch in arches: | ||
libname = "libpanda-"+arch+".so" | ||
softmmu = arch+"-softmmu" | ||
path = os.path.join(*[build_root, softmmu, libname]) | ||
plugindir = os.path.join(*[build_root, softmmu, "panda", "plugins"]) | ||
llvm1 = os.path.join(*[build_root, softmmu, "llvm-helpers.bc1"]) | ||
llvm2 = os.path.join(*[build_root, softmmu, f"llvm-helpers-{arch}.bc"]) | ||
|
@@ -71,25 +60,10 @@ def copy_objs(): | |
continue | ||
os.mkdir(os.path.join(lib_dir, softmmu)) | ||
|
||
new_plugindir = os.path.join(lib_dir, softmmu, "panda/plugins") | ||
os.mkdir(os.path.dirname(new_plugindir)) # When we copy the whole tree, it will make the plugins directory | ||
|
||
shutil.copy( path, os.path.join(lib_dir, softmmu)) | ||
if llvm_enabled: | ||
shutil.copy( llvm1, os.path.join(lib_dir, softmmu)) | ||
shutil.copy( llvm2, os.path.join(lib_dir, softmmu)) | ||
|
||
shutil.copytree(plugindir, new_plugindir, ignore=shutil.ignore_patterns('*.o', '*.d')) | ||
|
||
# Strip libpandas and plugins to save space (Need <100mb for pypi) | ||
if pypi_build: | ||
check_output(f"find {lib_dir} -type f -executable -exec strip {{}} \;", shell=True) | ||
|
||
|
||
######################### | ||
# 3) Build the package # | ||
######################### | ||
''' | ||
|
||
from setuptools.command.install import install as install_orig | ||
from setuptools.command.develop import develop as develop_orig | ||
|
@@ -100,11 +74,6 @@ class custom_develop(develop_orig): | |
2) Running regular setup tools logic | ||
''' | ||
def run(self): | ||
# Delete pandare/data in the case of `setup.py develop` | ||
# Don't copy objects, use them in the current path | ||
if os.path.isdir(lib_dir): | ||
assert('panda' in lib_dir), "Refusing to rm -rf directory without 'panda' in it" | ||
shutil.rmtree(lib_dir) | ||
from create_panda_datatypes import main as create_datatypes | ||
create_datatypes(install=False) | ||
super().run() | ||
|
@@ -114,18 +83,16 @@ class custom_install(install_orig): | |
We're going to install to the system. Two possible states to handle | ||
1) Running from within the panda repo with panda built - need to create_datatypes | ||
2) Running from a python sdist where all the files are already prepared | ||
Install to the system by: | ||
1) Creating datatype files for an install | ||
2) Copying objects into local module | ||
3) Running regular setup tools logic | ||
''' | ||
def run(self): | ||
try: | ||
from create_panda_datatypes import main as create_datatypes | ||
# If we can do the import, we're in the panda repo | ||
create_datatypes(install=True) | ||
copy_objs() | ||
|
||
except ImportError: | ||
# Import failed, we're either in a python sdist or something has gone very wrong | ||
assert(os.path.isfile("pandare/include/panda_datatypes.h")), \ | ||
"panda_datatypes.h missing and can't be generated" | ||
assert(os.path.isfile("pandare/autogen/panda_datatypes.py")), \ | ||
|
@@ -140,22 +107,18 @@ def run(self): | |
long_description = fh.read() | ||
|
||
setup(name='pandare', | ||
version='0.1.1.6', | ||
version='0.1.2.0', | ||
description='Python Interface to PANDA', | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
author='Andrew Fasano, Luke Craig, and Tim Leek', | ||
author_email='[email protected]', | ||
url='https://github.com/panda-re/panda/', | ||
packages=find_packages(), | ||
package_data = { 'pandare': ['data/**/*', # Copy everything (fails?) | ||
'data/*-softmmu/libpanda-*.so', # Libpandas | ||
'data/*-softmmu/llvm-helpers*.bc*', # Llvm-helpers | ||
'data/*-softmmu/panda/plugins/*', # All plugins | ||
'data/*-softmmu/panda/plugins/**/*',# All plugin files | ||
package_data = { 'pandare': [ \ | ||
'data/*-softmmu/llvm-helpers*.bc*', # LLVM Helpers | ||
'data/pypanda/include/*.h', # Includes files | ||
'data/pypanda/include/*.h', # Includes files | ||
'data/pc-bios/*', # BIOSes | ||
'data/pc-bios/**/*', # Keymaps | ||
'qcows.json' # Generic Images | ||
]}, | ||
install_requires=[ 'cffi>=1.14.3', 'colorama'], | ||
|