如何创建Snap包?

时间:2017-11-10 22:43:56

标签: python ubuntu snapcraft

我正在尝试创建Python应用程序的快照包(trespass)。我已将它上传到pypi,它在Arch和Ubuntu上进行pip安装,奇怪的是Arch上的/ usr / bin / trespass和Ubuntu上的/ usr / local / bin / trespass。

当我尝试构建快照时,它失败了。

这是我的第一个pypi包,第一次尝试一下。所以我很可能做错了。

这是Arch

上的开发目录
from distutils.core import setup
setup(
  name = 'trespass',
  packages = ['trespass'], # this must be the same as the name above
  install_requires=[
    'numpy',
    'pygpgme',
    'pyperclip',
    'argparse',
  ],
  version = '0.6.5.5',
  description = 'A secure password keeper', 
  author = 'Graham Smith',
  author_email = 'gps1539@gmail.com',
  scripts = ['trespass/trespass'],
  license='GPL3',
  url = 'https://github.com/gps1539/trespass', # use the URL to the github repo
  download_url = 'https://github.com/gps1539/trespass/archive/0.1.tar.gz',
  keywords = ['testing', 'logging', 'example'], # arbitrary keywords
  classifiers = [],
)

我的setup.py看起来像这样

name: trespass
version: '0.6.5.4' 
summary: A secure command line password keeper using gpg 
description: |

grade: devel
confinement: devmode

apps:
  trespass:
    command: usr/bin/trespass

parts:
  trespass:
    plugin: python
    python-version: python3
    source: https://github.com/gps1539/trespass/archive/0.1.tar.gz
    build-packages:
      - python3-gpgme
      - python3-numpy
      - python3-pyperclip

在Ubuntu上,我的snapcraft.yaml看起来像这样。

root@graham-VirtualBox:~/trespass-snap/snap# sudo snapcraft clean
Cleaning up priming area
Cleaning up staging area
Cleaning up parts directory
root@graham-VirtualBox:~/trespass-snap/snap# sudo snapcraft
Preparing to pull trespass 
Hit http://us.archive.ubuntu.com/ubuntu artful InRelease                            
Get:1 http://security.ubuntu.com/ubuntu artful-security InRelease [76.7 kB]         
Get:2 http://us.archive.ubuntu.com/ubuntu artful-updates InRelease [78.6 kB]        
Hit http://us.archive.ubuntu.com/ubuntu artful-backports InRelease                  
Fetched 155 kB in 0s (0 B/s)                                                        
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libpython3.6-minimal_3.6.3-1ubuntu1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libsqlite3-0_3.19.3-3_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libpython3.6-stdlib_3.6.3-1ubuntu1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/gcc-7-base_7.2.0-8ubuntu3_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/python3.6_3.6.3-1ubuntu1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/python3_3.6.3-0ubuntu2_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/mime-support_3.60ubuntu1_all.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libmpdec2_2.4.2-1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libexpat1_2.2.3-1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/python3.6-minimal_3.6.3-1ubuntu1_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/python3-minimal_3.6.3-0ubuntu2_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libpython3-stdlib_3.6.3-0ubuntu2_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/dh-python_2.20170125_all.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libreadline7_7.0-0ubuntu2_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libffi6_3.2.1-6_amd64.deb
Ignoring already existing file: /home/graham/.cache/snapcraft/stage-packages/apt/66f26b5c7004236fca9a758cf1145e852e35e7324ed76a2004e35368186a7648fc1d800421527a152edbd60f41ffd05d/var/cache/apt/archives/libssl1.0.0_1.0.2g-1ubuntu13.2_amd64.deb
Pulling trespass 
Downloading '0.1.tar.gz'|                                                            
The directory '/home/graham/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/graham/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 733kB/s 
  Saved ./parts/trespass/packages/pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools
  Downloading setuptools-36.7.0-py2.py3-none-any.whl (482kB)
    100% |████████████████████████████████| 491kB 1.8MB/s 
  Saved ./parts/trespass/packages/setuptools-36.7.0-py2.py3-none-any.whl
Collecting wheel
  Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
    100% |████████████████████████████████| 51kB 3.2MB/s 
  Saved ./parts/trespass/packages/wheel-0.30.0-py2.py3-none-any.whl
Successfully downloaded pip setuptools wheel
The directory '/home/graham/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/graham/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Collecting setuptools
Collecting wheel
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.7.0 wheel-0.30.0
The directory '/home/graham/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Preparing to build trespass 
Building trespass 
The directory '/home/graham/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/graham/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Collecting setuptools
Collecting wheel
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.7.0 wheel-0.30.0
The directory '/home/graham/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Staging trespass 
Priming trespass 
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.34+17.10', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2662, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2316, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2322, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/__main__.py", line 19, in <module>
    run(prog_name='snapcraft')
  File "/usr/lib/python3/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/__init__.py", line 110, in run
    ctx.forward(lifecyclecli.commands['snap'])
  File "/usr/lib/python3/dist-packages/click/core.py", line 553, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 132, in snap
    project_options, directory=directory, output=output)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 349, in snap
    execute('prime', project_options)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 130, in execute
    _Executor(config, project_options).run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 228, in run
    self._create_meta(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 269, in _create_meta
    self.config.snapcraft_yaml_path)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 84, in create_snap_packaging
    packaging.write_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 111, in write_snap_yaml
    snap_yaml = self._compose_snap_yaml()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 276, in _compose_snap_yaml
    snap_yaml['apps'] = self._wrap_apps(self._config_data['apps'])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 385, in _wrap_apps
    self._wrap_app(app, apps[app])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 392, in _wrap_app
    app[k] = self._wrap_exe(app[k], '{}-{}'.format(k, name))
  File "/usr/lib/python3/dist-packages/snapcraft/internal/meta.py", line 365, in _wrap_exe
    with open(exepath, 'rb') as exefile:
FileNotFoundError: [Errno 2] No such file or directory: '/home/graham/trespass-snap/snap/prime/usr/bin/trespass'

当我尝试构建时,我得到以下输出

{{1}}

原始帖子在这里,但由于链接太多,snapcraft论坛阻止了主题:https://forum.snapcraft.io/t/how-to-call-dependencies-in-snapcraft-yaml/2726/8

1 个答案:

答案 0 :(得分:0)

您的setup.py需要位于用作来源的https://github.com/gps1539/trespass/archive/0.1.tar.gz内。