Skip to main content

Skycoin Python Library

Project description

PySkycoin

Build Status

Python extension for Skycoin API. A Python extension generated with SWIG to access Skycoin API from Python.

Table of Contents

Installation

Download the repository from http://github.com/simelo/pyskycoin.git. Execute (python setup.py install) to install the library. Although executing (python setup.py develop) is a better choice for making changes to the library. However, when using tox these commands are not required at all because calling tox will make any necessary installation and execute the tests.

Usage

Naming

The exported function in PySkycoin have the following naming format: SKY_package_func_name where package is replace by the package where the original Skycoin function is and func_name is the name of the function. For example, LoadConfig function from cli package is called in Python SKY_cli_LoadConfig

Parameters

All skycoin exported functions return an error object as the last of the return parameters. In Pyskycoin error is return as an integer and it is the first return parameter. The rest of the parameters are returned in the same order.

Receivers in Skycoin are the first of the input parameters. Simple types, like integer, float, string will be used as the corresponding types in Python.

Handles

Some of Skycoin types are too complex to be exported to a scripting language. So, handles are used instead. Therefore all functions taking a complex type will receive a handle instead of the original Skycoin type. For example, having these functions exported from Skycoin:

	func LoadConfig() (Config, error)
	func (c Config) FullWalletPath() string

Config is a struct type that is treated as a handle in Pyskycoin. The usage in Python will be:

import skycoin
	
def main:
	err, configHandle = skycoin.SKY_cli_LoadConfig()
	if err == skycoin.SKY_OK:  # 0 then no error
		fullWalletPath = skycoin.SKY_cli_FullWalletPath(configHandle)
		print fullWallerPath
		#Close the handle after using the it
		#so the garbage collector can delete the object associated with it. 
		skycoin.SKY_handle_close( configHandle )
	else: 
		#Error
		print err

Byte slices

Parameters of type byte[] will treated as string . Example, this function in Skycoin:

func (s ScryptChacha20poly1305) Encrypt(data, password []byte) ([]byte, error)

Will be called like this:

encrypt_settings = skycoin.encrypt__ScryptChacha20poly1305()
data = "Data to encrypt" #It will be passed as a parameter of type []byte
pwd = "password"         #As []byte too
err, encrypted = skycoin.SKY_encrypt_ScryptChacha20poly1305_Encrypt(encrypt_settings, data, pwd)
if err == skycoin.SKY_OK:
	print encrypted #Encrypted is string

Structures

Structures that are not exported as handles are treated like classes in Python. In the previous example type ScryptChacha20poly1305 is created in Python like:

encrypt_settings = skycoin.encrypt__ScryptChacha20poly1305()

And passed as first parameter in call to SKY_encrypt_ScryptChacha20poly1305_Encrypt.

Fixed Sized Arrays

Parameters of fixed size array are wrapped in structures when called from python.

Given these types in Skycoin:

	type PubKey [33]byte
	type SecKey [32]byte

And this exported function:

	func GenerateDeterministicKeyPair(seed []byte) (PubKey, SecKey)

This is how it is used in Python:

#Generates random seed
err, data = skycoin.SKY_cipher_RandByte(32)
assert err == error["SKY_OK"]
pubkey = skycoin.cipher_PubKey()
seckey = skycoin.cipher_SecKey()
err = skycoin.SKY_cipher_GenerateDeterministicKeyPair(data, pubkey, seckey)

pubkey and seckey are objects of type structure containing a field name data for the corresponding type of PubKey and SecKey. Something like:

	cipher_PubKey struct{
		data [33]byte;
	} cipher_PubKey;

	cipher_SecKey struct{
		data [32]byte;
	} ;

Other Slices

Other slices of type different than byte were wrapped inside classes. Calling the following function:

func GenerateDeterministicKeyPairs(seed []byte, n int) []SecKey

Would be like:

#Generates random seed
err, seed = skycoin.SKY_cipher_RandByte(32)
err, seckeys = skycoin.SKY_cipher_GenerateDeterministicKeyPairs(seed, 2)
for seckey in seckeys:
	pubkey = skycoin.cipher_PubKey()
	skycoin.SKY_cipher_PubKeyFromSecKey(seckey, pubkey)
	err = skycoin.SKY_cipher_PubKey_Verify(pubkey)
	assert err == error["SKY_OK"]

Memory Management

Memory management is transparent to the user. Any object allocated inside the library is left to be managed by Python garbage collector.

Make Rules

