2020-08-04 10:57:03 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2023-06-22 11:54:41 +00:00
|
|
|
# Copyright (c) 2023 Bitdefender
|
2020-08-04 10:57:03 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
|
|
|
from setuptools import find_packages, setup, Command, Extension, Distribution
|
|
|
|
from codecs import open
|
|
|
|
|
2023-06-22 11:54:41 +00:00
|
|
|
VERSION = (0, 3, 0)
|
2024-02-20 11:39:22 +00:00
|
|
|
LIBRARY_VERSION = (2, 1, 0)
|
2023-06-22 11:54:41 +00:00
|
|
|
DIR_INCLUDE = '../../inc'
|
2020-08-04 10:57:03 +00:00
|
|
|
|
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
2023-06-22 11:54:41 +00:00
|
|
|
__swig_opts = ['-I%s' % (DIR_INCLUDE)]
|
|
|
|
__extra_compile_args = ['-march=westmere']
|
|
|
|
__sources = ['pybddisasm/pybddisasm.c', 'pybddisasm/pybddisasm.i']
|
|
|
|
__libraries = ['bddisasm']
|
|
|
|
__library_dirs = ['../../build', '../../bin/x64/Release']
|
|
|
|
__packages = ['pybddisasm']
|
|
|
|
__requires = ['setuptools']
|
|
|
|
|
|
|
|
class BinaryDistribution(Distribution):
|
|
|
|
def has_ext_modules(arg):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def is_pure(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __fn_validate_compatibility():
|
2024-02-20 11:39:22 +00:00
|
|
|
version_header = '%s/bddisasm_version.h' % (DIR_INCLUDE)
|
2020-08-05 11:01:32 +00:00
|
|
|
with open(version_header, 'r') as file:
|
|
|
|
data = file.read()
|
|
|
|
|
|
|
|
major = re.search(r'(?<=\bDISASM_VERSION_MAJOR).*(\d+)', data)
|
|
|
|
if not major:
|
|
|
|
print('error: Major version not found!')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
minor = re.search(r'(?<=\bDISASM_VERSION_MINOR).*(\d+)', data)
|
|
|
|
if not minor:
|
|
|
|
print('error: Minor version not found!')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
revision = re.search(r'(?<=\bDISASM_VERSION_REVISION).*(\d+)', data)
|
|
|
|
if not revision:
|
|
|
|
print('error: Revision version not found!')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
major = major.group(0).strip()
|
|
|
|
minor = minor.group(0).strip()
|
|
|
|
revision = revision.group(0).strip()
|
|
|
|
|
|
|
|
if int(major) != LIBRARY_VERSION[0] or int(minor) != LIBRARY_VERSION[1] or int(revision) != LIBRARY_VERSION[2]:
|
|
|
|
print('error: The version of the library is not compatible with the pybddisasm!')
|
|
|
|
print('error: Library : %s.%s.%s - pybddisasm : %d.%d.%d' % (major, minor, revision, LIBRARY_VERSION[0],
|
2024-02-20 11:39:22 +00:00
|
|
|
LIBRARY_VERSION[1], LIBRARY_VERSION[2]))
|
2020-08-05 11:01:32 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2023-06-22 11:54:41 +00:00
|
|
|
__fn_validate_compatibility()
|
2020-08-05 11:01:32 +00:00
|
|
|
|
2020-08-04 10:57:03 +00:00
|
|
|
with open('README.md', 'r', 'utf-8') as f:
|
|
|
|
readme = f.read()
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name="pybddisasm",
|
|
|
|
version='.'.join(map(str, VERSION)),
|
|
|
|
author="Bitdefender",
|
|
|
|
description="The Bitdefender disassembler Python wrapper",
|
|
|
|
long_description = readme,
|
|
|
|
long_description_content_type = "text/markdown",
|
|
|
|
url = "https://github.com/bitdefender/bddisasm",
|
|
|
|
license="Apache Software License",
|
2023-06-22 11:54:41 +00:00
|
|
|
package_data={'': ['LICENSE', 'NOTICE'], 'pybddisasm': ['pybddisasm/pybddisasm.py']},
|
2020-08-04 10:57:03 +00:00
|
|
|
package_dir={'pybddisasm': 'pybddisasm'},
|
|
|
|
platforms = ["Windows", "Linux"],
|
2023-06-22 11:54:41 +00:00
|
|
|
packages=__packages,
|
2020-08-04 10:57:03 +00:00
|
|
|
include_package_data=True,
|
2023-06-22 11:54:41 +00:00
|
|
|
py_modules = ["pybddisasm"],
|
2020-08-13 08:17:39 +00:00
|
|
|
python_requires=">=3.5",
|
2020-08-04 10:57:03 +00:00
|
|
|
setup_requires=['wheel'],
|
2023-06-22 11:54:41 +00:00
|
|
|
install_requires=__requires,
|
2020-08-04 10:57:03 +00:00
|
|
|
zip_safe=False,
|
|
|
|
classifiers=[
|
2024-02-20 11:39:22 +00:00
|
|
|
'Programming Language :: Python :: 3.5',
|
|
|
|
'Programming Language :: Python :: 3.6',
|
2020-08-04 10:57:03 +00:00
|
|
|
'Programming Language :: Python :: 3.7',
|
|
|
|
'Programming Language :: Python :: 3.8',
|
2023-06-22 11:54:41 +00:00
|
|
|
'Programming Language :: Python :: 3.9',
|
|
|
|
'Programming Language :: Python :: 3.10',
|
2020-08-04 10:57:03 +00:00
|
|
|
'License :: OSI Approved :: Apache Software License',
|
2020-08-13 07:55:19 +00:00
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Operating System :: POSIX :: Linux'
|
2020-08-04 10:57:03 +00:00
|
|
|
],
|
|
|
|
ext_modules = [Extension("_pybddisasm",
|
2023-06-22 11:54:41 +00:00
|
|
|
swig_opts = __swig_opts,
|
|
|
|
extra_compile_args = __extra_compile_args,
|
|
|
|
sources = __sources,
|
|
|
|
define_macros = [('AMD64', None)],
|
|
|
|
include_dirs = [DIR_INCLUDE],
|
|
|
|
libraries = __libraries,
|
|
|
|
library_dirs = __library_dirs)],
|
2020-08-04 10:57:03 +00:00
|
|
|
distclass=BinaryDistribution
|
|
|
|
)
|