...
 
Commits (16)
stages:
- checks
- tests
- publish
- coverage
variables:
DOCKER_IMAGE: "registry.duniter.org/docker/python3/poetry"
image: $DOCKER_IMAGE/3.7:latest
.code_changes:
only:
changes:
- bin/silkaj
- silkaj/*.py
- tests/*.py
.changes:
extends: .code_changes
only:
changes:
- .gitlab-ci.yml
- pyproject.toml
- poetry.lock
build:
extends: .changes
stage: checks
script:
- poetry install --no-dev
- poetry build
format:
extends: .code_changes
stage: checks
image: $DOCKER_IMAGE/3.8:latest
script:
- black --check bin silkaj tests
.type:
extends: .code_changes
stage: checks
script:
- poetry install
- poetry run mypy/pyright
.tests:
extends: .changes
stage: tests
before_script:
- poetry install
tests-3.5:
extends: .tests
image: $DOCKER_IMAGE/3.5:latest
script:
- poetry run pytest
tests-3.6:
extends: .tests
image: $DOCKER_IMAGE/3.6:latest
script:
- poetry run pytest
tests-3.7:
extends: .tests
image: $DOCKER_IMAGE/3.7:latest
script:
- poetry run pytest --cov silkaj --cov-report html:cov_html
- poetry run coverage-badge -o cov_html/coverage.svg
artifacts:
paths:
- cov_html
tests-3.8:
extends: .tests
image: $DOCKER_IMAGE/3.8:latest
script:
- poetry run pytest
pypi_test:
stage: publish
when: manual
script:
- poetry install --no-dev
- poetry config repositories.pypi_test https://test.pypi.org/legacy/
- poetry publish --build --username Silkaj --password $PYPI_TEST_PASSWORD --repository pypi_test
pypi:
stage: publish
only:
- tags
when: manual
script:
- poetry install --no-dev
- poetry publish --build --username GitLab --password $PYPI_PASSWORD
pages:
extends: .code_changes
stage: coverage
script: mv cov_html/ public/
artifacts:
paths:
- public
expire_in: 2 days
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
ipaddress = "*"
tabulate = "*"
PyNaCl = "*"
e1839a8 = {path = ".",editable = true}
duniterpy = "*"
click = "*"
texttable = "*"
[dev-packages]
pre-commit = "*"
black = "*"
setuptools = "*"
wheel = "*"
twine = "*"
pytest = "*"
coverage = "*"
pytest-cov = "*"
pytest-asyncio = "*"
[requires]
python_version = "3.7"
[pipenv]
allow_prereleases = true
This diff is collapsed.
......@@ -10,7 +10,7 @@ pip3 install silkaj --user
```
- [Install with Pip](doc/install_pip.md)
- [Install with pipenv](doc/install_pipenv.md)
- [Install the Development environment](doc/install_poetry.md)
- [Install with the build](doc/install_build.md)
- [Install with docker](doc/install_docker.md)
- [Build an executable with Pyinstaller](doc/build_with_pyinstaller.md)
......
# Install Silkaj with Pipenv
### Install libsodium
```bash
sudo apt install libsodium23 # Debian Buster
sudo apt install libsodium18 # Debian Stretch
sudo dnf install libsodium # Fedora
```
### Install pipenv
```bash
sudo apt install pipenv # Debian ≥ Buster
sudo dnf install pipenv # Fedora
```
- [Pipenv installation instructions](https://github.com/pypa/pipenv#installation)
### Retrieve silkaj sources
```bash
git clone https://git.duniter.org/clients/python/silkaj.git
cd silkaj
```
### Install with dependencies
```bash
pipenv install "-e ."
```
The double quotes are important, if you forget them, `pipenv` will install silkaj from pypi
### Run silkaj
```bash
pipenv run silkaj
```
- You can create shell alias, for instance for Bash, add in the `~/.bashrc`:
```bash
alias silkaj="cd $HOME/silkaj/silkaj && pipenv run silkaj"
```
### Activate pipenv shell and run the executable
```bash
pipenv shell
./bin/silkaj
```
## Manage Python versions with Pyenv
If you have trouble with the pipenv install, may be the Python version installed on your system is not up to date.
To install and manage easily multiple Python version, use Pyenv:
### Install pyenv on your home
```bash
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
```
Add in `~/.bash_profile`, in `~/.bashrc` on Fedora or Ubuntu:
```bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv virtualenv-init -)"
eval "$(pyenv init -)"
export PYENV_ROOT="$HOME/.pyenv"
```
Reload your bash config:
source ~/.bashrc
or
source ~/.bash_profile
### Install Python version required
pyenv install 3.7.2
### Select Python version for the current shell
pyenv shell 3.7.2
Pipenv will search the `Pyenv` Python version chosen before the system version.
## Install Silkaj in a development environement with Poetry
### Install libsodium
```bash
sudo apt install libsodium23 # Debian Buster
sudo apt install libsodium18 # Debian Stretch
sudo dnf install libsodium # Fedora
```
### Install Poetry
- [Installation documentation](https://poetry.eustace.io/docs/#installation)
### Install dependencies and the Python environment
```bash
poetry install
```
### Run Silkaj
Within `silkaj` repository, enter the development environement and run Silkaj:
```bash
poetry shell
./bin/silkaj
```
You might need to enter Poetry shell to access development tools such as `pytest` or `black`.
### Make Silkaj accessible from everywhere
Add following alias to your shell configuration:
```bash
alias silkaj "$HOME/silkaj/silkaj && poetry run silkaj"
```
This diff is collapsed.
[tool.poetry]
name = "silkaj"
version = "0.7.1"
description = "Powerfull, lightweight, and multi-platform command line client written with Python for Duniter’s currencies: Ğ1 and Ğ1-Test."
authors = ["Moul <moul@moul.re>", "Tortue <ucoin@tednet.fr>", "cebash <sebastien@da-rocha.net>"]
readme = "README.md"
license = "AGPL-3.0-or-later"
homepage = "https://silkaj.duniter.org"
repository = "https://git.duniter.org/clients/python/silkaj"
keywords = ["g1", "duniter", "cryptocurrency", "librecurrency", "RTM"]
[tool.poetry.dependencies]
python = "^3.5.3"
duniterpy = "^0.54.3"
#duniterpy = { path = "../duniterpy" }
click = "^7.0"
ipaddress = "^1.0"
tabulate = "^0.8.3"
texttable = "^1.6"
PyNaCl = "^1.3"
[tool.poetry.dev-dependencies]
pre-commit = "^1.16"
pytest = "^5.0"
pytest-cov = "^2.7"
pytest-asyncio = "^0.10.0"
coverage-badge = "^1.0"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Natural Language :: English"
]
......@@ -23,12 +23,12 @@ check_branch() {
update_version() {
sed -i "s/SILKAJ_VERSION = \".*\"/SILKAJ_VERSION = \"$VERSION\"/" silkaj/constants.py
sed -i "s/version=\".*\",/version=\"$VERSION\",/" setup.py
poetry version "$VERSION"
git diff
}
commit_tag() {
git commit silkaj/constants.py setup.py -m "v$VERSION"
git commit silkaj/constants.py pyproject.toml -m "v$VERSION"
git tag "v$VERSION" -a -m "$VERSION"
}
......
from setuptools import setup, find_packages
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
name="silkaj",
version="0.7.1",
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=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 :: Only",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Natural Language :: English",
),
install_requires=[
"Click",
"duniterpy==0.54.3",
"ipaddress",
"texttable",
"tabulate",
"pynacl",
],
scripts=["bin/silkaj"],
)
from subprocess import check_output
from click.testing import CliRunner
from silkaj.cli_tools import cli
def test_info():
"""tests 'silkaj info' returns a number of members"""
output = check_output(["silkaj", "info"])
assert "Number of members" in output.decode()
def test_wot():
"""tests 'silkaj wot' returns a number of members"""
output = check_output(["silkaj", "wot", "moul"]).decode()
assert "moul (GfKER…) from block #0-E3B0C44298FC1…" in output
assert "received_expire" in output
assert "received" in output
assert "sent" in output
assert "sent_expire" in output
def test_id():
"""tests 'silkaj id' certification on gtest"""
output = check_output(["silkaj", "--gtest", "id", "elois"]).decode()
assert "D7CYHJXjaH4j7zRdWngUbsURPnSnjsCYtvo6f8dvW3C" in output
def test_amount():
"""tests 'silkaj amount' command on gtest"""
output = check_output(["silkaj", "--gtest", "balance", "3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj"]).decode()
assert "Total amount of: 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj" in output
assert "Total Relative =" in output
assert "UD ĞTest" in output
assert "Total Quantitative =" in output
result = CliRunner().invoke(cli, ["info"])
assert "Number of members" in result.output
# def test_wot():
# """tests 'silkaj wot' returns a number of members"""
#
# output = CliRunner().invoke(cli, ["wot", "moul"]).output
# assert "moul (GfKER…) from block #0-E3B0C44298FC1…" in output
# assert "received_expire" in output
# assert "received" in output
# assert "sent" in output
# assert "sent_expire" in output
#
#
# def test_id():
# """tests 'silkaj id' certification on gtest"""
#
# result = CliRunner().invoke(cli, ["--gtest", "id", "elois"])
# assert "D7CYHJXjaH4j7zRdWngUbsURPnSnjsCYtvo6f8dvW3C" in result.output
#
#
# def test_amount():
# """tests 'silkaj amount' command on gtest"""
#
# result = CliRunner().invoke(
# cli, ["--gtest", "balance", "3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj"]
# )
# output = result.output
# assert "Total amount of: 3dnbnYY9i2bHMQUGyFp5GVvJ2wBkVpus31cDJA5cfRpj" in output
# assert "Total Relative =" in output
# assert "UD ĞTest" in output
# assert "Total Quantitative =" in output
......@@ -3,12 +3,9 @@ import pytest
from silkaj.tx import truncBase
@pytest.mark.parametrize('amount,base,expected', [
(0, 0, 0),
(10, 2, 0),
(100, 2, 100),
(306, 2, 300),
(3060, 3, 3000),
])
@pytest.mark.parametrize(
"amount,base,expected",
[(0, 0, 0), (10, 2, 0), (100, 2, 100), (306, 2, 300), (3060, 3, 3000)],
)
def test_truncBase(amount, base, expected):
assert truncBase(amount, base) == expected