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

#2289 Migrate to Poetry #2436

Merged
merged 27 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fc118c5
move from requirements.txt to poetry
Gavinok Aug 19, 2023
f111da7
Merge branch 'main' into migrate-to-poetry
Gavinok Aug 19, 2023
5b8ba48
Add python3-indy for Dockerfile.indy and corrected pyproject.toml
Gavinok Aug 19, 2023
5bfc54e
removed old setup.py and requirements.txt files
Gavinok Aug 19, 2023
8246b6c
Migrate poetry groups to extra dependancies
Gavinok Aug 22, 2023
d2db5dc
Updated test workflow to use poetry
Gavinok Aug 22, 2023
d1baab1
use pip install as the dockerfiles do for poetry
Gavinok Aug 22, 2023
e33d164
Corrected outdated "Indy Agent" to "Aries Agent"
Gavinok Aug 22, 2023
6d06184
Converted bash script to a python script for poetry support
Gavinok Aug 22, 2023
b6c9cc7
Simplify install by installing the complete package
Gavinok Aug 22, 2023
5cb336e
change entry point to be in 'name=module:attrs [extras]' format
Gavinok Aug 22, 2023
2aac2ce
Move tests from being optional to being a dev dependency
Gavinok Aug 22, 2023
65d058e
instead of os for aca-py import the module it's self
Gavinok Aug 24, 2023
ff377ec
Dropped dedicated aca-py script for poetry calling of main()
Gavinok Aug 24, 2023
8347c0b
bin directory is no longer necessary
Gavinok Aug 24, 2023
9d7a416
Create a dedicated scripting main to prevent failing during tests
Gavinok Aug 24, 2023
219240d
Conform to flake8
Gavinok Aug 24, 2023
ca60314
Corrected name of function in aca-py script
Gavinok Aug 24, 2023
9205b65
Merge branch 'main' into migrate-to-poetry
Gavinok Aug 25, 2023
981bc6c
removed tests as an extra and added hyperledger as the author
Gavinok Aug 25, 2023
afa1a67
Update publication to now use poetry
Gavinok Aug 25, 2023
433086d
Merge branch 'main' into migrate-to-poetry
Gavinok Aug 25, 2023
7bf400b
Merge branch 'main' into migrate-to-poetry
Gavinok Aug 28, 2023
93dfcab
Update devcontainer to use the poetry files.
Gavinok Aug 29, 2023
e7423b5
Added a Poetry.md
Gavinok Aug 29, 2023
ef6aac7
Relocate Poetry.md to the docs directory for consistancy
Gavinok Aug 29, 2023
040e830
Merge branch 'main' into migrate-to-poetry
usingtechnology Aug 29, 2023
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
20 changes: 19 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,22 @@
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# if we need to enhance this image we can do it in this dockerfile or the post-install.sh script
ARG POETRY_VERSION="1.4"
ENV POETRY_HOME="/opt/poetry" \
POETRY_VERSION=${POETRY_VERSION}

RUN curl -sSL https://install.python-poetry.org | python3 - \
&& update-alternatives --install /usr/local/bin/poetry poetry /opt/poetry/bin/poetry 900 \
# Enable tab completion for bash
&& poetry completions bash >> /home/vscode/.bash_completion \
# Enable tab completion for Zsh
&& mkdir -p /home/vscode/.zfunc/ \
&& poetry completions zsh > /home/vscode/.zfunc/_poetry \
&& echo "fpath+=~/.zfunc\nautoload -Uz compinit && compinit" >> /home/vscode/.zshrc

