diff --git a/.github/workflows/upload-python-docs.yml b/.github/workflows/upload-python-docs.yml new file mode 100644 index 000000000..141da1f9d --- /dev/null +++ b/.github/workflows/upload-python-docs.yml @@ -0,0 +1,25 @@ +name: Build & Deploy Documentation on py.delta.chat + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Fetch history to calculate VCS version number. + - name: Build Python documentation + run: scripts/build-python-docs.sh + - name: Upload to py.delta.chat + uses: up9cloud/action-rsync@v1.3 + env: + USER: delta + KEY: ${{ secrets.CODESPEAK_KEY }} + HOST: "lists.codespeak.net" + SOURCE: "dist/html/" + TARGET: "/home/delta/build/master" diff --git a/deltachat-rpc-client/examples/echobot_advanced.py b/deltachat-rpc-client/examples/echobot_advanced.py old mode 100644 new mode 100755 diff --git a/deltachat-rpc-client/examples/echobot_no_hooks.py b/deltachat-rpc-client/examples/echobot_no_hooks.py old mode 100644 new mode 100755 index 73e875b0d..429bce0b1 --- a/deltachat-rpc-client/examples/echobot_no_hooks.py +++ b/deltachat-rpc-client/examples/echobot_no_hooks.py @@ -40,13 +40,13 @@ def main(): while True: event = account.wait_for_event() - if event["type"] == EventType.INFO: + if event["kind"] == EventType.INFO: logging.info("%s", event["msg"]) - elif event["type"] == EventType.WARNING: + elif event["kind"] == EventType.WARNING: logging.warning("%s", event["msg"]) - elif event["type"] == EventType.ERROR: + elif event["kind"] == EventType.ERROR: logging.error("%s", event["msg"]) - elif event["type"] == EventType.INCOMING_MSG: + elif event["kind"] == EventType.INCOMING_MSG: logging.info("Got an incoming message") process_messages() diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/client.py b/deltachat-rpc-client/src/deltachat_rpc_client/client.py index 31b628ffa..04f792dd1 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/client.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/client.py @@ -195,7 +195,7 @@ class Client: class Bot(Client): - """Simple bot implementation that listent to events of a single account.""" + """Simple bot implementation that listens to events of a single account.""" def configure(self, email: str, password: str, **kwargs) -> None: kwargs.setdefault("bot", "1") diff --git a/python/README.rst b/python/README.rst index c79185b36..00440fb35 100644 --- a/python/README.rst +++ b/python/README.rst @@ -1,6 +1,6 @@ -========================= -DeltaChat Python bindings -========================= +============================ +CFFI Python Bindings +============================ This package provides `Python bindings`_ to the `deltachat-core library`_ which implements IMAP/SMTP/MIME/OpenPGP e-mail standards and offers @@ -8,157 +8,3 @@ a low-level Chat/Contact/Message API to user interfaces and bots. .. _`deltachat-core library`: https://github.com/deltachat/deltachat-core-rust .. _`Python bindings`: https://py.delta.chat/ - -Installing pre-built packages (Linux-only) -========================================== - -If you have a Linux system you may install the ``deltachat`` binary "wheel" packages -without any "build-from-source" steps. -Otherwise you need to `compile the Delta Chat bindings yourself`__. - -__ sourceinstall_ - -We recommend to first create a fresh Python virtual environment -and activate it in your shell:: - - python -m venv env - source env/bin/activate - -Afterwards, invoking ``python`` or ``pip install`` only -modifies files in your ``env`` directory and leaves -your system installation alone. - -For Linux we build wheels for all releases and push them to a python package -index. To install the latest release:: - - pip install deltachat - -To verify it worked:: - - python -c "import deltachat" - -Running tests -============= - -Recommended way to run tests is using `scripts/run-python-test.sh` -script provided in the core repository. - -This script compiles the library in debug mode and runs the tests using `tox`_. -By default it will run all "offline" tests and skip all functional -end-to-end tests that require accounts on real e-mail servers. - -.. _`tox`: https://tox.wiki -.. _livetests: - -Running "live" tests with temporary accounts --------------------------------------------- - -If you want to run live functional tests -you can set ``CHATMAIL_DOMAIN`` to a domain of the email server -that creates e-mail accounts like this:: - - export CHATMAIL_DOMAIN=nine.testrun.org - -With this account-creation setting, pytest runs create ephemeral e-mail accounts on the server. -These accounts have the pattern `ci-{6 characters}@{CHATMAIL_DOMAIN}`. -After setting the variable, either rerun `scripts/run-python-test.sh` -or run offline and online tests with `tox` directly:: - - tox -e py - -Each test run creates new accounts. - -Developing the bindings ------------------------ - -If you want to develop or debug the bindings, -you can create a testing development environment using `tox`:: - - export DCC_RS_DEV="$PWD" - export DCC_RS_TARGET=debug - tox -c python --devenv env -e py - . env/bin/activate - -Inside this environment the bindings are installed -in editable mode (as if installed with `python -m pip install -e`) -together with the testing dependencies like `pytest` and its plugins. - -You can then edit the source code in the development tree -and quickly run `pytest` manually without waiting for `tox` -to recreating the virtual environment each time. - -.. _sourceinstall: - -Installing bindings from source -=============================== - -Install Rust and Cargo first. -The easiest is probably to use `rustup `_. - -Bootstrap Rust and Cargo by using rustup:: - - curl https://sh.rustup.rs -sSf | sh - -Then clone the deltachat-core-rust repo:: - - git clone https://github.com/deltachat/deltachat-core-rust - cd deltachat-core-rust - -To install the Delta Chat Python bindings make sure you have Python3 installed. -E.g. on Debian-based systems `apt install python3 python3-pip -python3-venv` should give you a usable python installation. - -First, build the core library:: - - cargo build --release -p deltachat_ffi --features jsonrpc - -`jsonrpc` feature is required even if not used by the bindings -because `deltachat.h` includes JSON-RPC functions unconditionally. - -Create the virtual environment and activate it: - - python -m venv env - source env/bin/activate - -Build and install the bindings: - - export DCC_RS_DEV="$PWD" - export DCC_RS_TARGET=release - python -m pip install ./python - -`DCC_RS_DEV` environment variable specifies the location of -the core development tree. If this variable is not set, -`libdeltachat` library and `deltachat.h` header are expected -to be installed system-wide. - -When `DCC_RS_DEV` is set, `DCC_RS_TARGET` specifies -the build profile name to look up the artifacts -in the target directory. -In this case setting it can be skipped because -`DCC_RS_TARGET=release` is the default. - -Building manylinux based wheels -=============================== - -Building portable manylinux wheels which come with libdeltachat.so -can be done with Docker_ or Podman_. - -.. _Docker: https://www.docker.com/ -.. _Podman: https://podman.io/ - -If you want to build your own wheels, build container image first:: - - $ cd deltachat-core-rust # cd to deltachat-core-rust working tree - $ docker build -t deltachat/coredeps scripts/coredeps - -This will use the ``scripts/coredeps/Dockerfile`` to build -container image called ``deltachat/coredeps``. You can afterwards -find it with:: - - $ docker images - -This docker image can be used to run tests and build Python wheels for all interpreters:: - - $ docker run -e CHATMAIL_DOMAIN \ - --rm -it -v $(pwd):/mnt -w /mnt \ - deltachat/coredeps scripts/run_all.sh diff --git a/python/doc/Makefile b/python/doc/Makefile deleted file mode 100644 index 7f6b41af7..000000000 --- a/python/doc/Makefile +++ /dev/null @@ -1,197 +0,0 @@ -# Makefile for Sphinx documentation -# - -VERSION = $(shell python -c "import conf ; print(conf.version)") -DOCZIP = devpi-$(VERSION).doc.zip -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = _build -RSYNCOPTS = -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - -export HOME=/tmp/home -export TESTHOME=$(HOME) - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -# This variable is not auto generated as the order is important. -USER_MAN_CHAPTERS = commands\ - user\ - indices\ - packages\ -# userman/index.rst\ -# userman/devpi_misc.rst\ -# userman/devpi_concepts.rst\ - - -#export DEVPI_CLIENTDIR=$(CURDIR)/.tmp_devpi_user_man/client -#export DEVPI_SERVERDIR=$(CURDIR)/.tmp_devpi_user_man/server - -chapter = commands - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \ - epub latex latexpdf text man changes linkcheck doctest gettext install \ - quickstart-releaseprocess quickstart-pypimirror quickstart-server regen \ - prepare-quickstart\ - regen.server-fresh regen.server-restart regen.server-clean\ - regen.uman-all regen.uman - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - @echo - @echo "User Manual Regen Targets" - @echo " regen.uman regenerates page. of the user manual chapeter e.g. regen.uman chapter=..." - @echo " regen.uman-all regenerates the user manual" - @echo " regen.uman-clean stop temp server and clean up directory" - @echo " Chapter List: $(USER_MAN_CHAPTERS)" - -clean: - -rm -rf $(BUILDDIR)/* - -version: - @echo "version $(VERSION)" - -doczip: html - python doczip.py $(DOCZIP) _build/html - -install: html - rsync -avz $(RSYNCOPTS) _build/html/ delta@py.delta.chat:build/master - - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/devpi.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/devpi.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/devpi" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/devpi" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - - diff --git a/python/doc/_templates/globaltoc.html b/python/doc/_templates/globaltoc.html deleted file mode 100644 index 626a479b5..000000000 --- a/python/doc/_templates/globaltoc.html +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/python/doc/_templates/sidebarintro.html b/python/doc/_templates/sidebarintro.html deleted file mode 100644 index dbb2f7044..000000000 --- a/python/doc/_templates/sidebarintro.html +++ /dev/null @@ -1 +0,0 @@ -