All these make rules require skycoin to be a git submodule of pyskycoin

  • build-libc
    • Compiles skycoin C language library.
  • build-swig
    • Creates the wrapper C code to generate the Python library.
  • develop
    • Install a developer version of the module.
  • test
    • Compiles skycoin C language library, creates the wrapper and execute Tox. Tox installs compiles the Python library and executes the tests.

Development setup

It is highly recommended for developers to setup their environment using the available Docker images. Read the PySkycoin Docker docs for further details.

The project has two branches: master and develop.

  • develop is the default branch and will always have the latest code. The submodule at gopath/src/github.com/skycoin/skycoin has to be in sync with skycoin/skycoin develop branch.
  • master will always be equal to the current stable release on the website, and should correspond with the latest release tag. The submodule at gopath/src/github.com/skycoin/skycoin has to be in sync with skycoin/skycoin master branch.

Separate stable development branches will be created to work on releases for supporting the most recent stable version of Skycoin. The name of these branches should be the Skycoin major and minor version numbers followed by dev suffix e.g. 0.25dev. These branches may be forked out of either master or develop branches, and the submodule at gopath/src/github.com/skycoin/skycoin has to be in sync with the corresponding tag of skycoin/skycoin official repository.

Stable development branches are created most of the time for the following reasons:

  • A Skycoin release increasing patch version number.
  • Enhanced support and bug fixes for a version of PySkycoin compiled against an stable version of Skycoin
  • Backporting useful features added in develop.

Running tests

$ make test

Releases

Update the version

  1. If the master branch has commits that are not in develop (e.g. due to a hotfix applied to master), merge master into develop (and fix any build or test failures)
  2. Switch to a new release branch named release-X.Y.Z for preparing the release.
  3. Ensure that the submodule at gopath/src/github.com/skycoin/skycoin is in sync with respect to the corresponding tag in https://github.com/skycoin/skycoin repository.
  4. Update __version__ in skycoin/__init__.py
  5. Run make build to make sure that the code base is up to date
  6. Update CHANGELOG.md: move the "unreleased" changes to the version and add the date.
  7. Follow the steps in pre-release testing
  8. Make a PR merging the release branch into master
  9. Review the PR and merge it
  10. Update files in https://github.com/skycoin/repo-info/tree/master/repos/skycoin/remote for simelotech/skycoindev-dotnet Docker image, adding a new file for the new version and adjusting any configuration text that may have changed
  11. Tag the master branch with the version number. Version tags start with v, e.g. v0.20.0. Sign the tag. If you have your GPG key in github, creating a release on the Github website will automatically tag the release. It can be tagged from the command line with git tag -as v0.20.0 $COMMIT_ID, but Github will not recognize it as a "release".
  12. Release builds are created and uploaded by travis. To do it manually, checkout the master branch and follow the create release builds instructions.
  13. Checkout develop branch and bump __version__ to next dev version number.

Pre-release testing

Perform these actions before releasing:

make check
make integration-test

Creating release builds

Release builds should be created from git tags . After updating release version it is necessary to follow these steps

cd /path/to/pyskycoin
python3 setup.py sdist bdist_wheel
python3 -m pip install --user --upgrade twine
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyskycoin-0.25.0.post1.tar.gz (23.5 MB view details)

Uploaded Source

Built Distributions

pyskycoin-0.25.0.post1-cp37-cp37m-manylinux1_x86_64.whl (585.9 kB view details)

Uploaded CPython 3.7m

pyskycoin-0.25.0.post1-cp37-cp37m-macosx_10_13_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.7m macOS 10.13+ x86-64

pyskycoin-0.25.0.post1-cp36-cp36m-manylinux1_x86_64.whl (585.9 kB view details)

Uploaded CPython 3.6m

pyskycoin-0.25.0.post1-cp36-cp36m-macosx_10_13_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.6m macOS 10.13+ x86-64

pyskycoin-0.25.0.post1-cp35-cp35m-manylinux1_x86_64.whl (585.9 kB view details)

Uploaded CPython 3.5m

pyskycoin-0.25.0.post1-cp35-cp35m-macosx_10_13_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.5m macOS 10.13+ x86-64

pyskycoin-0.25.0.post1-cp34-cp34m-manylinux1_x86_64.whl (585.7 kB view details)

Uploaded CPython 3.4m

pyskycoin-0.25.0.post1-cp34-cp34m-macosx_10_13_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.4m macOS 10.13+ x86-64

pyskycoin-0.25.0.post1-cp27-cp27mu-manylinux1_x86_64.whl (598.1 kB view details)

Uploaded CPython 2.7mu