COPY pyproject.toml poetry.lock ./
# we do not want the packages defined for this install, comment out the line.
RUN sed -i 's/^[^#]*packages/#&/' pyproject.toml
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --all-extras \
&& rm -rf /root/.cache/pypoetry
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.9-bullseye"
"VARIANT": "3.9-bullseye",
"POETRY_VERSION": "1.4.2"
}
},
"customizations": {
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKSPACE_DIR=$(pwd)

# install all ACA-Py requirements
python -m pip install --upgrade pip
pip3 install -r requirements.txt -r requirements.askar.txt -r requirements.bbs.txt -r requirements.dev.txt -r requirements.indy.txt
pip3 install -r demo/requirements.txt -r demo/requirements.behave.txt

# install black for formatting
pip3 install black
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine poetry
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
poetry build
twine upload dist/*
13 changes: 4 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ jobs:
python-version: ${{ inputs.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements*.txt'
- name: Install dependencies
- name: Install the project dependencies
run: |
python -m pip install --upgrade pip
pip3 install --no-cache-dir \
-r requirements.txt \
-r requirements.askar.txt \
-r requirements.bbs.txt \
-r requirements.dev.txt
pip install poetry
poetry install -E "askar bbs"
- name: Tests
run: |
pytest
run: poetry run pytest
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,4 @@ _build/
**/*.iml

# Open API build
open-api/.build

# poetry
poetry.lock
pyproject.toml
open-api/.build
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ You can extend Aca-Py using plug-ins, which can be loaded at runtime. Plug-ins

An ["install and go" page for developers](https://github.com/hyperledger/aries-cloudagent-python/blob/main/DevReadMe.md) is available if you are comfortable with Trust over IP and Aries concepts. ACA-Py can be run with Docker without installation (highly recommended), or can be installed [from PyPi](https://pypi.org/project/aries-cloudagent/). In the [/demo directory](/demo) there is a full set of demos for developers to use in getting started, and the [demo read me](/demo/README.md) is a great starting point for developers to use an "in-browser" approach to run a zero-install example. The [Read the Docs](https://aries-cloud-agent-python.readthedocs.io/en/latest/) overview is also a way to reference the modules and APIs that make up an ACA-Py instance.

If you would like to develop on ACA-Py locally note that we use Poetry for dependency management and packaging, if you are unfamiliar with poetry please see our [cheat sheet](/docs/Poetry.md)

## About the ACA-Py Admin API

The [overview of ACA-Py’s API](https://github.com/hyperledger/aries-cloudagent-python/blob/main/AdminAPI.md) is a great starting place for learning about the ACA-Py API when you are starting to build your own controller.
Expand Down
13 changes: 9 additions & 4 deletions aries_cloudagent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ def run(args):
run_command(command, args)


def script_main():
"""Run the main function as a script for poetry."""
main(sys.argv)


def main(args):
"""Execute default entry point."""
if __name__ == "__main__":
init_debug(args)
run(args)
init_debug(args)
run(args)


main(sys.argv)
if __name__ == "__main__":
script_main()
10 changes: 0 additions & 10 deletions bin/aca-py

This file was deleted.

5 changes: 4 additions & 1 deletion devcontainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ The primary use case for this `devcontainer` is for developing, debugging and un
There are limitations running this devcontainer, such as all networking is within this container. This container has [docker-in-docker](https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md) which allows running demos, building docker images, running `docker compose` all within this container.

### Files
The `.devcontainer` folder contains the `devcontainer.json` file which defines this container. We are using a `Dockerfile` and `post-install.sh` to build and configure the container run image. The `Dockerfile` is simple but in place for simplifying image enhancements (ex. adding `poetry` to the image). The `post-install.sh` will install all the ACA-Py requirements and any additional steps (ex. adding additional development libraries).
The `.devcontainer` folder contains the `devcontainer.json` file which defines this container. We are using a `Dockerfile` and `post-install.sh` to build and configure the container run image. The `Dockerfile` is simple but in place for simplifying image enhancements (ex. adding `poetry` to the image). The `post-install.sh` will install some additional development libraries (including for BDD support).

### Poetry
The Python libraries / dependencies are installed using [`poetry`](https://python-poetry.org). For the devcontainer, we *DO NOT* use virtual environments. This means you will not see or need venv prompts in the terminals and you will not need to run tasks through poetry (ie. `poetry run black .`). If you need to add new dependencies, you will need to add the dependency via poetry *AND* you should rebuild your devcontainer.

### Running docker-in-docker demos
The following is an example of running the demos in this container using a local [von-network](https://github.com/bcgov/von-network/tree/main). You will have to connect to the local von-network using `host.docker.internal` not `localhost`.
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ WORKDIR /src

ADD . .

RUN pip install setuptools wheel
RUN python setup.py sdist bdist_wheel
RUN pip install --no-cache-dir poetry
RUN poetry build

FROM python:${python_version}-slim-bullseye AS main

Expand Down
15 changes: 5 additions & 10 deletions docker/Dockerfile.demo
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,15 @@ RUN mkdir -p bin && curl -L -o bin/jq \
https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
chmod ug+x bin/jq

# Add and install Indy Agent code
ADD requirements*.txt ./
# Add and install Aries Agent code
RUN pip install --no-cache-dir poetry

RUN pip3 install --no-cache-dir \
-r requirements.txt \
-r requirements.askar.txt \
-r requirements.bbs.txt \
-r requirements.dev.txt
ADD README.md pyproject.toml poetry.lock ./

RUN poetry install --no-root --no-directory -E "askar bbs"

ADD aries_cloudagent ./aries_cloudagent
ADD bin ./bin
ADD README.md ./
ADD scripts ./scripts
ADD setup.py ./

RUN pip3 install --no-cache-dir -e .

Expand Down
15 changes: 6 additions & 9 deletions docker/Dockerfile.indy
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,16 @@ WORKDIR /home/indy/src

RUN mkdir -p test-reports && chown -R indy:indy test-reports && chmod -R ug+rw test-reports

ADD requirements*.txt ./
ADD ./README.md pyproject.toml ./poetry.lock ./

USER root
RUN pip3 install --no-cache-dir \
-r requirements.txt \
-r requirements.askar.txt \
-r requirements.bbs.txt \
-r requirements.dev.txt
RUN pip install --no-cache-dir poetry
RUN poetry install --no-root --no-directory -E "askar bbs indy"

ADD --chown=indy:root . .
USER indy

ENTRYPOINT ["/bin/bash", "-c", "pytest \"$@\"", "--"]
ENTRYPOINT ["/bin/bash", "-c", "poetry run pytest \"$@\"", "--"]

# ACA-Py Builder
# Build ACA-Py wheel using setuptools
Expand All @@ -210,8 +207,8 @@ WORKDIR /src

ADD . .

RUN pip install setuptools wheel
RUN python setup.py sdist bdist_wheel
RUN pip install --no-cache-dir poetry
RUN poetry build


# ACA-Py Indy
Expand Down
22 changes: 8 additions & 14 deletions docker/Dockerfile.run
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@ ENV ENABLE_PTVSD 0

# For consistency with base images, include curl for healthchecks
RUN apt-get update && apt-get install -y curl && apt-get clean
ADD requirements*.txt ./

RUN pip3 install --no-cache-dir \
-r requirements.txt \
-r requirements.askar.txt \
-r requirements.bbs.txt \
-r requirements.dev.txt
RUN pip install --no-cache-dir poetry

RUN mkdir aries_cloudagent && touch aries_cloudagent/__init__.py
ADD aries_cloudagent/version.py aries_cloudagent/version.py
ADD bin ./bin
ADD README.md ./
ADD setup.py ./
ADD . .

RUN poetry install -E "askar bbs"

RUN pip3 install --no-cache-dir -e .
RUN mkdir -p aries_cloudagent && touch aries_cloudagent/__init__.py
ADD aries_cloudagent/version.py aries_cloudagent/version.py

RUN mkdir logs && chmod -R ug+rw logs
RUN mkdir -p logs && chmod -R ug+rw logs
ADD aries_cloudagent ./aries_cloudagent

ENTRYPOINT ["/bin/bash", "-c", "aca-py \"$@\"", "--"]
ENTRYPOINT ["/bin/bash", "-c", "poetry run aca-py \"$@\"", "--"]
12 changes: 5 additions & 7 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ RUN apt-get update -y && \

WORKDIR /usr/src/app

ADD requirements*.txt ./
RUN pip install --no-cache-dir poetry

RUN pip3 install --no-cache-dir \
-r requirements.txt \
-r requirements.askar.txt \
-r requirements.bbs.txt \
-r requirements.dev.txt
ADD ./README.md pyproject.toml ./poetry.lock ./

RUN poetry install --no-root --no-directory -E "askar bbs"

ADD . .

ENTRYPOINT ["/bin/bash", "-c", "pytest \"$@\"", "--"]
ENTRYPOINT ["/bin/bash", "-c", "poetry run pytest \"$@\"", "--"]
Loading