deltachat {{release}}

diff --git a/python/doc/api.rst b/python/doc/cffi/api.rst similarity index 69% rename from python/doc/api.rst rename to python/doc/cffi/api.rst index f19306391..e3b4ca1dc 100644 --- a/python/doc/api.rst +++ b/python/doc/cffi/api.rst @@ -1,5 +1,4 @@ - -high level API reference +High Level API Reference ======================== - :class:`deltachat.Account` (your main entry point, creates the @@ -8,28 +7,14 @@ high level API reference - :class:`deltachat.Chat` - :class:`deltachat.Message` -Account -------- - .. autoclass:: deltachat.Account - :members: - - -Contact -------- + :members: .. autoclass:: deltachat.Contact - :members: - -Chat ----- + :members: .. autoclass:: deltachat.Chat - :members: - -Message -------- + :members: .. autoclass:: deltachat.Message - :members: - + :members: diff --git a/python/doc/examples.rst b/python/doc/cffi/examples.rst similarity index 82% rename from python/doc/examples.rst rename to python/doc/cffi/examples.rst index dd8f2a023..d07df0476 100644 --- a/python/doc/examples.rst +++ b/python/doc/cffi/examples.rst @@ -1,11 +1,10 @@ - -examples +Examples ======== Once you have :doc:`installed deltachat bindings ` you need email/password credentials for an IMAP/SMTP account. Delta Chat developers and the CI system use a special URL to create -temporary e-mail accounts on [testrun.org](https://testrun.org) for testing. +temporary email accounts on `testrun.org `_ for testing. Receiving a Chat message from the command line ---------------------------------------------- @@ -16,11 +15,11 @@ Here is a simple bot that: - terminates the bot if the message `/quit` is sent -.. include:: ../examples/echo_and_quit.py +.. include:: ../../examples/echo_and_quit.py :literal: With this file in your working directory you can run the bot -by specifying a database path, an e-mail address and password of +by specifying a database path, an email address and password of a SMTP-IMAP account:: $ cd examples @@ -40,11 +39,11 @@ Here is a simple bot that: - tracks member additions and removals for all chat groups -.. include:: ../examples/group_tracking.py +.. include:: ../../examples/group_tracking.py :literal: With this file in your working directory you can run the bot -by specifying a database path, an e-mail address and password of +by specifying a database path, an email address and password of a SMTP-IMAP account:: python group_tracking.py --email ADDRESS --password PASSWORD /tmp/db diff --git a/python/doc/cffi/install.rst b/python/doc/cffi/install.rst new file mode 100644 index 000000000..cdfc85081 --- /dev/null +++ b/python/doc/cffi/install.rst @@ -0,0 +1,80 @@ +Install +======= + +Installing pre-built packages (Linux-only) +------------------------------------------ + +If you have a Linux system you may install the ``deltachat`` binary "wheel" packages +without any "build-from-source" steps. +Otherwise you need to `compile the Delta Chat bindings yourself`__. + +__ sourceinstall_ + +We recommend to first create a fresh Python virtual environment +and activate it in your shell:: + + python -m venv env + source env/bin/activate + +Afterwards, invoking ``python`` or ``pip install`` only +modifies files in your ``env`` directory and leaves +your system installation alone. + +For Linux we build wheels for all releases and push them to a python package +index. To install the latest release:: + + pip install deltachat + +To verify it worked:: + + python -c "import deltachat" + +.. _sourceinstall: + +Installing bindings from source +------------------------------- + +Install Rust and Cargo first. +The easiest is probably to use `rustup `_. + +Bootstrap Rust and Cargo by using rustup:: + + curl https://sh.rustup.rs -sSf | sh + +Then clone the deltachat-core-rust repo:: + + git clone https://github.com/deltachat/deltachat-core-rust + cd deltachat-core-rust + +To install the Delta Chat Python bindings make sure you have Python3 installed. +E.g. on Debian-based systems `apt install python3 python3-pip +python3-venv` should give you a usable python installation. + +First, build the core library:: + + cargo build --release -p deltachat_ffi --features jsonrpc + +`jsonrpc` feature is required even if not used by the bindings +because `deltachat.h` includes JSON-RPC functions unconditionally. + +Create the virtual environment and activate it:: + + python -m venv env + source env/bin/activate + +Build and install the bindings:: + + export DCC_RS_DEV="$PWD" + export DCC_RS_TARGET=release + python -m pip install ./python + +`DCC_RS_DEV` environment variable specifies the location of +the core development tree. If this variable is not set, +`libdeltachat` library and `deltachat.h` header are expected +to be installed system-wide. + +When `DCC_RS_DEV` is set, `DCC_RS_TARGET` specifies +the build profile name to look up the artifacts +in the target directory. +In this case setting it can be skipped because +`DCC_RS_TARGET=release` is the default. diff --git a/python/doc/cffi/intro.rst b/python/doc/cffi/intro.rst new file mode 100644 index 000000000..1b4e0254a --- /dev/null +++ b/python/doc/cffi/intro.rst @@ -0,0 +1,11 @@ +Introduction +============ + +CFFI bindings are available via the `deltachat `_ Python package. +The package contains both the Python bindings and the Delta Chat core. +It is provided only for Linux. + +The ``deltachat`` Python package provides two layers of bindings for the +core Rust-library of the https://delta.chat messaging ecosystem: +low-level CFFI bindings to the C interface of the Delta Chat core +and high-level Python bindings built on top of CFFI bindings. diff --git a/python/doc/lapi.rst b/python/doc/cffi/lapi.rst similarity index 53% rename from python/doc/lapi.rst rename to python/doc/cffi/lapi.rst index 67bb63bc4..165f531f4 100644 --- a/python/doc/lapi.rst +++ b/python/doc/cffi/lapi.rst @@ -1,8 +1,7 @@ +Low Level API Reference +======================= -low level API reference -=================================== - -for full doxygen-generated C-docs, defines and functions please checkout +For full doxygen-generated C-docs, defines and functions please checkout https://c.delta.chat diff --git a/python/doc/cffi/manylinux.rst b/python/doc/cffi/manylinux.rst new file mode 100644 index 000000000..a149012f8 --- /dev/null +++ b/python/doc/cffi/manylinux.rst @@ -0,0 +1,25 @@ +Building Manylinux-Based Wheels +=============================== + +Building portable manylinux wheels which come with libdeltachat.so +can be done with Docker_ or Podman_. + +.. _Docker: https://www.docker.com/ +.. _Podman: https://podman.io/ + +If you want to build your own wheels, build container image first:: + + $ cd deltachat-core-rust # cd to deltachat-core-rust working tree + $ docker build -t deltachat/coredeps scripts/coredeps + +This will use the ``scripts/coredeps/Dockerfile`` to build +container image called ``deltachat/coredeps``. You can afterwards +find it with:: + + $ docker images + +This docker image can be used to run tests and build Python wheels for all interpreters:: + + $ docker run -e CHATMAIL_DOMAIN \ + --rm -it -v $(pwd):/mnt -w /mnt \ + deltachat/coredeps scripts/run_all.sh diff --git a/python/doc/plugins.rst b/python/doc/cffi/plugins.rst similarity index 100% rename from python/doc/plugins.rst rename to python/doc/cffi/plugins.rst diff --git a/python/doc/cffi/tests.rst b/python/doc/cffi/tests.rst new file mode 100644 index 000000000..08a59cd7e --- /dev/null +++ b/python/doc/cffi/tests.rst @@ -0,0 +1,49 @@ +Running Tests +============= + +Recommended way to run tests is using `scripts/run-python-test.sh` +script provided in the core repository. + +This script compiles the library in debug mode and runs the tests using `tox`_. +By default it will run all "offline" tests and skip all functional +end-to-end tests that require accounts on real email servers. + +.. _`tox`: https://tox.wiki +.. _livetests: + +Running "Live" Tests With Temporary Accounts +-------------------------------------------- + +If you want to run live functional tests +you can set ``CHATMAIL_DOMAIN`` to a domain of the email server +that creates email accounts like this:: + + export CHATMAIL_DOMAIN=nine.testrun.org + +With this account-creation setting, pytest runs create ephemeral email accounts on the server. +These accounts have the pattern `ci-{6 characters}@{CHATMAIL_DOMAIN}`. +After setting the variable, either rerun `scripts/run-python-test.sh` +or run offline and online tests with `tox` directly:: + + tox -e py + +Each test run creates new accounts. + +Developing the Bindings +----------------------- + +If you want to develop or debug the bindings, +you can create a testing development environment using `tox`:: + + export DCC_RS_DEV="$PWD" + export DCC_RS_TARGET=debug + tox -c python --devenv env -e py + . env/bin/activate + +Inside this environment the bindings are installed +in editable mode (as if installed with `python -m pip install -e`) +together with the testing dependencies like `pytest` and its plugins. + +You can then edit the source code in the development tree +and quickly run `pytest` manually without waiting for `tox` +to recreating the virtual environment each time. diff --git a/python/doc/changelog.rst b/python/doc/changelog.rst deleted file mode 100644 index db2b47a69..000000000 --- a/python/doc/changelog.rst +++ /dev/null @@ -1,4 +0,0 @@ -Changelog for deltachat-core's Python bindings -============================================== - -.. include:: ../CHANGELOG diff --git a/python/doc/conf.py b/python/doc/conf.py index 4647c6ae2..f56cf58ea 100644 --- a/python/doc/conf.py +++ b/python/doc/conf.py @@ -1,138 +1,94 @@ -# -*- coding: utf-8 -*- -# -# devpi documentation build configuration file, created by -# sphinx-quickstart on Mon Jun 3 16:11:22 2013. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os +from pathlib import Path # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. from deltachat import __version__ as release + version = ".".join(release.split(".")[:2]) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - #'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.viewcode', - 'breathe', - #'sphinx.ext.githubpages', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.viewcode", + "breathe", + "sphinx_rtd_theme", ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'deltachat' -copyright = u'2020, holger krekel and contributors' +project = "Delta Chat" +copyright = "2023, Delta Chat contributors" +author = "Delta Chat contributors" -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['sketch', '_build', "attic"] +exclude_patterns = ["sketch", "_build", "attic", "Thumbs.db", ".DS_Store"] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- breathe options ------ -breathe_projects = { - "deltachat": "../../docs/xml/" -} +breathe_projects = {"deltachat": Path("../../docs/xml/")} breathe_default_project = "deltachat" # -- Options for HTML output --------------------------------------------------- -sys.path.append(os.path.abspath('_themes')) -html_theme_path = ['_themes'] - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# html_theme = 'flask' -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - 'logo': '_static/delta-chat.svg', - 'font_size': "1.1em", - 'caption_font_size': "0.9em", - 'code_font_size': "1.1em", - - -} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = ["_themes"] +html_theme = "sphinx_rtd_theme" # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. @@ -141,51 +97,34 @@ html_logo = "_static/delta-chat.svg" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# -html_sidebars = { - 'index': [ - 'sidebarintro.html', - 'globaltoc.html', - 'searchbox.html' - ], - '**': [ - 'sidebarintro.html', - 'globaltoc.html', - 'relations.html', - 'searchbox.html' - ] -} - +# html_use_smartypants = True # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = False @@ -194,71 +133,65 @@ html_show_sourcelink = False html_show_sphinx = False # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -html_use_opensearch = 'https://doc.devpi.net' +html_use_opensearch = "https://doc.devpi.net" # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'deltachat-python' +htmlhelp_basename = "deltachat-python" # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -'pointsize': '12pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '12pt', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'devpi.tex', u'deltachat documentation', - u'holger krekel', 'manual'), + ("index", "devpi.tex", "deltachat documentation", "holger krekel", "manual"), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'deltachat', u'deltachat documentation', - [u'holger krekel'], 1) -] +man_pages = [("index", "deltachat", "deltachat documentation", ["holger krekel"], 1)] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ @@ -267,30 +200,38 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'devpi', u'devpi Documentation', - u'holger krekel', 'devpi', 'One line description of project.', - 'Miscellaneous'), + ( + "index", + "devpi", + "devpi Documentation", + "holger krekel", + "devpi", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} +intersphinx_mapping = {"http://docs.python.org/": None} # autodoc options autodoc_member_order = "bysource" + + # always document __init__ functions def skip(app, what, name, obj, skip, options): return skip + def setup(app): app.connect("autodoc-skip-member", skip) - diff --git a/python/doc/index.rst b/python/doc/index.rst index b5643eee4..1a95370d3 100644 --- a/python/doc/index.rst +++ b/python/doc/index.rst @@ -1,41 +1,44 @@ -deltachat python bindings -========================= +Delta Chat Python bindings, new and old +======= -The ``deltachat`` Python package provides two layers of bindings for the -core Rust-library of the https://delta.chat messaging ecosystem: - -- :doc:`api` is a high level interface to deltachat-core. - -- :doc:`plugins` is a brief introduction into implementing plugin hooks. - -- :doc:`lapi` is a lowlevel CFFI-binding to the `Rust Core - `_. - - - -getting started ---------------- +`Delta Chat `_ provides two kinds of Python bindings +to the `Rust Core `_: +JSON-RPC bindings and CFFI bindings. +When starting a new project it is recommended to use JSON-RPC bindings, +which are used in the Delta Chat Desktop app through generated Typescript-bindings. +The Python JSON-RPC bindings are maintained by Delta Chat core developers. +Most existing bot projects and many tests in Delta Chat's own core library +still use the CFFI-bindings, and it is going to be maintained certainly also in 2024. +New APIs might however only appear in the JSON-RPC bindings, +as the CFFI bindings are increasingly in maintenance-only mode. .. toctree:: :maxdepth: 2 + :caption: JSON-RPC Bindings - install - examples + jsonrpc/intro + jsonrpc/install + jsonrpc/examples + jsonrpc/reference + jsonrpc/develop .. toctree:: - :hidden: + :maxdepth: 2 + :caption: CFFI Bindings - links - changelog - api - lapi - plugins - -.. - Indices and tables - ================== - - * :ref:`genindex` - * :ref:`modindex` - * :ref:`search` + cffi/intro + cffi/install + cffi/examples + cffi/manylinux + cffi/tests + cffi/api + cffi/lapi + cffi/plugins +.. _`deltachat`: https://delta.chat +.. _`deltachat-core repo`: https://github.com/deltachat +.. _pip: http://pypi.org/project/pip/ +.. _virtualenv: http://pypi.org/project/virtualenv/ +.. _merlinux: http://merlinux.eu +.. _pypi: http://pypi.org/ +.. _`issue-tracker`: https://github.com/deltachat/deltachat-core-rust diff --git a/python/doc/install.rst b/python/doc/install.rst deleted file mode 100644 index 04abf49af..000000000 --- a/python/doc/install.rst +++ /dev/null @@ -1,2 +0,0 @@ - -.. include:: ../README.rst diff --git a/python/doc/jsonrpc/develop.rst b/python/doc/jsonrpc/develop.rst new file mode 100644 index 000000000..0ac25e606 --- /dev/null +++ b/python/doc/jsonrpc/develop.rst @@ -0,0 +1,68 @@ +=========== +Development +=========== + +To develop JSON-RPC bindings, +clone the `deltachat-core-rust `_ repository:: + + git clone https://github.com/deltachat/deltachat-core-rust.git + +Testing +======= + +To run online tests, set ``CHATMAIL_DOMAIN`` +to a domain of the email server +that can be used to create testing accounts:: + + export CHATMAIL_DOMAIN=nine.testrun.org + +Then run ``scripts/run-rpc-test.sh`` +to build debug version of ``deltachat-rpc-server`` +and run ``deltachat-rpc-client`` tests +in a separate virtual environment managed by `tox `_. + +Development Environment +======================= + +Creating a new virtual environment +to run the tests each time +as ``scripts/run-rpc-test.sh`` does is slow +if you are changing the tests or the code +and want to rerun the tests each time. + +If you are developing the tests, +it is better to create a persistent virtual environment. +You can do this by running ``scripts/make-rpc-testenv.sh``. +This creates a virtual environment ``venv`` which you can then enter with:: + + . venv/bin/activate + +Then you can run the tests with + +:: + + pytest deltachat-rpc-client/tests/ + +Refer to `pytest documentation ` for details. + +If make the changes to Delta Chat core +or Python bindings, you can rebuild the environment by rerunning +``scripts/make-rpc-testenv.sh``. +It is ok to rebuild the activated environment this way, +you do not need to deactivate or reactivate the environment each time. + +Using REPL +========== + +Once you have a development environment, +you can quickly test things in REPL:: + + $ python + >>> from deltachat_rpc_client import * + >>> rpc = Rpc() + >>> rpc.start() + >>> dc = DeltaChat(rpc) + >>> system_info = dc.get_system_info() + >>> system_info["level"] + 'awesome' + >>> rpc.close() diff --git a/python/doc/jsonrpc/examples.rst b/python/doc/jsonrpc/examples.rst new file mode 100644 index 000000000..92c7cc43f --- /dev/null +++ b/python/doc/jsonrpc/examples.rst @@ -0,0 +1,19 @@ +Examples +======== + +Echo bot +-------- +.. include:: ../../../deltachat-rpc-client/examples/echobot_no_hooks.py + :literal: + +Echo bot with hooks +------------------- +.. include:: ../../../deltachat-rpc-client/examples/echobot.py + :literal: + +Advanced echo bot +----------------- + +.. include:: ../../../deltachat-rpc-client/examples/echobot_advanced.py + :literal: + diff --git a/python/doc/jsonrpc/install.rst b/python/doc/jsonrpc/install.rst new file mode 100644 index 000000000..931000919 --- /dev/null +++ b/python/doc/jsonrpc/install.rst @@ -0,0 +1,36 @@ +Install +======= + +To use JSON-RPC bindings for Delta Chat core you will need +a ``deltachat-rpc-server`` binary which provides Delta Chat core API over JSON-RPC +and a ``deltachat-rpc-client`` Python package which is a JSON-RPC client that starts ``deltachat-rpc-server`` process and uses JSON-RPC API. + +`Create a virtual environment `__ if you +don’t have one already and activate it:: + + $ python -m venv venv + $ . venv/bin/activate + +Install ``deltachat-rpc-server`` +-------------------------------- + +To get ``deltachat-rpc-server`` binary you have three options: + +1. Install ``deltachat-rpc-server`` from PyPI using ``pip install deltachat-rpc-server``. +2. Build and install ``deltachat-rpc-server`` from source with ``cargo install --git https://github.com/deltachat/deltachat-core-rust/ deltachat-rpc-server``. +3. Download prebuilt release from https://github.com/deltachat/deltachat-core-rust/releases and install it into ``PATH``. + +Check that ``deltachat-rpc-server`` is installed and can run:: + + $ deltachat-rpc-server --version + 1.131.4 + +Then install ``deltachat-rpc-client`` with ``pip install deltachat-rpc-client``. + +Install ``deltachat-rpc-client`` +-------------------------------- + +To get ``deltachat-rpc-client`` Python library you can: + +1. Install ``deltachat-rpc-client`` from PyPI using ``pip install deltachat-rpc-client``. +2. Install ``deltachat-rpc-client`` from source with ``pip install git+https://github.com/deltachat/deltachat-core-rust.git@main#subdirectory=deltachat-rpc-client``. diff --git a/python/doc/jsonrpc/intro.rst b/python/doc/jsonrpc/intro.rst new file mode 100644 index 000000000..11f0988e1 --- /dev/null +++ b/python/doc/jsonrpc/intro.rst @@ -0,0 +1,8 @@ +Introduction +============ + +JSON-RPC bindings are available via the `deltachat-rpc-client `_ Python package. +This package provides only the Python bindings and requires ``deltachat-rpc-server`` binary to be installed. +`deltachat-rpc-server `_ package provides ``deltachat-rpc-server`` binary for Linux, Windows, macOS and Android. + +RPC client connects to standalone Delta Chat RPC server ``deltachat-rpc-server`` and provides Python interface to it. diff --git a/python/doc/jsonrpc/reference.rst b/python/doc/jsonrpc/reference.rst new file mode 100644 index 000000000..11116b5ca --- /dev/null +++ b/python/doc/jsonrpc/reference.rst @@ -0,0 +1,5 @@ +API Reference +============= + +.. automodule:: deltachat_rpc_client + :members: diff --git a/python/doc/links.rst b/python/doc/links.rst deleted file mode 100644 index 432775e1e..000000000 --- a/python/doc/links.rst +++ /dev/null @@ -1,11 +0,0 @@ - -links -================================ - -.. _`deltachat`: https://delta.chat -.. _`deltachat-core repo`: https://github.com/deltachat -.. _pip: http://pypi.org/project/pip/ -.. _virtualenv: http://pypi.org/project/virtualenv/ -.. _merlinux: http://merlinux.eu -.. _pypi: http://pypi.org/ -.. _`issue-tracker`: https://github.com/deltachat/deltachat-core diff --git a/python/doc/make.bat b/python/doc/make.bat deleted file mode 100644 index 1a48d1e63..000000000 --- a/python/doc/make.bat +++ /dev/null @@ -1,190 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% - set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. singlehtml to make a single large HTML file - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. devhelp to make HTML files and a Devhelp project - echo. epub to make an epub - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. text to make text files - echo. man to make manual pages - echo. texinfo to make Texinfo files - echo. gettext to make PO message catalogs - echo. changes to make an overview over all changed/added/deprecated items - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i - del /q /s %BUILDDIR%\* - goto end -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. - goto end -) - -if "%1" == "singlehtml" ( - %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %BUILDDIR%/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\devpi.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\devpi.ghc - goto end -) - -if "%1" == "devhelp" ( - %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. - goto end -) - -if "%1" == "epub" ( - %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The epub file is in %BUILDDIR%/epub. - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex - if errorlevel 1 exit /b 1 - echo. - echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. - goto end -) - -if "%1" == "text" ( - %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The text files are in %BUILDDIR%/text. - goto end -) - -if "%1" == "man" ( - %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The manual pages are in %BUILDDIR%/man. - goto end -) - -if "%1" == "texinfo" ( - %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. - goto end -) - -if "%1" == "gettext" ( - %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale - if errorlevel 1 exit /b 1 - echo. - echo.Build finished. The message catalogs are in %BUILDDIR%/locale. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes - if errorlevel 1 exit /b 1 - echo. - echo.The overview file is in %BUILDDIR%/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck - if errorlevel 1 exit /b 1 - echo. - echo.Link check complete; look for any errors in the above output ^ -or in %BUILDDIR%/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest - if errorlevel 1 exit /b 1 - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in %BUILDDIR%/doctest/output.txt. - goto end -) - -:end diff --git a/python/tox.ini b/python/tox.ini index 5f9cc5094..2bcba7e95 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -62,9 +62,9 @@ commands = [testenv:doc] changedir=doc deps = -# Pinned due to incompatibility of breathe with sphinx 7.2: - sphinx<=7.1.2 + sphinx breathe + sphinx_rtd_theme commands = sphinx-build -Q -w toxdoc-warnings.log -b html . _build/html diff --git a/scripts/README.md b/scripts/README.md index cf11364bb..160e633cf 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -39,6 +39,8 @@ and an own build machine. - `android-rpc-server.sh` compiles binaries of `deltachat-rpc-server` using Android NDK. +- `build-python-docs.sh` builds Python documentation into `dist/html/`. + ## Triggering runs on the build machine locally (fast!) There is experimental support for triggering a remote Python or Rust test run diff --git a/scripts/build-python-docs.sh b/scripts/build-python-docs.sh new file mode 100755 index 000000000..9e994f39c --- /dev/null +++ b/scripts/build-python-docs.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +export DCC_RS_TARGET=debug +export DCC_RS_DEV="$PWD" +cargo build -p deltachat_ffi --features jsonrpc + +python3 -m venv venv +venv/bin/pip install ./python +venv/bin/pip install ./deltachat-rpc-client +venv/bin/pip install sphinx breathe sphinx_rtd_theme +venv/bin/pip install ./deltachat-rpc-client +venv/bin/sphinx-build -b html -a python/doc/ dist/html diff --git a/scripts/concourse/docs_wheels.yml b/scripts/concourse/docs_wheels.yml index 790a2246f..66f835d29 100644 --- a/scripts/concourse/docs_wheels.yml +++ b/scripts/concourse/docs_wheels.yml @@ -102,8 +102,6 @@ jobs: - name: deltachat-core-rust-release path: . outputs: - - name: py-docs - path: ./python/doc/_build/ # Binary wheels - name: py-wheels path: ./python/.docker-tox/wheelhouse/ @@ -115,28 +113,6 @@ jobs: - | scripts/run_all.sh - # Upload python docs to py.delta.chat - - task: upload-py-docs - config: - inputs: - - name: py-docs - image_resource: - type: registry-image - source: - repository: alpine - platform: linux - run: - path: sh - args: - - -ec - - | - apk add --no-cache rsync openssh-client - mkdir -p ~/.ssh - chmod 700 ~/.ssh - echo "(("c.delta.chat".private_key))" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 - rsync -e "ssh -o StrictHostKeyChecking=no" -avz --delete py-docs/html/ delta@py.delta.chat:build/master - # Upload x86_64 wheels and source packages - task: upload-wheels config: diff --git a/scripts/run_all.sh b/scripts/run_all.sh index e465bddc6..9d491a8a2 100755 --- a/scripts/run_all.sh +++ b/scripts/run_all.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Build the Delta Chat Core Rust library, Python wheels and docs +# Build the Delta Chat Core Rust library and Python wheels set -e -x @@ -34,9 +34,3 @@ unset CHATMAIL_DOMAIN tox --workdir "$TOXWORKDIR" -e py37,py38,py39,py310,py311,py312,pypy37,pypy38,pypy39,pypy310 --skip-missing-interpreters true auditwheel repair "$TOXWORKDIR"/wheelhouse/deltachat* -w "$TOXWORKDIR/wheelhouse" - - -echo ----------------------- -echo generating python docs -echo ----------------------- -tox --workdir "$TOXWORKDIR" -e doc