diff --git a/Pipfile b/Pipfile index a05dbf66d7c87bd3553e71c3e1e6a71e3f2f28e1..c91fd92a34ead07e04cb8108d8605c069addcdb7 100644 --- a/Pipfile +++ b/Pipfile @@ -10,6 +10,7 @@ tabulate = "*" scrypt = "*" pyaes = "*" PyNaCl = "*" +"e1839a8" = {path = ".", editable = true} [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index ae44ec13ecfa2b633ee88bba8a0369dabd944a53..f27e6a971ed83e646d6d0601652f30277f8b9d32 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "22ac5bb64561eb08ea075a575e2b957157c4ecf5a04b37eada7331161eebe2e7" + "sha256": "9781db60bd2b394b50555e7bd36ebf96fbd997f7c2ff27bf5fb9f6ab83a58674" }, "pipfile-spec": 6, "requires": { @@ -56,6 +56,10 @@ "index": "pypi", "version": "==0.4.1" }, + "e1839a8": { + "editable": true, + "path": "." + }, "ipaddress": { "hashes": [ "sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794", diff --git a/README.md b/README.md index da340c80b86dc714f773e70c6a3ca03c7f26b88d..dc72078192f7ea4c0434592754c58f7583ded83b 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,36 @@ # Silkaj +[](https://pypi.python.org/pypi/silkaj) [](https://pypi.python.org/pypi/silkaj) [](https://pypi.python.org/pypi/silkaj) - CLI Duniter client written with Python 3. - [Website](https://silkaj.duniter.org) ## Install -### With release -Download [last release](https://git.duniter.org/clients/python/silkaj/tags) with `wget`. -Check it's integrity comparing it to `silkaj_sha256sum`: -```bash -sha256sum silkaj -``` -Add executable permissions: +### Install from Pypi + ```bash -chmod a+x silkaj +pip3 install silkaj ``` -### Manually +### Other installation methods + +- [Install with Pip](doc/install_pip.md) - [Install with pipenv](doc/install_pipenv.md) +- [Install with the build](doc/install_build.md) - [Build an executable with Pyinstaller](doc/build_with_pyinstaller.md) - [Install as a drop-down for GNOME Shell with Argos](doc/argos.md) ## Usage - Get help usage with `-h`, `--help` or `--usage` options, then run: ```bash -./silkaj <sub-command> +silkaj <sub-command> ``` - Will automatically request and post data on `duniter.org 10901` main Ğ1 node. - Specify a custom node with `-p` option: ```bash -./silkaj <sub-command> -p <address>:<port> +silkaj <sub-command> -p <address>:<port> ``` ## Features @@ -50,7 +49,7 @@ chmod a+x silkaj ## Example ```bash -./silkaj network +silkaj network ### 20 peers ups, with 15 members and 5 non-members diff --git a/bin/silkaj b/bin/silkaj new file mode 100755 index 0000000000000000000000000000000000000000..3cf945564064af3a47706eb083167f3d7e2f13e1 --- /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/doc/build_with_pyinstaller.md b/doc/build_with_pyinstaller.md index 384f78430366f288ea752e82a06415112e83b6e3..146716870cdad4ec9c94f25d4ca96a6e2d30172f 100644 --- a/doc/build_with_pyinstaller.md +++ b/doc/build_with_pyinstaller.md @@ -12,7 +12,7 @@ pyenv rehash ## Build ```bash -pyinstaller src/silkaj.py --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile +pyinstaller bin/silkaj --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile ``` -You will found the exetuable file on `silkaj/dist` folder. +You will found the exetuable file on `dist` folder. diff --git a/doc/install_build.md b/doc/install_build.md new file mode 100644 index 0000000000000000000000000000000000000000..cfb791e40a3cd8347b9b8a4d300f07af93ee2d78 --- /dev/null +++ b/doc/install_build.md @@ -0,0 +1,18 @@ +## Install with the realease bundle + +Build are built on Fedora, and only works on Fedora for now. + +### Download +Download [last release](https://git.duniter.org/clients/python/silkaj/tags) with `wget`. + + +### Integrity check +Check it's integrity comparing it to `silkaj_sha256sum`: +```bash +sha256sum silkaj +``` + +### Add executable permissions: +```bash +chmod a+x silkaj +``` diff --git a/doc/install_pip.md b/doc/install_pip.md new file mode 100644 index 0000000000000000000000000000000000000000..2b2dbdc31d1bc9c62b44edf53bf8f7ff8ed98789 --- /dev/null +++ b/doc/install_pip.md @@ -0,0 +1,40 @@ +# Install Silkaj with Pip + +## Install dependencies + +```bash +sudo apt install python3-pip libssl-dev +``` + +On Ubuntu 14.04 and Debian 8, you need this package too: +```bash +sudo apt install libffi-dev +``` + +## Install from Pypi + +```bash +pip3 install silkaj +``` + +## Install from sources + +### Retrieve silkaj sources +```bash +sudo apt install git +git clone https://git.duniter.org/clients/python/silkaj.git +cd silkaj +``` + +### Install with dependencies + +Just install: +```bash +pip3 install . +``` + +Or install it as "editable", for development: +```bash +pip3 install -e . +``` + diff --git a/doc/install_pipenv.md b/doc/install_pipenv.md index 153e31c39cad74a7f7ca97afd41956a684a471f1..481577957f0e573928a6e81e034373fc6d7d65a2 100644 --- a/doc/install_pipenv.md +++ b/doc/install_pipenv.md @@ -10,15 +10,17 @@ git clone https://git.duniter.org/clients/python/silkaj.git cd silkaj ``` -### Install dependencies +### Install with dependencies ```bash -pipenv install +pipenv install "-e ." ``` +The double quotes are important, if you forget them, `pipenv` will install silkaj from pypi + ### Activate pipenv and run silkaj ```bash pipenv shell -./silkaj +silkaj ``` ## Manage Python versions with Pyenv diff --git a/doc/release_packages_on_pypi-fr.md b/doc/release_packages_on_pypi-fr.md new file mode 100644 index 0000000000000000000000000000000000000000..13bbf4524cc342bbb15990596c9d1daf277f6bd2 --- /dev/null +++ b/doc/release_packages_on_pypi-fr.md @@ -0,0 +1,62 @@ +En résumé : + +1. Créer un compte sur pypi / pypi de test +2. Génrérer des paquets wheel (un source, un binaire). +3. Envoyer les paquets sur pypi + +# Créer un compte sur pypi + +De test : https://test.pypi.org/account/register/ + +De production : https://pypi.org/account/register/ + +Ça permet de gérer les versions et les projets (notamment ajouter des collaborateurs qui pourront aussi faire des livraisons). + +# Générer les paquets + +D'abord il faut installer/mettre à jour `setuptools` et `wheels` + +```bash +pip install -U setuptools wheel twine +``` + +Ensuite créer les paquets source et binaire dans le dossier "dist/" : + +```bash +$ python3 setup.py sdist bdist_wheel +$ ls dist/ +silkaj-0.6.0-py3-none-any.whl silkaj-0.6.0.tar.gz +``` + +# Pousser les paquets sur pypi + +Pour ne pas taper son password à chaque fois, on peut utiliser ça : https://github.com/pypa/twine#keyring-support + +## Pousser sur l'environnement de test + +Pour pousser la version $VERSION + +```bash +twine upload --repository-url https://test.pypi.org/legacy/ dist/silkaj-$VERSION* +``` + +On peut voir le paquet ici : https://test.pypi.org/project/silkaj/ + + +Pout installer le paquet depuis le dépôt de test sur un venv tout neuf : + +```bash +pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.python.org/simple/ silkaj +``` + +Le `--extra-index-url` sert à ajouter les paquets officiels, sinon il y aura un problème avec les dépendances absentes de l'environnement de test. + +## Pousser sur l'environnement de test + +Juste faire : `twine upload dist/silkaj-$VERSION*` + +Pour installer le paquet dans un environnement tout propre : + +```bash +pip install silkaj +``` diff --git a/release.sh b/release.sh index afc9a744d6813fe8048f54a8659ef0f1cf4b053d..c4c77ae1851a7a203eb8ba77a704ca98f3413874 100755 --- a/release.sh +++ b/release.sh @@ -22,12 +22,13 @@ check_branch() { } update_version() { - sed -i "s/SILKAJ_VERSION = \"silkaj.*\"/SILKAJ_VERSION = \"silkaj $VERSION\"/" src/constants.py + sed -i "s/SILKAJ_VERSION = \"silkaj.*\"/SILKAJ_VERSION = \"silkaj $VERSION\"/" silkaj/constants.py + sed -i "s/version=\".*\",/version=\"$VERSION\",/" setup.py git diff } commit_tag() { - git commit src/constants.py -m "v$VERSION" + git commit silkaj/constants.py setup.py -m "v$VERSION" git tag "v$VERSION" -a -m "$VERSION" } @@ -36,7 +37,7 @@ build() { error_message "Activate silkaj-env" fi exec_installed pyinstaller - pyinstaller src/silkaj.py --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile + pyinstaller bin/silkaj --hidden-import=_cffi_backend --hidden-import=_scrypt --onefile } checksum() { diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d7d531fd42c74c244c47839a95bf58d48ff6ed3a..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..25faf93242f0035ce8cb68582327b3387cc0c084 --- /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 b/silkaj deleted file mode 120000 index 70e7362bbc0a29052ae645561df7f331a8c35de5..0000000000000000000000000000000000000000 --- a/silkaj +++ /dev/null @@ -1 +0,0 @@ -src/silkaj.py \ No newline at end of file diff --git a/silkaj/__init__.py b/silkaj/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..775d1576f8ea4c5ea3ed9820688908fc98e61d45 --- /dev/null +++ b/silkaj/__init__.py @@ -0,0 +1 @@ +name = "silkaj" diff --git a/src/auth.py b/silkaj/auth.py similarity index 98% rename from src/auth.py rename to silkaj/auth.py index ba50f174c95c6e27bfed8db8474d5c620ef82ac7..98c375716ce4377508cfe3778a889b4026f85b4e 100644 --- a/src/auth.py +++ b/silkaj/auth.py @@ -1,4 +1,4 @@ -from tools import get_publickey_from_seed, b58_decode, xor_bytes, message_exit +from silkaj.tools import get_publickey_from_seed, b58_decode, xor_bytes, message_exit from nacl import encoding import nacl.hash from scrypt import hash diff --git a/src/cert.py b/silkaj/cert.py similarity index 88% rename from src/cert.py rename to silkaj/cert.py index 4625ac2671e028c8e1fe987649e393d77ca0212f..bcd6a34fd3484314342a065f46f9487207785f14 100644 --- a/src/cert.py +++ b/silkaj/cert.py @@ -1,12 +1,12 @@ import urllib from tabulate import tabulate -from auth import auth_method -from tools import get_publickey_from_seed, message_exit, sign_document_from_seed -from network_tools import get_current_block, post_request -from license import license_approval -from constants import NO_MATCHING_ID -from wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\ +from silkaj.auth import auth_method +from silkaj.tools import get_publickey_from_seed, message_exit, sign_document_from_seed +from silkaj.network_tools import get_current_block, post_request +from silkaj.license import license_approval +from silkaj.constants import NO_MATCHING_ID +from silkaj.wot import is_member, get_pubkey_from_id, get_pubkeys_from_id,\ get_uid_from_pubkey diff --git a/src/commands.py b/silkaj/commands.py similarity index 97% rename from src/commands.py rename to silkaj/commands.py index 44265003638b98479852b7cbf57eba9253ef7a14..60a05edd38a5dceab868675fc47253d8516ee6a6 100644 --- a/src/commands.py +++ b/silkaj/commands.py @@ -5,10 +5,10 @@ from collections import OrderedDict from tabulate import tabulate from operator import itemgetter -from wot import get_uid_from_pubkey -from network_tools import discover_peers, get_request, best_node, get_current_block -from tools import convert_time, get_currency_symbol, message_exit -from constants import NO_MATCHING_ID +from silkaj.wot import get_uid_from_pubkey +from silkaj.network_tools import discover_peers, get_request, best_node, get_current_block +from silkaj.tools import convert_time, get_currency_symbol, message_exit +from silkaj.constants import NO_MATCHING_ID def currency_info(ep): diff --git a/src/constants.py b/silkaj/constants.py similarity index 100% rename from src/constants.py rename to silkaj/constants.py diff --git a/src/license.py b/silkaj/license.py similarity index 100% rename from src/license.py rename to silkaj/license.py diff --git a/src/money.py b/silkaj/money.py similarity index 95% rename from src/money.py rename to silkaj/money.py index 21e8be10efed12a3bce6301c38514a3e34f62333..fb7e5f5877e5df115dd7b5bece629d88fdac6bce 100644 --- a/src/money.py +++ b/silkaj/money.py @@ -1,7 +1,7 @@ -from network_tools import get_request, get_current_block -from tools import get_currency_symbol, get_publickey_from_seed -from auth import auth_method -from wot import check_public_key +from silkaj.network_tools import get_request, get_current_block +from silkaj.tools import get_currency_symbol, get_publickey_from_seed +from silkaj.auth import auth_method +from silkaj.wot import check_public_key def cmd_amount(ep, cli_args): diff --git a/src/network_tools.py b/silkaj/network_tools.py similarity index 100% rename from src/network_tools.py rename to silkaj/network_tools.py diff --git a/src/silkaj.py b/silkaj/silkaj.py old mode 100755 new mode 100644 similarity index 88% rename from src/silkaj.py rename to silkaj/silkaj.py index 99d5cdd7bc98e6f39183c16989a0f22393540038..58669a6fab4a12ec7be953952d231d9cee2a4909 --- a/src/silkaj.py +++ b/silkaj/silkaj.py @@ -1,25 +1,23 @@ -#!/usr/bin/env python3 # -*- coding: utf-8 -*- from sys import stderr from commandlines import Command -from tx import send_transaction -from money import cmd_amount -from cert import send_certification -from commands import currency_info, difficulties, set_network_sort_keys,\ +from silkaj.tx import send_transaction +from silkaj.money import cmd_amount +from silkaj.cert import send_certification +from silkaj.commands import currency_info, difficulties, set_network_sort_keys,\ network_info, argos_info, list_issuers -from tools import message_exit -from network_tools import check_port, best_node -from wot import received_sent_certifications, id_pubkey_correspondence -from auth import generate_auth_file -from license import display_license -from constants import SILKAJ_VERSION, G1_SYMBOL, GTEST_SYMBOL, G1_DEFAULT_ENDPOINT, G1_TEST_DEFAULT_ENDPOINT +from silkaj.tools import message_exit +from silkaj.wot import received_sent_certifications, id_pubkey_correspondence +from silkaj.auth import generate_auth_file +from silkaj.license import display_license +from silkaj.constants import SILKAJ_VERSION, G1_SYMBOL, GTEST_SYMBOL, G1_DEFAULT_ENDPOINT, G1_TEST_DEFAULT_ENDPOINT def usage(): message_exit("Silkaj: command line client for Duniter currencies\ \n\nhelp: -h, --help, --usage \ - \nnersion: -v, --version \ + \nversion: -v, --version \ \nabout: display informations about the programm\ \n \ \nEndpoint:\ @@ -98,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() @@ -128,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) @@ -153,7 +151,7 @@ def about(): \n @@ @@@ @@@@@@@@@# @@@@ @@(\ \n @@ @@@@ @@@@@@@@@ @@@ @@ Built in Python for Duniter’s currencies: Ğ1 and Ğ1-Test\ \n @@ @@@ @@@@@@@@ @ @@@ @@\ -\n @@ @@@ @@@@@@ @@@@ @@ @@ Authors: Moul, Tortue, Jytou\ +\n @@ @@@ @@@@@@ @@@@ @@ @@ Authors: moul, tortue, jytou, cebash, cgeek\ \n @@ @@@@ @@@ @@@@@@@ @@ @@\ \n @@ @@@@* @@@@@@@@@ @# @@ Website: https://silkaj.duniter.org\ \n @@ @@@@@ @@@@@@@@@@ @ ,@@\ @@ -164,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) diff --git a/src/tools.py b/silkaj/tools.py similarity index 98% rename from src/tools.py rename to silkaj/tools.py index 7152c12a0c4c33684cd8416ae80d89f00a8b5a3e..6a965d9f8e44105644bf4690b099988bf6ae0b29 100644 --- a/src/tools.py +++ b/silkaj/tools.py @@ -3,7 +3,7 @@ from nacl import encoding, signing, hash, bindings from re import compile, search from sys import exit -from constants import G1_SYMBOL, GTEST_SYMBOL +from silkaj.constants import G1_SYMBOL, GTEST_SYMBOL def convert_time(timestamp, kind): diff --git a/src/tx.py b/silkaj/tx.py similarity index 96% rename from src/tx.py rename to silkaj/tx.py index 2f4b54dc3efd6791772246433ee2b4ddec158411..96aa30a45ae1b967ac75adaa7fe0465c63aba98a 100644 --- a/src/tx.py +++ b/silkaj/tx.py @@ -4,13 +4,13 @@ from time import sleep import urllib from tabulate import tabulate -from network_tools import get_request, post_request, get_current_block -from tools import get_currency_symbol, get_publickey_from_seed, sign_document_from_seed,\ +from silkaj.network_tools import get_request, post_request, get_current_block +from silkaj.tools import get_currency_symbol, get_publickey_from_seed, sign_document_from_seed,\ check_public_key, message_exit -from auth import auth_method -from wot import get_uid_from_pubkey -from money import get_last_ud_value, get_amount_from_pubkey -from constants import NO_MATCHING_ID +from silkaj.auth import auth_method +from silkaj.wot import get_uid_from_pubkey +from silkaj.money import get_last_ud_value, get_amount_from_pubkey +from silkaj.constants import NO_MATCHING_ID def send_transaction(ep, cli_args): diff --git a/src/wot.py b/silkaj/wot.py similarity index 97% rename from src/wot.py rename to silkaj/wot.py index 905629cbf6566d33c2e984abe9838fb4043e354b..40712cf79bd6f1aa991c1edc47113013875eb0c7 100644 --- a/src/wot.py +++ b/silkaj/wot.py @@ -3,9 +3,9 @@ from time import time from tabulate import tabulate from collections import OrderedDict -from network_tools import get_request -from tools import message_exit, check_public_key, convert_time -from constants import NO_MATCHING_ID +from silkaj.network_tools import get_request +from silkaj.tools import message_exit, check_public_key, convert_time +from silkaj.constants import NO_MATCHING_ID def get_sent_certifications(certs, time_first_block, params):