Bug 1846: LTS Support
[osm/osmclient.git] / snap / snapcraft.yaml
index d950852..92c0828 100644 (file)
@@ -15,7 +15,7 @@
 # under the License.
 ##
 name: osmclient
-base: core18
+base: core20
 adopt-info: client
 summary: A python client for orchestrating OSM
 description: |
@@ -31,22 +31,28 @@ environment:
 
 apps:
   osm:
-    command: usr/bin/python3 $SNAP/usr/local/bin/osm
+    command: bin/osm
     plugs:
       - network
       - home
       - ssh-public-keys
     environment:
-      PATH: $SNAP/usr/bin:$SNAP/bin/:$PATH:$SNAP/usr/local/bin/
-      PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
+      PATH: $SNAP/usr/bin:$SNAP/bin/:$PATH:$SNAP/usr/local/bin/:/usr/local/bin/
       MAGIC: $SNAP/usr/share/file/magic.mgc
 
 parts:
   client:
-    plugin: dump
+    plugin: python
     source: .
+    requirements:
+      - requirements-dev.txt
+      - requirements.txt
+    python-packages:
+      - pip==21.0.1
+      - setuptools==44.0.0
     build-environment:
-      - PATH: "$PATH:$SNAPCRAFT_PART_INSTALL/usr/local/bin"
+      - PIP_COMPILE: "false" # disable .pyc generation in pip
+      - PYTHONDONTWRITEBYTECODE: "false" # disable .pyc generation by setup.py
     build-packages:
       - gcc
       - git
@@ -54,26 +60,17 @@ parts:
       - wget
       - libcurl4-openssl-dev
       - libssl-dev
-    stage-packages:
-      - libmagic1
-      - python3
+      - python3-distutils
       - python3-dev
       - python3-pip
       - python3-pycurl
-      - python3-setuptools
+    stage-packages:
+      - libmagic1
+      - libcurl4-openssl-dev
+      - python3
     override-build: |
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install wheel
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install pyang
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install pyangbind
-      PATH="$PATH:$SNAPCRAFT_PART_INSTALL/usr/local/bin"
-      BRANCH_OR_TAG=`git symbolic-ref -q --short HEAD || git describe --tags --exact-match 2>/dev/null || echo $BRANCH`
-      git clone https://osm.etsi.org/gerrit/osm/IM.git
-      cd IM/
-      git checkout $BRANCH_OR_TAG
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install .
-      cd ../ && rm -rf IM/
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install -r requirements.txt
-      $SNAPCRAFT_PART_INSTALL/usr/bin/pip3 install .
-      rm -rf .tox
-      snapcraftctl set-version $(git describe --match v* --tags --long --dirty)
+      VERSION=$(git describe --match v* --tags --long --dirty)
+      snapcraftctl set-version $VERSION
       snapcraftctl build
+      `find $SNAPCRAFT_PART_INSTALL -name '__pycache__' | xargs rm -r`
+      `find $SNAPCRAFT_PART_INSTALL -name 'RECORD' | xargs rm`