From 7e9f95ebccc4f106c7bbdea75c9cac5963dd05db Mon Sep 17 00:00:00 2001 From: Yun Zheng Hu Date: Fri, 11 Oct 2024 10:05:58 +0200 Subject: [PATCH] Migrate setuptools to full pyproject.toml only (#61) Also switched the build system to hatchling and hatch-vcs. --- MANIFEST.in | 3 -- pyproject.toml | 98 +++++++++++++++++++++++++++++++++++++++++++++++--- setup.cfg | 90 ---------------------------------------------- setup.py | 6 ---- tox.ini | 6 ++-- 5 files changed, 97 insertions(+), 106 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d3b100a..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -# Exclude some dirs from the release package -prune tests/beacons -prune tests/profiles diff --git a/pyproject.toml b/pyproject.toml index 62f59d8..6f5c0de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,99 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] -build-backend = 'setuptools.build_meta' +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" -[tool.setuptools_scm] -write_to = "dissect/cobaltstrike/_version.py" +[project] +name = "dissect.cobaltstrike" +dynamic = ["version"] +description = "a Python library for dissecting Cobalt Strike related data" +requires-python = ">=3.9" +license = {text = "MIT License"} +readme = "README.rst" +authors = [ + {name = "Yun Zheng Hu", email = "hu@fox-it.com"}, +] +dependencies = [ + "dissect.cstruct >= 4.2", + "lark", +] +keywords = ["dissect", "cobaltstrike", "beacon", "parser", "parsing", "lark", "cstruct"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Security", + "Topic :: Utilities", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Software Development :: Libraries :: Python Modules", +] + +[project.urls] +documentation = "https://dissect-cobaltstrike.readthedocs.io/" +repository = "https://github.com/fox-it/dissect.cobaltstrike" + +[project.optional-dependencies] +c2 = [ + "flow.record", + "pycryptodome", + "httpx", +] +pcap = [ + "pyshark", + "dissect.cobaltstrike[c2]", +] +full = [ + "dissect.cobaltstrike[c2,pcap]", + "rich", +] +test = [ + "pytest", + "pytest-cov", + "pytest-httpserver", + "dissect.cobaltstrike[full]", +] +docs = [ + "sphinx", + "sphinx_rtd_theme>=2.0", + "sphinx-autoapi", + "sphinx-copybutton", + "sphinx-argparse-cli", + "ipython", + "pickleshare", + "dissect.cobaltstrike[full]", +] + +[project.scripts] +beacon-artifact = "dissect.cobaltstrike.artifact:main" +beacon-dump = "dissect.cobaltstrike.beacon:main" +beacon-xordecode = "dissect.cobaltstrike.xordecode:main" +beacon-pcap = "dissect.cobaltstrike.pcap:main" +beacon-client = "dissect.cobaltstrike.client:main" +c2profile-dump = "dissect.cobaltstrike.c2profile:main" + +[tool.hatch] +version.source = "vcs" +build.hooks.vcs.version-file = "dissect/cobaltstrike/_version.py" + +[tool.hatch.build.targets.sdist] +exclude = [ + "/tests/beacons/", + "/tests/profiles/", +] + +[tool.hatch.build.targets.wheel] +only-include = ["dissect/cobaltstrike", "tests", "docs"] [tool.black] line-length = 120 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ccb6886..0000000 --- a/setup.cfg +++ /dev/null @@ -1,90 +0,0 @@ -[metadata] -name = dissect.cobaltstrike -description = a Python library for dissecting Cobalt Strike related data -long_description = file: README.rst -long_description_content_type = text/x-rst -url = https://github.com/fox-it/dissect.cobaltstrike -author = Yun Zheng Hu -author_email = hu@fox-it.com -license = MIT -license_file = LICENSE -keywords = dissect, cobaltstrike, beacon, parser, parsing, lark, cstruct -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Console - Intended Audience :: Developers - Intended Audience :: Science/Research - Intended Audience :: Information Technology - License :: OSI Approved :: MIT License - Operating System :: POSIX - Operating System :: MacOS :: MacOS X - Operating System :: Microsoft :: Windows - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 - Topic :: Security - Topic :: Utilities - Topic :: Scientific/Engineering :: Information Analysis - Topic :: Software Development :: Libraries :: Python Modules -project_urls = - Source = https://github.com/fox-it/dissect.cobaltstrike - Documentation = https://dissect-cobaltstrike.readthedocs.io/ - -[options] -zip_safe = false -packages = find_namespace: -namespace_packages = dissect -platforms = any -include_package_data = true -install_requires = - dissect.cstruct >= 4.2 - lark -python_requires = >=3.9 -setup_requires = - setuptools_scm - -[bdist_wheel] -universal = 0 - -[options.entry_points] -console_scripts = - beacon-artifact = dissect.cobaltstrike.artifact:main - beacon-dump = dissect.cobaltstrike.beacon:main - beacon-xordecode = dissect.cobaltstrike.xordecode:main - beacon-pcap = dissect.cobaltstrike.pcap:main - beacon-client = dissect.cobaltstrike.client:main - c2profile-dump = dissect.cobaltstrike.c2profile:main - -[options.extras_require] -c2 = - flow.record - pycryptodome - httpx -pcap = - pyshark - dissect.cobaltstrike[c2] -full = - dissect.cobaltstrike[c2,pcap] - rich -test = - pytest - pytest-cov - pytest-httpserver - dissect.cobaltstrike[full] -docs = - sphinx - sphinx_rtd_theme>=2.0 - sphinx-autoapi - sphinx-copybutton - sphinx-argparse-cli - ipython - pickleshare - dissect.cobaltstrike[full] - -[flake8] -max-line-length = 120 -extend-ignore = E203 -statistics = true diff --git a/setup.py b/setup.py deleted file mode 100644 index bac24a4..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python - -import setuptools - -if __name__ == "__main__": - setuptools.setup() diff --git a/tox.ini b/tox.ini index 81a7eda..561a5a5 100644 --- a/tox.ini +++ b/tox.ini @@ -21,10 +21,10 @@ commands = pre-commit run --all-files [testenv:build] skip_install = true deps = - setuptools==60.10.0 # somehow v61.0.0 breaks bdist_wheel, pin to 60.10.0 for now - setuptools_scm[toml] + hatchling + hatch-vcs build twine commands = - python -m build --no-isolation # use --no-isolation so we can use our pinned versions + python -m build twine check dist/*