Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry migration #370

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 60 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,74 @@ jobs:
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]
# Current (1.7.1) version of poetry doesn't support python < 3.8, and poetry 1.1.13 is the last version with
# python 3.6 support, so use it for both python 3.6 and 3.7
include:
- poetry-version: 1.7.1
- python-version: 3.6
poetry-version: 1.1.13
- python-version: 3.7
poetry-version: 1.1.13
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-${{ matrix.poetry-version }}-${{ matrix.python-version }}

- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
version: ${{ matrix.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Unset unsupported group directive from pyproject.toml for poetry 1.1.13
if: matrix.poetry-version == '1.1.13'
# removing the section and one string after it, that contains sphinx dependency, that isn't needed for these
# tests anyway
run: sed -i '/\[tool.poetry.group.docs.dependencies\]/,+1 d' pyproject.toml

# Checking pyproject.toml just in case
- name: Check pyproject.toml validity
run: poetry check --no-interaction

# The lock file format has changed since 1.1.3, so we just recreate it.
# Be aware that it will have different versions, than the repository lock file.
- name: Recreate lock file (for poetry 1.1.13)
if: matrix.poetry-version == '1.1.13'
# poetry.lock should be deleted before recreating it, or an error occurs
run: rm poetry.lock && poetry lock

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: |
sudo apt update
sudo apt-get install -y libxml2-dev libxmlsec1-dev
python -m pip install --upgrade pip
pip install -r requirements.txt
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# --no-root because it makes no sense to install our package into cache.
run: poetry install --no-interaction --no-root

# If we would need our package installed - here is the way. But we don't.
# - name: Install project
# run: poetry install --no-interaction

- name: Run tests
run: |
python -m unittest tests.tests
poetry run python -m unittest tests.tests
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
version := $(shell python -c "exec(open('pykeepass/version.py').read());print(__version__)")

.PHONY: dist
dist:
python setup.py sdist bdist_wheel
poetry build

.PHONY: pypi
pypi: dist
twine upload dist/pykeepass-$(version).tar.gz
twine upload --skip-existing dist/pykeepass-*

.PHONY: docs
docs:
Expand Down
27 changes: 21 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ pykeepass

.. image:: https://img.shields.io/badge/irc-%23pykeepass-brightgreen
:target: https://webchat.freenode.net/?channels=pykeepass

This library allows you to write entries to a KeePass database.

Come chat at `#pykeepass`_ on Freenode or `#pykeepass:matrix.org`_ on Matrix.

.. _#pykeepass: irc://irc.freenode.net
.. _#pykeepass\:matrix.org: https://matrix.to/#/%23pykeepass:matrix.org
.. _#pykeepass\:matrix.org: https://matrix.to/#/%23pykeepass:matrix.org

Example
-------
Expand Down Expand Up @@ -69,7 +69,7 @@ Finding Entries
Returns entries which match all provided parameters, where ``title``, ``username``, ``password``, ``url``, ``notes``, ``otp``, ``autotype_window`` and ``autotype_sequence`` are strings, ``path`` is a list, ``string`` is a dict, ``autotype_enabled`` is a boolean, ``uuid`` is a ``uuid.UUID`` and ``tags`` is a list of strings. This function has optional ``regex`` boolean and ``flags`` string arguments, which means to interpret search strings as `XSLT style`_ regular expressions with `flags`_.

.. _XSLT style: https://www.xml.com/pub/a/2003/06/04/tr.html
.. _flags: https://www.w3.org/TR/xpath-functions/#flags
.. _flags: https://www.w3.org/TR/xpath-functions/#flags

The ``path`` list is a full path to an entry (ex. ``['foobar_group', 'foobar_entry']``). This implies ``first=True``. All other arguments are ignored when this is given. This is useful for handling user input.

Expand Down Expand Up @@ -123,7 +123,7 @@ Finding Groups
where ``name`` and ``notes`` are strings, ``path`` is a list, ``uuid`` is a ``uuid.UUID``. This function has optional ``regex`` boolean and ``flags`` string arguments, which means to interpret search strings as `XSLT style`_ regular expressions with `flags`_.

.. _XSLT style: https://www.xml.com/pub/a/2003/06/04/tr.html
.. _flags: https://www.w3.org/TR/xpath-functions/#flags
.. _flags: https://www.w3.org/TR/xpath-functions/#flags

The ``path`` list is a full path to a group (ex. ``['foobar_group', 'sub_group']``). This implies ``first=True``. All other arguments are ignored when this is given. This is useful for handling user input.

Expand Down Expand Up @@ -311,7 +311,7 @@ the entry that this attachment is attached to
>>> a = e.add_attachment(binary_id, 'hello.txt')
>>> a
Attachment: 'hello.txt' -> 0

# access attachments
>>> a
Attachment: 'hello.txt' -> 0
Expand Down Expand Up @@ -418,7 +418,22 @@ pretty print database XML to file
Tests and Debugging
-------------------

Run tests with :code:`python tests/tests.py` or :code:`python tests/tests.py SomeSpecificTest`
Clone the repository

:code:`git clone https://github.com/libkeepass/pykeepass.git`

Go into the source code directory

:code:`cd pykeepass`

Install the package and it's dependencies into virtual environment

:code:`poetry install`

Run tests with
:code:`poetry run python tests/tests.py`
or for some specific test
:code:`poetry run python tests/tests.py SomeSpecificTest`

Enable debugging when doing tests in console:

Expand Down
Loading
Loading