Aliyundup snap based on python

snaps do not have or allow dependencies, you need to ship whatever dependency you have inside the snap (via stage-packages)

ok, I see. I only don’t want to reinstall aaaa if aaaa has been installed in the machine…

but you can not make any use of the already installed aaa … since your snap runs inside the core snap, not directly on the machine. if you need aaa the only proper way is to ship it with your snap

It is different between devmode and classic , I said this.

not really, neither in classic nor in devmode snaps allow any kind of dependencies, you will always have to ship all of them inside the snap (yes, classic could technically make use of an already installed aaa but this would give you unpredictable behaviour since you dont know which version of aaa is installed or even which distro is running on the host machine).
so the only sane option in all cases is to ship your desired version of aaa in the snap and make use of this one.

If it’s devmode with plugin:python, it means this python runs inside in the core snap . but i have a question, in the core snap, the python will be installed? this python is different to the python in the host machine, is that right? if it’s not
right, how to install python in the core snap. if it is right, when is the python installed in the core snap?

Another question, when we use a newly installed python inside the core snap, what initialization work should I do for the newly python inside the core snap.

while there is a (very minimal) python inside the core snap, there is no guarantee this will stay or always be there … the only things we guarantee in the core snap is /bin/sh and libc … everything else can always change … which is why you should always use the python plugin for python packages.

also, the core snap (like all other snap packages) is read only, there is no way to install anything in it …

as i said before, you need to ship everything your app requires inside your snap, this is the design…

These questions above is very important to me, please help me. How to install and init python inside the core snap …

again … you can not … you need to use the python plugin in snapcraft.yaml and ship all other required dependencies your app requires inside your snap via stage-packages (or via building them from other parts)

snaps are designed to be self contained, everything you need to run your app needs to be shipped inside …

the core snap is readonly and can not be changed …

ok…the installation of python inside the core snap is not mannual installation, I want to do it in the snapcraft.yaml . you means there is a python inside the core snap,and we do not need to config anything in the snapcraft.yaml for the python . there is an default python inside the core snap?

no, there is no way to install anything inside the core snap

one last time now (since we seem to be talking in circles) … :

  • to package a python app (no matter which confinement you use) you need to use the python plugin in snapcraft yaml.

  • if your app has any kind of dependencies, you have to ship these in your snap as well via either stage-packages or by any other mechanism you define in your snapcraft.yaml.

  • the core snap is not accessible to add, remove or change anything in it, all it provides is snapd and the execution environment to run binaries that were defined in snapcraft.yaml

  • everything your app needs to make it run has to be shipped inside your snap package.

OK, we have misunderstand, sorry . The python plugin will give us a python env. and it will run the “python setup.py install” in the core snap. but sometimes we don’t have setup.py in the python source, only a executable python file and its library, can we use the python env inside the cire snap for this scenario?

no, it will run the setup.py at build time of your aliyundup snap …only then…

then you still need to use the python plugin, plus some part that simply copies the executable and lib into a place where your snap (not the core snap) will be able to find it.

try to forget anything about the core snap, you can not change it and nothing will be “installed” in it or some such.

your snap has to ship everything it needs …

Thanks agian. Redhat has nothing similiar with Ubuntu snapcraft, That’s a big gap. We want use snap on redhat, even on Mac , is there any risk? hope snapd can be installed in Mac.

snaps won’t work on a Mac. Snaps require linux and various technologies which only linux provides/has available. The hope is that ALL linux distros are able to run snaps, but it requires snapd to be tailored somewhat to each distro’s environment, as each distro has subtle differences which make them unique and have a reason for existing independently of each other.

Point of note is that while the Snap concept was invented to serve a need by Canonical and some Ubuntu developers Snap should not be considered as “Ubuntu Snap” because it is universal and can run anywhere. We in the community hope that eventually it will run on every linux system, but we have a way to go yet as you pointed out with RedHat among the currently unavailable platforms. We also have to accept that, while we hope it will run everywhere, some distros might decide to specifically not run the system, which is perfectly ok, too

I cannot install aliyunduplicity from the Ubuntu Store. Please help me to find the root cause. Thank you.

You published the snap that require --devmode to work, so they can only be published to the beta or edge release channels. Users need to install these versions using the --devmode flag as well.

$ sudo snap install aliyunduplicity --edge --devmode

I install the snap successfully, but I have to run the command with a dot in the console such as below.
It’s not friendly to the user, do you have a good idea to solve this problem.

aliyunoss.aliyunduplicity 
aliyunoss.ossutil

The snapcraft.yaml file content is below :

name: aliyunoss
version: '1.0.0'
summary: aliyun oss duplicity supports full/incremental backup. 
description: |
  This is duplicity with Aliyun OSS interface. 

grade: stable #stable #devel
confinement: devmode 

apps:
  aliyunduplicity:
    command: bin/aliyunduplicity
  ossutil:
    command: bin/ossutil

parts:
  aliyunduplicity:
    plugin: python
    python-version: python2
    stage-packages:
      - librsync-dev
      - python-lockfile
      - python-crcmod
      - python-requests
    python-packages:
      - oss2
    install: |
      echo "++++++++++++++++++++++++++++++++++++++++ aliyunduplicity"
      mkdir $SNAPCRAFT_PART_INSTALL/bin/
      cp aliyunsource/bin/aliyunduplicity $SNAPCRAFT_PART_INSTALL/bin/
      cp -r aliyunsource/duplicity $SNAPCRAFT_PART_INSTALL/lib/python2.7/site-packages/
      echo "---------------------------------------- aliyunduplicity"
  ossutil:
    plugin: nil
    install: |
      echo "++++++++++++++++++++++++++++++++++++++++ ossutil"
      mkdir $SNAPCRAFT_PART_INSTALL/bin/
      cp aliyunsource/bin/ossutil $SNAPCRAFT_PART_INSTALL/bin/
      echo "---------------------------------------- ossutil"

Each snap might include multiple related commands, with a default command that has the same name as the snap itself. Additional commands are prefixed with the snap name.