From 2a50af9384d53063df82f49359807e31a6b13033 Mon Sep 17 00:00:00 2001
From: KOLANICH <kolan_n@mail.ru>
Date: Tue, 31 Aug 2021 19:47:23 +0300
Subject: [PATCH] Imporved packaging. Metadata has been moved into setup.cfg.
 Added pyproject.toml.

---
 pyproject.toml   |  5 ++++
 requirements.txt |  4 ---
 setup.cfg        | 13 ++++++++++
 setup.py         | 65 ++++--------------------------------------------
 4 files changed, 23 insertions(+), 64 deletions(-)
 create mode 100644 pyproject.toml
 delete mode 100644 requirements.txt
 create mode 100644 setup.cfg

diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..66ddafd
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,5 @@
+[build-system]
+requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools_scm]
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 500726d..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-pefile
-pyelftools
-msgpack-python>=0.4.6
-nose
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..18cb7b7
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,13 @@
+[metadata]
+name = plasma
+version = 1.0
+license = GPL-3.0
+description = plasma disassembler for x86/ARM/MIPS
+url = https://github.com/joelpx/plasma
+
+[options]
+install_requires = pefile; pyelftools; msgpack; capstone
+packages= plasma, plasma.lib, plasma.lib.arch, plasma.lib.arch.x86, plasma.lib.arch.mips, plasma.lib.arch.arm, plasma.lib.ui, plasma.lib.fileformat, plasma.lib.fileformat.relocations, plasma.scripts
+
+[options.entry_points]
+console_scripts = plasma = plasma.main:console_entry
diff --git a/setup.py b/setup.py
index c00745c..b98f33c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,68 +1,13 @@
 # -*- coding: utf-8 -*-
 
-try:
-    from setuptools import setup, find_packages
-except ImportError:
-    from distutils.core import setup
-
-try:
-    from pip._internal.req import parse_requirements
-except ImportError:
-    from pip.req import parse_requirements
+from setuptools import setup, find_packages
 
 from distutils.core import Extension
-import plasma
-
-requirements = parse_requirements('requirements.txt', session=False)
-
-requires = []
-for item in requirements:
-    # we want to handle package names and also repo urls
-    if getattr(item, 'url', None):  # older pip has url
-        links.append(str(item.url))
-    if getattr(item, 'link', None): # newer pip has link
-        links.append(str(item.link))
-    if item.req:
-        requires.append(str(item.req))
-
-
-x86_analyzer = Extension('plasma.lib.arch.x86.analyzer',
-    sources = ['plasma/lib/arch/x86/analyzer.c'])
-
-mips_analyzer = Extension('plasma.lib.arch.mips.analyzer',
-    sources = ['plasma/lib/arch/mips/analyzer.c'])
-
-arm_analyzer = Extension('plasma.lib.arch.arm.analyzer',
-    sources = ['plasma/lib/arch/arm/analyzer.c'])
-
 
 setup(
-    name='plasma',
-    version='1.0',
-    url="https://github.com/joelpx/plasma",
-    description='plasma disassembler for x86/ARM/MIPS',
-    license="GPLv3",
     ext_modules=[
-        x86_analyzer,
-        mips_analyzer,
-        arm_analyzer,
-    ],
-    packages=['plasma',
-              'plasma.lib',
-              'plasma.lib.arch',
-              'plasma.lib.arch.x86',
-              'plasma.lib.arch.mips',
-              'plasma.lib.arch.arm',
-              'plasma.lib.ui',
-              'plasma.lib.fileformat',
-              'plasma.lib.fileformat.relocations',
-              'plasma.scripts',
-    ],
-    package_dir={'plasma':'plasma'},
-    install_requires=requires,
-    entry_points = {
-        "console_scripts": [
-            "plasma = plasma.main:console_entry",
-        ],
-    },
+        Extension('plasma.lib.arch.x86.analyzer', sources = ['plasma/lib/arch/x86/analyzer.c']),
+        Extension('plasma.lib.arch.mips.analyzer', sources = ['plasma/lib/arch/mips/analyzer.c']),
+        Extension('plasma.lib.arch.arm.analyzer', sources = ['plasma/lib/arch/arm/analyzer.c']),
+    ]
 )