Skip to content

Commit

Permalink
Merge pull request #1079 from Bastian-Krause/bst/separate-crossbar-venv
Browse files Browse the repository at this point in the history
Install Crossbar Into Separate Virtualenv
  • Loading branch information
Emantor committed Apr 26, 2023
2 parents 52dd973 + 522b60a commit 9cba6af
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .crossbar/config-anonymous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ workers:
role: public
- id: coordinator
type: guest
executable: python3
executable: /path/to/labgrid-venv/bin/python3
arguments:
- -m
- labgrid.remote.coordinator
Expand Down
68 changes: 0 additions & 68 deletions .crossbar/config.yaml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/reusable-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@ jobs:
ssh -o StrictHostKeyChecking=no localhost echo OK
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip virtualenv
- name: Install labgrid
run: |
pip install -e ".[dev]"
- name: Install crossbar in virtualenv
run: |
virtualenv -p python3 crossbar-venv
crossbar-venv/bin/pip install -r crossbar-requirements.txt
- name: Lint with pylint
run: |
pylint --list-msgs-enabled
pylint labgrid
- name: Test with pytest
run: |
TERM=xterm pytest --cov-config .coveragerc --cov=labgrid --local-sshmanager --ssh-username runner -k "not test_docker_with_daemon"
TERM=xterm pytest --cov-config .coveragerc --cov=labgrid --local-sshmanager --ssh-username runner --crossbar-venv crossbar-venv -k "not test_docker_with_daemon"
- name: Build documentation
run: |
make -C doc clean
Expand Down
22 changes: 22 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
Release 23.1 (unreleased)
------------------------------------

New Features in 23.1
~~~~~~~~~~~~~~~~~~~~


Bug fixes in 23.1
~~~~~~~~~~~~~~~~~


Breaking changes in 23.1
~~~~~~~~~~~~~~~~~~~~~~~~~
- The Debian package (``debian/``) no longer contains crossbar. Use the
`coordinator container <https://hub.docker.com/r/labgrid/coordinator>`_ or
install it into a separate local venv as desribed in the
`documentation <https://labgrid.readthedocs.io/en/latest/getting_started.html#coordinator>`_.

Known issues in 23.1
~~~~~~~~~~~~~~~~~~~~


Release 23.0 (Released Apr 24, 2023)
------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions crossbar-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
crossbar==21.3.1
autobahn<=22.4.1
6 changes: 5 additions & 1 deletion doc/RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Test the upload by using pypi dev as a download source

::

virtualenv -p python3 labgrid-crossbar-release-<your-version-number>
labgrid-crossbar-release-<your-version-number>/bin/pip install --upgrade pip
labgrid-crossbar-release-<your-version-number>/bin/pip install -r crossbar-requirements.txt

virtualenv -p python3 labgrid-release-<your-version-number>
source labgrid-release-<your-version-number>/bin/activate
pip install --upgrade pip setuptools wheel
Expand All @@ -91,7 +95,7 @@ And optionally run the tests:
::

pip install ".[dev]"
pytest tests
pytest tests --crossbar-venv labgrid-crossbar-release-<your-version-number>

9. Upload to pypi
=================
Expand Down
57 changes: 44 additions & 13 deletions doc/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,57 @@ Coordinator
~~~~~~~~~~~

To start the coordinator, we will download the labgrid repository, create an
extra virtualenv and install the dependencies via the crossbar `extra`.
extra virtualenv and install the dependencies:

.. code-block:: bash
$ sudo apt install libsnappy-dev
$ git clone https://github.com/labgrid-project/labgrid
$ cd labgrid
$ virtualenv -p python3 crossbar-venv
$ source crossbar-venv/bin/activate
crossbar-venv $ git clone https://github.com/labgrid-project/labgrid
crossbar-venv $ cd labgrid && pip install ".[crossbar]"
$ crossbar-venv/bin/pip install --upgrade pip
$ crossbar-venv/bin/pip install -r crossbar-requirements.txt
$ virtualenv -p python3 labgrid-venv
$ source labgrid-venv/bin/activate
labgrid-venv $ pip install --upgrade pip
labgrid-venv $ pip install .
All necessary dependencies should be installed now, we can start the coordinator
by running ``crossbar start --config config-anonymous.yaml`` inside the repository.
All necessary dependencies should be installed now.

.. note:: This is possible because the labgrid repository contains the crossbar
configuration for the coordinator in the ``.crossbar`` folder.
crossbar is a network messaging framework for building distributed
Copy and customize the crossbar config file ``.crossbar/config-anonymous.yaml``
for your use case:

.. code-block:: bash
labgrid-venv $ cp .crossbar/config-anonymous.yaml .crossbar/my-config.yaml
.. note:: crossbar is a network messaging framework for building distributed
applications, which labgrid plugs into.

.. note:: For long running deployments, you should copy and customize the
``.crossbar/config-anonymous.yaml`` file for your use case. This includes
setting a different ``workdir`` and may include changing the running
port.
The path to the Python interpreter in the labgrid-venv needs to be configured
in crossbar's config, either manually or with the labgrid-venv being active
via:

