Skip to content

Commit

Permalink
Merge pull request #24 from VirgilSecurity/v5
Browse files Browse the repository at this point in the history
V5
  • Loading branch information
kmuzychko authored Aug 14, 2019
2 parents 237cf09 + e2bf3e6 commit 9128a76
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ virgil_crypto/*virgil_crypto_python*
.vscode
.DS_Store
/doc-source/api-doc/
generated-docs/
generated-docs/
docs/
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ python:

env:
global:
- REPO=VirgilSecurity/virgil-sdk-python
- GIT_TAG=$TRAVIS_TAG
- GIT_COMMIT=$TRAVIS_COMMIT
- GIT_BRANCH=$TRAVIS_BRANCH
- OS_NAME=$(echo $TRAVIS_OS_NAME)

matrix:
Expand Down Expand Up @@ -78,6 +82,23 @@ script:
- pwd
- python -m unittest discover -s virgil_crypto/tests -p "*_test.py"

after_success: |
if [[ $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
make docs
fi
deploy:
# Upload docs to gh-pages
- provider: pages
skip_cleanup: true
github-token: $GITHUB_ACCESS_TOKEN
local_dir: "docs"
on:
repo: $REPO
tags: true
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+

notifications:
email:
- [email protected]
66 changes: 66 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.PHONY: wheel docs

PYTHON3="python3.5"
REPO=VirgilSecurity/virgil-crypto-python
REPO_PATH=https://github.com/${REPO}.git
DOCS_DEST="./docs"
API_DOCS="./doc-source/api-doc"
CURRENT_VERSION=$$(sed -n -E -e 's/__version__ = \"(.*)\"/\1/p' virgil_crypto/__init__.py)
CURRENT_VERSION_DIR="${DOCS_DEST}/v${CURRENT_VERSION}"

define clean_api_docs
@echo "Clean api-docs directory"
@if [ -d ${API_DOCS} ]; then \
rm -r ${API_DOCS}; \
fi
endef

define clean_dist
@echo "Clean docs directory"
@if [ -d ./dist ]; then \
rm -r ./dist; \
fi
endef

define clean_after_wheel
@echo "Cleaning after wheel build"
rm -r ./build
rm -r ./*.egg-info
endef

sphinx_docs:
@echo ">>> Generate Api Docs"
$(call clean_api_docs)
sphinx-apidoc -f -e -R ${GIT_TAG} -V ${GIT_TAG} -o ${API_DOCS} ./virgil_crypto *test*


@echo "Check ${DOCS_DEST} exist"
@if [ -d ${API_DOCS} ]; then \
if [ ! -d ${API_DOCS} ]; then \
mkdir ${API_DOCS}; \
fi \
else \
mkdir -p ${API_DOCS}; \
fi

sphinx-build ./doc-source ${CURRENT_VERSION_DIR}

docs:
@echo ">>> Start generating docs"
mkdir -p ${DOCS_DEST}
git clone -b gh-pages "${REPO_PATH}" --single-branch ${DOCS_DEST}
make sphinx_docs
${PYTHON3} -m pip install jinja2
${PYTHON3} ci/render_index.py ${DOCS_DEST}

wheel:
${PYTHON3} setup.py bdist_wheel --universal --python-tag py2.py3
$(call clean_after_wheel)


upload_testpypi:
twine upload -r pypitest dist/*

clean:
$(call clean_api_docs)
$(call clean_dist)
15 changes: 15 additions & 0 deletions ci/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Virgil Security Python Crypto</title>
</head>
<body>
Virgil Security Python Crypto
<ul>
{%- for dir in version_dirs %}
<li><p><a href="{{ dir }}/index.html">{{ dir }}</a></p></li>
{%- endfor %}
</ul>
</body>
</html>
21 changes: 21 additions & 0 deletions ci/render_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from jinja2 import Environment, FileSystemLoader, select_autoescape
import os
import sys

if __name__ == '__main__':
template_loader = FileSystemLoader(searchpath="./")
env = Environment(
loader=template_loader,
autoescape=select_autoescape(['html'])
)

template = env.get_template('ci/index.html')

target_dir = sys.argv[1]
version_list = list()
for item in os.listdir(target_dir):
item_full_path = os.path.join(target_dir, item)
if os.path.isdir(item_full_path) and "git" not in item:
version_list.append((item))

open(os.path.join(target_dir, "index.html"), "w").write(template.render(version_dirs=version_list))
6 changes: 3 additions & 3 deletions doc-source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
# -- Project information -----------------------------------------------------

project = 'Virgil Crypto'
copyright = '2018, Virgil Security'
copyright = '2016-2019, Virgil Security'
author = 'Virgil Security'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = 'v3'
release = 'v5'


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -185,4 +185,4 @@
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
# -- Extension configuration -------------------------------------------------
6 changes: 1 addition & 5 deletions doc-source/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.. Virgil Crypto documentation master file, created by
sphinx-quickstart on Thu Nov 8 16:49:22 2018.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Virgil Crypto's documentation!
=========================================

Expand All @@ -11,6 +6,7 @@ Welcome to Virgil Crypto's documentation!
:caption: Contents:

:glob:
installation
api-doc/modules


Expand Down
9 changes: 9 additions & 0 deletions doc-source/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Installation
============

The Virgil Crypto is provided as a package named *virgil-crypto*. The package is distributed via Pypi package management system.
To install the pip package use the command below

.. code-block:: bash
pip install virgil-crypto
2 changes: 1 addition & 1 deletion virgil_crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

__version__ = "5.0.0"
__version__ = "5.0.1"

from .crypto import VirgilCrypto
4 changes: 2 additions & 2 deletions virgil_crypto/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ def encrypt(self, data, *recipients):

return result

@staticmethod
def decrypt(data, private_key):
def decrypt(self, data, private_key):
# type: (Union[Tuple[int], List[int]], VirgilPrivateKey) -> Tuple[int]
"""Decrypts the specified data using Private key.
Expand All @@ -277,6 +276,7 @@ def decrypt(data, private_key):
Decrypted data bytes.
"""
cipher = RecipientCipher()
cipher.set_random(self.rng)

cipher.start_decryption_with_key(
private_key.identifier,
Expand Down

0 comments on commit 9128a76

Please sign in to comment.