From bca0cde6709495e818a632a1fe27faaefaf3b77f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20DA=20ROCHA?= <sebastien@da-rocha.net>
Date: Wed, 20 Jun 2018 10:39:00 +0200
Subject: [PATCH] [enh] #100: make silkaj installable from pip:

- move main in `bin/silkaj`.
- fix variable naming.
- remove requirement.txt
- add setup.py with Python 3.7 compatibility: #98.
---
 bin/silkaj         | 10 ++++++++++
 requirements.txt   |  6 ------
 setup.py           | 38 ++++++++++++++++++++++++++++++++++++++
 silkaj/__init__.py |  1 +
 silkaj/silkaj.py   | 10 ++--------
 5 files changed, 51 insertions(+), 14 deletions(-)
 create mode 100755 bin/silkaj
 delete mode 100644 requirements.txt
 create mode 100644 setup.py
 create mode 100644 silkaj/__init__.py

diff --git a/bin/silkaj b/bin/silkaj
new file mode 100755
index 00000000..3cf94556
--- /dev/null
+++ b/bin/silkaj
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+
+from silkaj.network_tools import check_port, best_node
+from silkaj.silkaj import cli, manage_cmd
+
+if __name__ == '__main__':
+    ep, cli_args = cli()
+    check_port(ep["port"])
+    best_node(ep, 1)
+    manage_cmd(ep, cli_args)
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index d7d531fd..00000000
--- a/requirements.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-commandlines
-ipaddress
-tabulate
-pynacl
-scrypt
-pyaes
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..25faf932
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,38 @@
+import setuptools
+
+with open("README.md", "r") as fh:
+    long_description = fh.read()
+
+setuptools.setup(
+    name="silkaj",
+    version="0.6.0",
+    author="Moul",
+    author_email="moul@moul.re",
+    description="Command line client for Duniter",
+    long_description=long_description,
+    long_description_content_type="text/markdown",
+    url="https://git.duniter.org/clients/python/silkaj",
+    license='GNU AGPLv3',
+    packages=setuptools.find_packages(),
+    keywords='g1 duniter cryptocurrency librecurrency RTM',
+    classifiers=(
+        'Programming Language :: Python :: 3.7',
+        'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3 :: Only',
+        "License :: OSI Approved :: GNU Affero General Public License v3",
+        "Operating System :: OS Independent",
+    ),
+    install_requires=[
+        "commandlines",
+        "ipaddress",
+        "tabulate",
+        "pynacl",
+        "scrypt",
+        "pyaes",
+    ],
+    scripts=[
+        'bin/silkaj',
+    ],
+)
diff --git a/silkaj/__init__.py b/silkaj/__init__.py
new file mode 100644
index 00000000..775d1576
--- /dev/null
+++ b/silkaj/__init__.py
@@ -0,0 +1 @@
+name = "silkaj"
diff --git a/silkaj/silkaj.py b/silkaj/silkaj.py
index e9e88d58..f01bc648 100644
--- a/silkaj/silkaj.py
+++ b/silkaj/silkaj.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 from sys import stderr
@@ -97,7 +96,7 @@ def cli():
     return ep, cli_args
 
 
-def manage_cmd(ep, c):
+def manage_cmd(ep, cli_args):
 
     if cli_args.subcmd == "about":
         about()
@@ -127,7 +126,7 @@ def manage_cmd(ep, c):
         send_transaction(ep, cli_args)
 
     elif cli_args.subcmd == "cert":
-        send_certification(ep, c)
+        send_certification(ep, cli_args)
 
     elif cli_args.subcmd == "generate_auth_file":
         generate_auth_file(cli_args)
@@ -163,8 +162,3 @@ def about():
 \n            @@@@@@@@@@@@@@@\n")
 
 
-if __name__ == '__main__':
-    ep, cli_args = cli()
-    check_port(ep["port"])
-    best_node(ep, 1)
-    manage_cmd(ep, cli_args)
-- 
GitLab