From ba444962500b2a6f8f4f82b0792916f91cb8f4d4 Mon Sep 17 00:00:00 2001 From: Wojtek Porczyk Date: Tue, 20 Oct 2020 16:57:38 +0200 Subject: [PATCH] meson: install graphene-sgx-sign (former pal-sgx-sign) It's a miracle this still works from within the repo. --- Pal/src/host/Linux-SGX/signer/pal-sgx-sign | 23 +++++++++++++------ python/graphene-sgx-sign | 4 ++++ python/graphenelibos/meson.build | 8 +++++++ .../graphenelibos/sgx_sign.py | 8 +++++-- python/meson.build | 1 + 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100755 python/graphene-sgx-sign rename Pal/src/host/Linux-SGX/signer/pal_sgx_sign.py => python/graphenelibos/sgx_sign.py (99%) diff --git a/Pal/src/host/Linux-SGX/signer/pal-sgx-sign b/Pal/src/host/Linux-SGX/signer/pal-sgx-sign index 4658e117..cbfb620f 100755 --- a/Pal/src/host/Linux-SGX/signer/pal-sgx-sign +++ b/Pal/src/host/Linux-SGX/signer/pal-sgx-sign @@ -1,14 +1,23 @@ #!/usr/bin/env python3 - -# This is just a wrapper that provides the cmdline tool. All code should go -# into pal_sgx_sign.py. - -# pylint: disable=invalid-name +# pylint: disable=invalid-name,import-error,wrong-import-position import sys import os +import pathlib +import warnings -sys.path.insert(0, os.path.dirname(__file__)) -from pal_sgx_sign import main # pylint: disable=import-error,wrong-import-position +try: + fspath = os.fspath +except AttributeError: + fspath = str +# this is needed, so import generated_offsets works as backup from main python package +sys.path.insert(0, fspath(pathlib.Path(__file__).parent.parent)) + +sys.path.insert(0, fspath((pathlib.Path(__file__) / '../../../../../../python').resolve())) +from graphenelibos.sgx_sign import main + +warnings.warn( + 'pal-sgx-sign is deprecated, please install graphene and use graphene-sgx-sign', + DeprecationWarning) sys.exit(main()) diff --git a/python/graphene-sgx-sign b/python/graphene-sgx-sign new file mode 100755 index 00000000..a43777a4 --- /dev/null +++ b/python/graphene-sgx-sign @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + +from graphenelibos.sgx_sign import main +sys.exit(main()) diff --git a/python/graphenelibos/meson.build b/python/graphenelibos/meson.build index d21e7ea7..fb41d4df 100644 --- a/python/graphenelibos/meson.build +++ b/python/graphenelibos/meson.build @@ -7,6 +7,14 @@ init_py = configure_file( configuration: conf, ) +offsets_py = configure_file( + input: '../../Pal/src/host/Linux-SGX/generated_offsets.py', + output: '_offsets.py', + copy: true, +) + python3.install_sources([ init_py, + 'sgx_sign.py', + offsets_py, ], subdir: 'graphenelibos') diff --git a/Pal/src/host/Linux-SGX/signer/pal_sgx_sign.py b/python/graphenelibos/sgx_sign.py similarity index 99% rename from Pal/src/host/Linux-SGX/signer/pal_sgx_sign.py rename to python/graphenelibos/sgx_sign.py index 1ec1da76..24cb43e6 100644 --- a/Pal/src/host/Linux-SGX/signer/pal_sgx_sign.py +++ b/python/graphenelibos/sgx_sign.py @@ -9,8 +9,12 @@ import struct import subprocess import sys -sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) -import generated_offsets as offs # pylint: disable=import-error,wrong-import-position +try: + from . import _offsets as offs # pylint: disable=import-error +except ImportError: + # when we're in repo, _offsets does not exist and pal-sgx-sign sets sys.path + # so we can import as follows + import generated_offsets as offs # pylint: disable=import-error # pylint: enable=invalid-name diff --git a/python/meson.build b/python/meson.build index a1775ed2..ace50b4f 100644 --- a/python/meson.build +++ b/python/meson.build @@ -1 +1,2 @@ subdir('graphenelibos') +install_data('graphene-sgx-sign', install_dir: get_option('bindir'))