]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Install requirements if using pip 66/head
authorShivani Bhardwaj <shivanib134@gmail.com>
Fri, 23 Nov 2018 14:55:29 +0000 (20:25 +0530)
committerJason Ish <ish@unx.ca>
Fri, 23 Nov 2018 17:26:57 +0000 (11:26 -0600)
Current setup was using distutils which does not allow to define the
requirements of a package. Check if the installation of
`suricata-update` is being done with `pip` and if it is, install the
requirements while installing the package.
This way distutils will not throw a warning of the `install_requires`
option being unrecognized, however, it would still not install the
requirements.
Now, with the installation of `suricata-update` package, all the
requirements are installed as well if it is installed with `pip`.

Closes redmine ticket #2667

setup.py

index a8456b48f362355b7c620fd8c42c3ac394dc7a46..14a4b0efda1cb818fddecf0ac1631006f82ab775 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,11 @@
 import os.path
 import subprocess
+import distutils
 from distutils.core import setup
 
 from suricata.update.version import version
 
+
 def write_git_revision():
     if not os.path.exists(".git"):
         return
@@ -17,13 +19,13 @@ def write_git_revision():
 
 write_git_revision()
 
-setup(
-    name="suricata-update",
-    version=version,
-    description="Suricata Update Tool",
-    author="Jason Ish",
-    author_email="ish@unx.ca",
-    packages=[
+args = {
+    "name": "suricata-update",
+    "version": version,
+    "description": "Suricata Update Tool",
+    "author": "Jason Ish",
+    "author_email": "ish@unx.ca",
+    "packages": [
         "suricata",
         "suricata.update",
         "suricata.update.commands",
@@ -32,13 +34,18 @@ setup(
         "suricata.update.compat.argparse",
         "suricata.update.data",
     ],
-    package_data={"suricata.update.configs": ["*.conf", "*.yaml", "*.in"]},
-    url="https://github.com/OISF/suricata-update",
-    license="GPLv2",
-    classifiers=[
+    "package_data": {"suricata.update.configs": ["*.conf", "*.yaml", "*.in"]},
+    "url": "https://github.com/OISF/suricata-update",
+    "license": "GPLv2",
+    "classifiers": [
         'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
     ],
-    scripts = [
+    "scripts": [
         "bin/suricata-update",
     ],
-)
+}
+
+if any("pip" in arg for arg in distutils.sys.argv):
+    args["install_requires"] = ["pyyaml", ]
+
+setup(**args)