pyskycoin-0.25.0.post1-cp27-cp27m-manylinux1_x86_64.whl (598.1 kB view details)

Uploaded CPython 2.7m

File details

Details for the file pyskycoin-0.25.0.post1.tar.gz.

File metadata

  • Download URL: pyskycoin-0.25.0.post1.tar.gz
  • Upload date:
  • Size: 23.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1.tar.gz
Algorithm Hash digest
SHA256 9b6cf58ea9304fe856dc9fdd46e6ca39f8d6f0aa411746713432270dce8e9a83
MD5 1fe8ced269ce0934919b1cada959e16a
BLAKE2b-256 080e1ba0d5a420646cec5fc522737f7d348b50f91d840668eb6a7bfb07453c86

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 585.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 41681d7f32d6e50d8a595929d87c0a457cb92a07ecbfbd383c4fded990b1eb76
MD5 1b25aeb359e962346005b8a0762d7acb
BLAKE2b-256 37322e502127647e60c649356c740f8e36cd62a67a99abdf3c69da2d0ff26797

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for pyskycoin-0.25.0.post1-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e4d1fb7edb55a69b4c3dfec8ac5bbe42645d98f9289341a763cf19640bf29906
MD5 cfecaa6e9a1fd96cd8042545309c435b
BLAKE2b-256 de8f500bd1a2e325ce7bfde4e030d3bd751ebfe13aa83ee9968f0361fdb2f2b9

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 585.9 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ebdcf6ce60c7a087788f7cf3a8223cb5c77225775bfeb03b0354d45c461bc53e
MD5 4868f790042d119d15690cbec4df148c
BLAKE2b-256 d6e933ba5313bb5f0d9a27c922ea7ddf0bb329749c230abde6fa78256d68a33e

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp36-cp36m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp36-cp36m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.6m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5

File hashes

Hashes for pyskycoin-0.25.0.post1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 523ea55f2b81de8b133ee0e1fadaeba186e16a9a1de4c2efbe2999cef0ff6efc
MD5 02ae8b2db28f4724c90efbb12ee85e53
BLAKE2b-256 5f6ca88895f7cc9417ed03850867cf0f35ae9beeb88c5b99b8ce4f4c0a971bd5

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 585.9 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fd974fb102bf368fc0186f205e7b4cb1c21d80bb9e953f1824ff788720b263cd
MD5 1825619efaf69216ce99bcb94d276fb7
BLAKE2b-256 ddd3ba1ac0acae2e43ec215987f1c48649ac952f66c90825f7e0bbae06dbe6d8

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp35-cp35m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp35-cp35m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.5m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.5

File hashes

Hashes for pyskycoin-0.25.0.post1-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 10aa829c365ecba4c569130e66bfdc511fe8fcb6f01216538874be75588d17a7
MD5 2912c1a0c3a8e0a7e9cb234ee80b4878
BLAKE2b-256 442b0dfb1cbb3e202898207a49074902aefae3a3fb51a9c7133e83314038cc5f

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp34-cp34m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 585.7 kB
  • Tags: CPython 3.4m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 556b2333fe0f09503eddc1d8de9736649517a9c47606100e38662801ea28e456
MD5 cce71e8a2aba2db0334156c7a6cb1e71
BLAKE2b-256 507ad669813ddb1ee4a6cbaf0914efcf0dd169446047eb695869d6c42b9f89d0

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp34-cp34m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp34-cp34m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.4m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp34-cp34m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 15bd555c9c32811729bfd07ff4dc42ac1bb0e99fe05bd8bfdf1d558a910d7d20
MD5 3d4c9dd20561e0448f7aa79270d04f23
BLAKE2b-256 5849edd7663948debbcb96509880dee94eece8846a7a3f8132776e3df4e46429

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 598.1 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9617daf69c1e663a638cffbd758176dc8fb45abca40d57ea5bbf92c3b42d51a1
MD5 568bff2a475d7c8ca07c824839d696cc
BLAKE2b-256 26f485fc792e89f360e2241aa934d17988837cc2beb806eefa3098a3228746eb

See more details on using hashes here.

File details

Details for the file pyskycoin-0.25.0.post1-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pyskycoin-0.25.0.post1-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 598.1 kB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.4.8

File hashes

Hashes for pyskycoin-0.25.0.post1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9588d00caf5302f3fedf37ba0ccf8e77669f3f77c6c468f7e6be19a95889f8fe
MD5 e4f5753c40c2cd445ee1317ec6614821
BLAKE2b-256 09c3bcb8fe682c4860e206f10e918e1baa532ff90dc85ab52fcbc0609f4007b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page