.. code-block:: bash
labgrid-venv $ sed -i "s#^ executable: .*\$# executable: ${VIRTUAL_ENV}/bin/python3#" .crossbar/my-config.yaml
.. note:: For long running deployments a different ``workdir`` and port may be
used.
The crossbar config should reside in a ``.crossbar`` directory in the
``workdir`` in this case.
For an example systemd service file, see
:ref:`remote-getting-started-systemd-files`.

Now we can finally start the coordinator inside the repository:

.. code-block:: bash
$ crossbar-venv/bin/crossbar start --config my-config.yaml
.. note:: If --config is specified as a relative path, the config is expected
in a .crossbar subdirectory (as is the case in the labgrid
repository).

Exporter
~~~~~~~~
Expand Down Expand Up @@ -315,6 +344,8 @@ See :ref:`remote-usage` for some more advanced features.
For a complete reference have a look at the :doc:`labgrid-client(1) <man/client>`
man page.

.. _remote-getting-started-systemd-files:

Systemd files
~~~~~~~~~~~~~

Expand Down
8 changes: 6 additions & 2 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ ENV CROSSBAR_DIR=/opt/crossbar

RUN set -e ;\
cd /opt/labgrid ;\
SETUPTOOLS_SCM_PRETEND_VERSION="$VERSION" pip3 install --no-cache-dir ".[crossbar]"
pip3 install virtualenv ;\
SETUPTOOLS_SCM_PRETEND_VERSION="$VERSION" pip3 install --no-cache-dir . ;\
virtualenv -p python3 crossbar-venv ;\
crossbar-venv/bin/pip3 install -r crossbar-requirements.txt ;\
sed -i "s#^ executable: .*\$# executable: python3#" .crossbar/config-anonymous.yaml

VOLUME /opt/crossbar

EXPOSE 20408

CMD ["crossbar", "start", "--config", "/opt/labgrid/.crossbar/config.yaml"]
CMD ["/opt/labgrid/crossbar-venv/bin/crossbar", "start", "--config", "/opt/labgrid/.crossbar/config-anonymous.yaml"]

#
# Exporter
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/staging/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
tty: true
network_mode: "host"
command: bash -c "cp /home/root/crossbar/places_example.yaml /opt/crossbar/places.yaml &&
crossbar start --config /opt/labgrid/.crossbar/config.yaml"
/opt/labgrid/crossbar-venv/bin/crossbar start --config /opt/labgrid/.crossbar/config-anonymous.yaml"
client:
image: "labgrid-client"
volumes:
Expand Down
7 changes: 4 additions & 3 deletions examples/usbpower/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ on port 3.
Software Setup
--------------

The following expects that labgrid with crossbar support is installed in the
active virtualenv.
The following expects that labgrid is installed in the
active virtualenv and crossbar is installed into a separate virtualenv.
The ``uhubctl`` and ``usbsdmux`` tools need to be installed on the system.

Library Example
Expand Down Expand Up @@ -116,7 +116,7 @@ Remote Setup
------------

To access resources remotely, you first need to start the coordinator::
$ crossbar start --logformat none --config config-anonymous.yaml
$ crossbar-venv/bin/crossbar start --logformat none --config config-anonymous.yaml
[...]
Coordinator ready.

Expand Down Expand Up @@ -232,4 +232,5 @@ Remote pytest Example
---------------------

Run ``pytest --lg-env remote.yaml -v``.

You should get output very similar to the local pytest example above.
15 changes: 3 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ dynamic = ["version"] # via setuptools_scm
"Bug Tracker" = "https://github.com/labgrid-project/labgrid/issues"

[project.optional-dependencies]
crossbar = [
"crossbar==21.3.1",
"werkzeug>=0.14.1,<2.1",
]
doc = [
"docutils==0.17.1",
"Sphinx==4.2.0",
Expand All @@ -75,10 +71,6 @@ snmp = [
vxi11 = ["python-vxi11==0.9"]
xena = ["xenavalkyrie==3.0.1"]
deb = [
# labgrid[crossbar]
"crossbar==21.3.1",
"werkzeug>=0.14.1,<2.1",

# labgrid[modbus]
"pyModbusTCP==0.1.10",

Expand All @@ -91,10 +83,6 @@ deb = [
]
dev = [
# references to other optional dependency groups
# labgrid[crossbar]
"crossbar==21.3.1",
"werkzeug>=0.14.1,<2.1",

# labgrid[doc]
"docutils==0.17.1",
"Sphinx==4.2.0",
Expand Down Expand Up @@ -177,6 +165,9 @@ testpaths = [
]
addopts = "-p no:labgrid"

[tool.pylint.MASTER]
ignore-paths = ["labgrid/remote/authenticator.py"]

[tool.pylint.imports]
ignored-modules = ["gi"]

Expand Down

0 comments on commit 9cba6af

Please sign in to comment.