Add Python3 in Snap build + doc fixes
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sat, 07 Oct 2023 17:37:00 +0200
changeset 123 032aaa29f498
parent 122 ef1c44f741e3
child 124 9304b56075c2
Add Python3 in Snap build + doc fixes
.github/workflows/prep_sources.yml
Makefile
README.md
distfiles/v1.3.7.tar.gz.md5
revisions.txt
snap.mk
snap/snapcraft.yaml
--- a/.github/workflows/prep_sources.yml	Thu Oct 05 13:16:35 2023 +0200
+++ b/.github/workflows/prep_sources.yml	Sat Oct 07 17:37:00 2023 +0200
@@ -9,10 +9,11 @@
     runs-on: ubuntu-latest
 
     env:
-        beremiz_revisionid: 0189295a9c03fb29797ee174915057061e737603
+        beremiz_revisionid: 5826f71a5f7fe98758525b22fdcff19b3a811f86
         matiec_revisionid: e5be6a1f036d21cd7b5ee75ef352783a7cfcc1a7
         canfestival_revisionid: 12a05e422666c738d1312259703f80150c747cb5
         Modbus_revisionid: 4d7d67a8e911d744165709c20a254b5cb924ec71
+        # v1.3.7
         open62541_revisionid: b8ac9e77f703e6ba5c012b886a8821037503daa6
 
 
--- a/Makefile	Thu Oct 05 13:16:35 2023 +0200
+++ b/Makefile	Sat Oct 07 17:37:00 2023 +0200
@@ -84,9 +84,9 @@
 
 sources/open62541_src: | sources
 	rm -rf sources/open62541
