2017-08-25 06:46:16 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-05-15 23:13:02 +01:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
# SPDX-License-Identifier: GPL-3.0+
|
2017-08-25 06:46:16 +01:00
|
|
|
|
2020-07-18 09:36:50 +01:00
|
|
|
# setuptools must be imported before distutils (see pypa/setuptools#2230).
|
2020-08-20 22:27:51 +01:00
|
|
|
import setuptools # isort: skip
|
2020-07-18 09:36:50 +01:00
|
|
|
|
2019-05-03 18:14:27 +01:00
|
|
|
import contextlib
|
2020-01-23 20:09:48 +00:00
|
|
|
from distutils import log
|
2020-01-24 23:38:54 +00:00
|
|
|
from distutils.command.build import build as _build
|
2019-04-03 19:33:37 +01:00
|
|
|
from distutils.dir_util import mkpath
|
2020-03-31 08:54:24 +01:00
|
|
|
from distutils.errors import DistutilsError
|
2019-04-03 19:33:37 +01:00
|
|
|
from distutils.file_util import copy_file
|
2019-11-15 21:28:47 +00:00
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import re
|
2020-08-20 22:27:51 +01:00
|
|
|
import shlex
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from setuptools import Command, find_packages, setup
|
2020-01-24 23:24:50 +00:00
|
|
|
from setuptools.command.build_ext import build_ext as _build_ext
|
|
|
|
from setuptools.command.egg_info import egg_info as _egg_info
|
2019-11-15 21:28:47 +00:00
|
|
|
from setuptools.extension import Extension
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2020-03-30 18:51:04 +01:00
|
|
|
from util import nproc, out_of_date
|
|
|
|
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2020-01-24 23:38:54 +00:00
|
|
|
class build(_build):
|
|
|
|
def finalize_options(self):
|
|
|
|
super().finalize_options()
|
|
|
|
if self.parallel is None:
|
2020-03-30 18:51:04 +01:00
|
|
|
self.parallel = nproc() + 1
|
2020-01-27 20:20:45 +00:00
|
|
|
|
|
|
|
|
2020-01-24 23:24:50 +00:00
|
|
|
class build_ext(_build_ext):
|
2019-04-03 19:33:37 +01:00
|
|
|
user_options = [
|
|
|
|
("inplace", "i", "put compiled extension into the source directory"),
|
|
|
|
("parallel=", "j", "number of parallel build jobs"),
|
|
|
|
]
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2019-04-03 19:33:37 +01:00
|
|
|
boolean_options = ["inplace"]
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2019-04-03 19:33:37 +01:00
|
|
|
help_options = []
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2019-09-04 22:40:47 +01:00
|
|
|
def _run_autoreconf(self, dir):
|
2020-01-27 20:20:45 +00:00
|
|
|
configure = os.path.join(dir, "configure")
|
|
|
|
configure_ac = os.path.join(dir, "configure.ac")
|
|
|
|
makefile_am = os.path.join(dir, "Makefile.am")
|
2019-09-04 22:40:47 +01:00
|
|
|
makefile_in = os.path.join(dir, "Makefile.in")
|
2020-01-27 20:20:45 +00:00
|
|
|
if out_of_date(makefile_in, makefile_am, configure_ac) or out_of_date(
|
|
|
|
configure, configure_ac
|
|
|
|
):
|
2019-05-03 18:14:27 +01:00
|
|
|
try:
|
2019-09-04 22:40:47 +01:00
|
|
|
subprocess.check_call(["autoreconf", "-i", dir])
|
2019-05-03 18:14:27 +01:00
|
|
|
except Exception:
|
2020-01-27 20:20:45 +00:00
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
os.remove(configure)
|
2019-05-03 18:14:27 +01:00
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
os.remove(makefile_in)
|
|
|
|
raise
|
|
|
|
|
2019-09-04 22:40:47 +01:00
|
|
|
def _run_configure(self):
|
2019-04-03 19:33:37 +01:00
|
|
|
mkpath(self.build_temp)
|
2019-05-03 18:14:27 +01:00
|
|
|
makefile = os.path.join(self.build_temp, "Makefile")
|
|
|
|
if not os.path.exists(makefile):
|
2019-04-03 19:33:37 +01:00
|
|
|
args = [
|
|
|
|
os.path.relpath("libdrgn/configure", self.build_temp),
|
|
|
|
"--disable-static",
|
|
|
|
"--with-python=" + sys.executable,
|
|
|
|
]
|
2020-01-24 01:54:46 +00:00
|
|
|
try:
|
|
|
|
args.extend(shlex.split(os.environ["CONFIGURE_FLAGS"]))
|
|
|
|
except KeyError:
|
|
|
|
pass
|
2019-05-03 18:14:27 +01:00
|
|
|
try:
|
|
|
|
subprocess.check_call(args, cwd=self.build_temp)
|
|
|
|
except Exception:
|
|
|
|
with contextlib.suppress(FileNotFoundError):
|
|
|
|
os.remove(makefile)
|
|
|
|
raise
|
2019-04-03 19:33:37 +01:00
|
|
|
|
2019-09-04 22:40:47 +01:00
|
|
|
def _run_make(self):
|
|
|
|
args = ["make", "-C", self.build_temp]
|
2019-04-03 19:33:37 +01:00
|
|
|
if self.parallel:
|
|
|
|
args.append(f"-j{self.parallel}")
|
|
|
|
subprocess.check_call(args)
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2019-09-04 22:40:47 +01:00
|
|
|
def run(self):
|
|
|
|
self._run_autoreconf("libdrgn")
|
|
|
|
self._run_configure()
|
|
|
|
self._run_make()
|
|
|
|
|
2019-04-03 19:33:37 +01:00
|
|
|
so = os.path.join(self.build_temp, ".libs/_drgn.so")
|
|
|
|
if self.inplace:
|
2019-09-06 20:25:59 +01:00
|
|
|
copy_file(so, self.get_ext_fullpath("_drgn"), update=True)
|
|
|
|
old_inplace, self.inplace = self.inplace, 0
|
2019-04-03 19:33:37 +01:00
|
|
|
build_path = self.get_ext_fullpath("_drgn")
|
|
|
|
mkpath(os.path.dirname(build_path))
|
2019-09-06 20:25:59 +01:00
|
|
|
copy_file(so, build_path, update=True)
|
|
|
|
self.inplace = old_inplace
|
Rewrite drgn core in C
The current mixed Python/C implementation works well, but it has a
couple of important limitations:
- It's too slow for some common use cases, like iterating over large
data structures.
- It can't be reused in utilities written in other languages.
This replaces the internals with a new library written in C, libdrgn. It
includes Python bindings with mostly the same public interface as
before, with some important improvements:
- Types are now represented by a single Type class rather than the messy
polymorphism in the Python implementation.
- Qualifiers are a bitmask instead of a set of strings.
- Bit fields are not considered a separate type.
- The lvalue/rvalue terminology is replaced with reference/value.
- Structure, union, and array values are better supported.
- Function objects are supported.
- Program distinguishes between lookups of variables, constants, and
functions.
The C rewrite is about 6x as fast as the original Python when using the
Python bindings, and about 8x when using the C API directly.
Currently, the exposed API in C is fairly conservative. In the future,
the memory reader, type index, and object index APIs will probably be
exposed for more flexibility.
2019-03-22 23:27:46 +00:00
|
|
|
|
2019-09-04 01:07:37 +01:00
|
|
|
def get_source_files(self):
|
|
|
|
if os.path.exists(".git"):
|
|
|
|
args = ["git", "ls-files", "-z", "libdrgn"]
|
|
|
|
return [
|
|
|
|
os.fsdecode(path)
|
|
|
|
for path in subprocess.check_output(args).split(b"\0")
|
|
|
|
if path
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
# If this is a source distribution, then setuptools will get the
|
|
|
|
# list of sources that was included in the tarball.
|
|
|
|
return []
|
2017-08-29 05:16:43 +01:00
|
|
|
|
|
|
|
|
2019-11-15 21:28:47 +00:00
|
|
|
# Work around pypa/setuptools#436.
|
2020-01-24 23:24:50 +00:00
|
|
|
class egg_info(_egg_info):
|
2019-11-15 21:28:47 +00:00
|
|
|
def run(self):
|
|
|
|
if os.path.exists(".git"):
|
2020-02-21 19:09:04 +00:00
|
|
|
with contextlib.suppress(FileNotFoundError):
|
2019-11-15 21:28:47 +00:00
|
|
|
os.remove(os.path.join(self.egg_info, "SOURCES.txt"))
|
|
|
|
super().run()
|
|
|
|
|
|
|
|
|
2020-03-31 08:54:24 +01:00
|
|
|
class test(Command):
|
|
|
|
description = "run unit tests after in-place build"
|
|
|
|
|
2021-01-22 00:59:57 +00:00
|
|
|
KERNELS = [
|
2021-03-09 21:51:52 +00:00
|
|
|
"5.12",
|
2021-01-22 00:59:57 +00:00
|
|
|
"5.11",
|
|
|
|
"5.10",
|
|
|
|
"5.9",
|
|
|
|
"5.8",
|
|
|
|
"5.7",
|
|
|
|
"5.6",
|
|
|
|
"5.4",
|
|
|
|
"4.19",
|
|
|
|
"4.14",
|
|
|
|
"4.9",
|
|
|
|
"4.4",
|
|
|
|
]
|
2020-03-31 08:54:24 +01:00
|
|
|
|
|
|
|
user_options = [
|
|
|
|
(
|
|
|
|
"kernel",
|
|
|
|
"K",
|
|
|
|
"run Linux kernel helper tests in a virtual machine on all supported kernels "
|
|
|
|
f"({', '.join(KERNELS)})",
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"extra-kernels=",
|
|
|
|
"k",
|
|
|
|
"additional kernels to run Linux kernel helper tests on in a virtual machine "
|
2020-10-15 00:26:48 +01:00
|
|
|
"(comma-separated list of wildcard patterns matching uploaded kernel releases)",
|
2020-03-31 08:54:24 +01:00
|
|
|
),
|
|
|
|
(
|
|
|
|
"vmtest-dir=",
|
|
|
|
"d",
|
|
|
|
"directory for built artifacts and downloaded kernels for virtual machine tests (default: 'build/vmtest')",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
self.kernel = False
|
|
|
|
self.extra_kernels = ""
|
|
|
|
self.vmtest_dir = None
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
self.kernels = [kernel for kernel in self.extra_kernels.split(",") if kernel]
|
|
|
|
if self.kernel:
|
|
|
|
self.kernels.extend(kernel + ".*" for kernel in test.KERNELS)
|
|
|
|
if self.vmtest_dir is None:
|
|
|
|
build_base = self.get_finalized_command("build").build_base
|
|
|
|
self.vmtest_dir = os.path.join(build_base, "vmtest")
|
|
|
|
|
|
|
|
def _run_local(self):
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
argv = ["discover"]
|
|
|
|
if self.verbose:
|
|
|
|
argv.append("-v")
|
|
|
|
test = unittest.main(module=None, argv=argv, exit=False)
|
|
|
|
return test.result.wasSuccessful()
|
|
|
|
|
2020-10-15 00:26:48 +01:00
|
|
|
def _run_vm(self, kernel_dir):
|
|
|
|
from pathlib import Path
|
|
|
|
|
2020-03-31 08:54:24 +01:00
|
|
|
import vmtest.vm
|
|
|
|
|
2020-04-17 23:11:54 +01:00
|
|
|
command = fr"""cd {shlex.quote(os.getcwd())} &&
|
|
|
|
DRGN_RUN_LINUX_HELPER_TESTS=1 {shlex.quote(sys.executable)} -Bm \
|
|
|
|
unittest discover -t . -s tests/helpers/linux {"-v" if self.verbose else ""}"""
|
2020-03-31 08:54:24 +01:00
|
|
|
try:
|
2020-04-17 23:11:54 +01:00
|
|
|
returncode = vmtest.vm.run_in_vm(
|
2020-10-15 00:26:48 +01:00
|
|
|
command, Path(kernel_dir), Path(self.vmtest_dir)
|
2020-04-17 23:11:54 +01:00
|
|
|
)
|
2020-03-31 08:54:24 +01:00
|
|
|
except vmtest.vm.LostVMError as e:
|
|
|
|
self.announce(f"error: {e}", log.ERROR)
|
|
|
|
return False
|
2020-04-14 01:21:02 +01:00
|
|
|
self.announce(f"Tests in VM returned {returncode}", log.INFO)
|
|
|
|
return returncode == 0
|
2020-03-31 08:54:24 +01:00
|
|
|
|
|
|
|
def run(self):
|
2020-10-14 00:47:24 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
2020-10-15 00:26:48 +01:00
|
|
|
from vmtest.download import KernelDownloader
|
2020-03-31 08:54:24 +01:00
|
|
|
|
|
|
|
# Start downloads ASAP so that they're hopefully done by the time we
|
|
|
|
# need them.
|
2020-10-15 00:26:48 +01:00
|
|
|
with KernelDownloader(self.kernels, Path(self.vmtest_dir)) as downloader:
|
2020-03-31 08:54:24 +01:00
|
|
|
if self.kernels:
|
2020-10-15 00:26:48 +01:00
|
|
|
self.announce("downloading kernels in the background", log.INFO)
|
2020-03-31 08:54:24 +01:00
|
|
|
self.run_command("egg_info")
|
|
|
|
self.reinitialize_command("build_ext", inplace=1)
|
|
|
|
self.run_command("build_ext")
|
|
|
|
|
|
|
|
passed = []
|
|
|
|
failed = []
|
|
|
|
|
|
|
|
if self.kernels:
|
|
|
|
self.announce("running tests locally", log.INFO)
|
|
|
|
if self._run_local():
|
|
|
|
passed.append("local")
|
|
|
|
else:
|
|
|
|
failed.append("local")
|
|
|
|
|
|
|
|
if self.kernels:
|
2020-10-15 00:26:48 +01:00
|
|
|
for kernel in downloader:
|
2020-03-31 08:54:24 +01:00
|
|
|
self.announce(
|
2020-10-15 00:26:48 +01:00
|
|
|
f"running tests in VM on Linux {kernel.name}", log.INFO
|
2020-03-31 08:54:24 +01:00
|
|
|
)
|
2020-10-15 00:26:48 +01:00
|
|
|
if self._run_vm(kernel):
|
|
|
|
passed.append(kernel.name)
|
2020-03-31 08:54:24 +01:00
|
|
|
else:
|
2020-10-15 00:26:48 +01:00
|
|
|
failed.append(kernel.name)
|
2020-03-31 08:54:24 +01:00
|
|
|
|
|
|
|
if passed:
|
|
|
|
self.announce(f'Passed: {", ".join(passed)}', log.INFO)
|
|
|
|
if failed:
|
|
|
|
self.announce(f'Failed: {", ".join(failed)}', log.ERROR)
|
|
|
|
|
|
|
|
if failed:
|
|
|
|
raise DistutilsError("some tests failed")
|
|
|
|
else:
|
|
|
|
self.announce("all tests passed", log.INFO)
|
|
|
|
|
|
|
|
|
2020-01-23 20:09:48 +00:00
|
|
|
def get_version():
|
2020-10-20 10:27:22 +01:00
|
|
|
try:
|
|
|
|
with open("drgn/internal/version.py", "r") as f:
|
|
|
|
version_py = f.read()
|
|
|
|
except FileNotFoundError:
|
|
|
|
version_py = None
|
2020-01-23 20:09:48 +00:00
|
|
|
|
2020-10-20 10:27:22 +01:00
|
|
|
# The public version always comes from configure.ac.
|
2020-01-23 20:09:48 +00:00
|
|
|
with open("libdrgn/configure.ac", "r") as f:
|
2020-10-20 10:27:22 +01:00
|
|
|
public_version = re.search(r"AC_INIT\(\[drgn\], \[([^]]*)\]", f.read()).group(1)
|
|
|
|
# Default local version if we fail.
|
|
|
|
local_version = "+unknown"
|
|
|
|
|
|
|
|
# If this is a git repository, use a git-describe(1)-esque local version.
|
|
|
|
# Otherwise, get the local version saved in the sdist.
|
|
|
|
if os.path.exists(".git"):
|
|
|
|
# Read the Docs modifies the working tree (namely, docs/conf.py). We
|
|
|
|
# don't want the documentation to display a dirty version, so ignore
|
|
|
|
# modifications for RTD builds.
|
|
|
|
dirty = os.getenv("READTHEDOCS") != "True" and bool(
|
2020-01-23 20:09:48 +00:00
|
|
|
subprocess.check_output(
|
2020-10-20 10:27:22 +01:00
|
|
|
["git", "status", "-uno", "--porcelain"],
|
|
|
|
# Use the environment variable instead of --no-optional-locks
|
|
|
|
# to support Git < 2.14.
|
|
|
|
env={**os.environ, "GIT_OPTIONAL_LOCKS": "0"},
|
2020-01-23 20:09:48 +00:00
|
|
|
)
|
|
|
|
)
|
2020-10-20 10:27:22 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
count = int(
|
|
|
|
subprocess.check_output(
|
|
|
|
["git", "rev-list", "--count", f"v{public_version}.."],
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
universal_newlines=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
log.warn("warning: v%s tag not found", public_version)
|
|
|
|
else:
|
|
|
|
if count == 0:
|
|
|
|
local_version = "+dirty" if dirty else ""
|
|
|
|
else:
|
|
|
|
commit = subprocess.check_output(
|
|
|
|
["git", "rev-parse", "--short", "HEAD"], universal_newlines=True
|
|
|
|
).strip()
|
|
|
|
local_version = f"+{count}.g{commit}"
|
|
|
|
if dirty:
|
|
|
|
local_version += ".dirty"
|
|
|
|
else:
|
|
|
|
if version_py is None:
|
|
|
|
# This isn't a proper sdist (maybe a git archive).
|
|
|
|
log.warn("warning: drgn/internal/version.py not found")
|
|
|
|
else:
|
|
|
|
# The saved version must start with the public version.
|
|
|
|
match = re.search(
|
2021-01-22 19:45:11 +00:00
|
|
|
fr'^__version__ = "{re.escape(public_version)}([^"]*)"$',
|
|
|
|
version_py,
|
|
|
|
re.M,
|
2020-10-20 10:27:22 +01:00
|
|
|
)
|
|
|
|
if match:
|
|
|
|
local_version = match.group(1)
|
|
|
|
else:
|
|
|
|
log.warn("warning: drgn/internal/version.py is invalid")
|
|
|
|
|
|
|
|
version = public_version + local_version
|
|
|
|
# Update version.py if necessary.
|
2021-01-22 19:17:18 +00:00
|
|
|
new_version_py = f'__version__ = "{version}"\n'
|
2020-10-20 10:27:22 +01:00
|
|
|
if new_version_py != version_py:
|
|
|
|
with open("drgn/internal/version.py", "w") as f:
|
|
|
|
f.write(new_version_py)
|
2020-01-23 20:09:48 +00:00
|
|
|
return version
|
|
|
|
|
|
|
|
|
2020-01-11 01:14:52 +00:00
|
|
|
with open("README.rst", "r") as f:
|
|
|
|
long_description = f.read()
|
|
|
|
|
2019-04-03 19:33:37 +01:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name="drgn",
|
2020-01-23 20:09:48 +00:00
|
|
|
version=get_version(),
|
2020-02-25 19:43:01 +00:00
|
|
|
packages=find_packages(include=["drgn", "drgn.*"]),
|
|
|
|
package_data={"drgn": ["../_drgn.pyi", "py.typed"]},
|
2019-04-03 19:33:37 +01:00
|
|
|
# This is here so that setuptools knows that we have an extension; it's
|
|
|
|
# actually built using autotools/make.
|
|
|
|
ext_modules=[Extension(name="_drgn", sources=[])],
|
2020-03-31 08:54:24 +01:00
|
|
|
cmdclass={
|
|
|
|
"build": build,
|
|
|
|
"build_ext": build_ext,
|
|
|
|
"egg_info": egg_info,
|
|
|
|
"test": test,
|
|
|
|
},
|
2020-08-27 06:15:04 +01:00
|
|
|
entry_points={"console_scripts": ["drgn=drgn.internal.cli:main"]},
|
2020-01-11 01:14:52 +00:00
|
|
|
python_requires=">=3.6",
|
2019-04-03 19:33:37 +01:00
|
|
|
author="Omar Sandoval",
|
|
|
|
author_email="osandov@osandov.com",
|
|
|
|
description="Scriptable debugger library",
|
2020-01-11 01:14:52 +00:00
|
|
|
long_description=long_description,
|
|
|
|
long_description_content_type="text/x-rst",
|
2019-04-03 19:33:37 +01:00
|
|
|
url="https://github.com/osandov/drgn",
|
2020-01-11 01:14:52 +00:00
|
|
|
project_urls={
|
|
|
|
"Bug Tracker": "https://github.com/osandov/drgn/issues",
|
|
|
|
"Documentation": "https://drgn.readthedocs.io",
|
|
|
|
},
|
|
|
|
license="GPL-3.0+",
|
|
|
|
classifiers=[
|
|
|
|
"Development Status :: 3 - Alpha",
|
|
|
|
"Environment :: Console",
|
|
|
|
"Intended Audience :: Developers",
|
|
|
|
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
|
|
"Operating System :: POSIX :: Linux",
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"Topic :: Software Development :: Debuggers",
|
|
|
|
],
|
2019-04-03 19:33:37 +01:00
|
|
|
)
|