-	$(call get_src_http,https://github.com/open62541/open62541/archive/refs/tags,v1.3.2.tar.gz)\
+	$(call get_src_http,https://github.com/open62541/open62541/archive/refs/tags,v1.3.7.tar.gz)\
 	tar -xzf $$dld
-	mv open62541-1.3.2 sources/open62541
+	mv open62541-1.3.7 sources/open62541
 	
 
 define show_revision_details
--- a/README.md	Thu Oct 05 13:16:35 2023 +0200
+++ b/README.md	Sat Oct 07 17:37:00 2023 +0200
@@ -47,9 +47,10 @@
 ~/src
      /beremiz
      /beremiz_public_dist
-     /canfestival
      /matiec
-     /Modbus
+     /canfestival [optional]
+     /Modbus      [optional]
+     /open62541   [optional]
 ```
 
 Repositories can be cloned from https://hg.beremiz.org .
@@ -67,16 +68,6 @@
 
     ./rebuild_docker.sh [build directory]
 
-Example:
-
-```
-#!sh
-mkdir ~/src ~/build
-cd ~/src
-hg clone https://hg.beremiz.org/beremiz_public_dist
-cd beremiz_public_dist
-./rebuild_docker.sh
-```
 
 Source and Build Volumes :
  
@@ -126,16 +117,15 @@
 Reasons for this are :
  - no parameters or conditional variables exist to tell snapcraft.yaml where to get the source from
  - building from local source should be always possible
- - revisions.txt must be updated in any case so that it is always possible to know what version wqas used to build resulting package
+ - revisions.txt must be updated in any case so that it is always possible to know what version was used to build resulting package
  - when Snap is built from GitHub actions, Makefile isn't used at all, and GitHub action workflow organize sources and revisions.txt on its own.
 
 In the end, instead of just calling `snapcraft` to get a snap package, it is more complicated:
 
 ```
-#!sh
-mkdir ~/src ~/build
-cd ~/src
-hg clone https://hg.beremiz.org/beremiz_public_dist
+# assuming source repositories are cloned in ~/src 
+# and build happens in ~/build
+
 cd ~/build
 make -f ~/src/beremiz_public_dist/Makefile DIST=snap
 
@@ -144,6 +134,6 @@
 It can be installed this way:
 
 ```
-sudo snap install sources/beremiz_1.3-beta2_amd64.snap --dangerous --devmode
+sudo snap install sources/beremiz_1.4-beta2_amd64.snap --dangerous --devmode
 ```
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/distfiles/v1.3.7.tar.gz.md5	Sat Oct 07 17:37:00 2023 +0200
@@ -0,0 +1,1 @@
+5d79dfd16940aab816816beb9aaac262  v1.3.7.tar.gz
--- a/revisions.txt	Thu Oct 05 13:16:35 2023 +0200
+++ b/revisions.txt	Sat Oct 07 17:37:00 2023 +0200
@@ -1,4 +1,5 @@
 beremiz local
 canfestival local
 Modbus local
+open62541 local
 matiec local
--- a/snap.mk	Thu Oct 05 13:16:35 2023 +0200
+++ b/snap.mk	Sat Oct 07 17:37:00 2023 +0200
@@ -2,6 +2,8 @@
 
 main_target: Snap
 
+DIST_FROM_SOURCE_PROJECTS=canfestival Modbus open62541
+
 tar_opts=--absolute-names --exclude=.hg --exclude=.git --exclude=.*.pyc --exclude=.*.swp
 
 Snap: snap_built
--- a/snap/snapcraft.yaml	Thu Oct 05 13:16:35 2023 +0200
+++ b/snap/snapcraft.yaml	Sat Oct 07 17:37:00 2023 +0200
@@ -34,69 +34,23 @@
 
 grade: devel
 confinement: strict
-base: core20
+base: core22
 architectures: [amd64, arm64]
 
 parts:
 
-  python-deps:
-    # This part provides all python2 dependencies, including interpreter
-    # More particularily, it builds latest PIP supporting python2 from git
-    # and uses it to collect and buid other Beremiz dependencies.
-    #
-    # rational:
-    #  - python plugin doesn't support python2 anymore on core20+
-    #  - attempts to get python2+pip+virtualenv in a core20 based snap failed
-
-    plugin: nil
-    source: https://github.com/pypa/pip/archive/refs/tags/20.3.4.tar.gz
-    build-packages:
-      - libssl-dev
-      - libgtk-3-dev
-      - libgl1-mesa-dev
-      - libglu1-mesa-dev
-      - python2-dev
-
-    stage-packages:
-      - python2
-      - python-setuptools
-      - python-lxml
-
-    override-build: |
-      # For some reasons site-packages needs to be created and 
-      # added to PYTHONPATH during PIP (own) build.
-      # Apparently not anymore when snap is executed.
-      mkdir $SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages
-      PYTHONPATH=$SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages \
-        $SNAPCRAFT_PART_INSTALL/usr/bin/python2 $SNAPCRAFT_PART_SRC/setup.py \
-            install --prefix $SNAPCRAFT_PART_INSTALL/usr
-      PYTHONPATH=$SNAPCRAFT_PART_INSTALL/usr/lib/python2.7/site-packages \
-        $SNAPCRAFT_PART_INSTALL/usr/bin/pip install \
-          future              \
-          matplotlib          \
-          msgpack_python      \
-          u-msgpack-python    \
-          zeroconf2           \
-          enum34              \
-          pyro                \
-          sslpsk              \
-          posix_spawn         \
-          twisted             \
-          nevow               \
-          autobahn            \
-          click               \
-          opcua               \
-          pycountry           \
-          fonttools           \
-          Brotli              \
-          wxPython==4.1.1
-
   beremiz:
-    # Beremiz python source + GCC toolchain
+    # Beremiz python source and dependencies, inc. native GCC
     # source tree is expected to be just aside snap directory
-    plugin: nil
+    plugin: python
     source: beremiz
     source-type: local
+    python-requirements:
+      - requirements.txt
+    # native GCC toolchain
+    # note: GCC toolchain cannot be move to separate part
+    # otherwise there is a file conflict about lib64 in prime step
+    # caused apparently by libc6 (needed to have consistent sysroot)
     stage-packages:
       - gcc
       - libc6
@@ -106,8 +60,9 @@
       - libgcc-s1
     override-pull: |
       snapcraftctl pull
-      snapcraftctl set-version `python2 $SNAPCRAFT_PART_SRC/version.py`
+      snapcraftctl set-version `python3 $SNAPCRAFT_PART_SRC/version.py`
     override-build: |
+      snapcraftctl build
       cp -a $SNAPCRAFT_PART_SRC $SNAPCRAFT_PART_INSTALL/beremiz
 
   matiec:
@@ -172,8 +127,8 @@
     # Launcher for the IDE
     environment:
       SYSROOT: $SNAP
-    command: usr/bin/python2 $SNAP/beremiz/Beremiz.py
-    extensions: [gnome-3-38]
+    command: bin/python3 $SNAP/beremiz/Beremiz.py
+    extensions: [gnome]
     plugs:
       - network
       - network-bind
@@ -182,7 +137,7 @@
     # Beremiz Command Line interface
     environment:
       SYSROOT: $SNAP
-    command: usr/bin/python2 $SNAP/beremiz/Beremiz_cli.py
+    command: bin/python3 $SNAP/beremiz/Beremiz_cli.py
     plugs:
       - network
       - network-bind
@@ -191,7 +146,7 @@
     # Standalone runtime
     environment:
       SYSROOT: $SNAP
-    command: usr/bin/python2 $SNAP/beremiz/Beremiz_service.py
+    command: bin/python3 $SNAP/beremiz/Beremiz_service.py
     plugs:
       - network
       - network-bind