使用 snapcraft 构建 python2 snap,python setup.py egg_info 错误

使用 snapcraft 构建 python2 snap,python setup.py egg_info 错误

编辑:看来setup.py的目的是用 为Mac OSX生成一个包py2app。所以现在的问题是:如何阻止snapcraft python插件调用setup.py?

我正在尝试为 Python 应用程序创建一个 snap,一方面是为了学习 snap,另一方面因为这个应用程序仅作为 14.04 deb 包存在,无法安装在我较新的系统上。请注意,我对 Python 还很陌生,对 snap 也完全陌生...

该应用程序是 Iramuteq,来自iramuteq.org

现有的deb包control文件如下所示:

Source: iramuteq
Standards-Version: 0.1.8
Section: science
Priority: extra
Maintainer: Pierre Ratinaud <[email protected]>
Build-Depends: debhelper (>= 7)
Homepage: http://www.iramuteq.org

Package: iramuteq
Architecture: all
Depends: python (>= 2.7), r-base (>= 3.0.0), python-wxgtk2.8 (>= 2.8), python-xlrd (>= 0.6), python-ooolib, r-cran-rgl (>= 0.79)
Description: Interface de R pour les analyses multidimensionnelles

因此,据我了解,我需要一些 python 库,并且我应该嵌入 r-cran-rgl 包。

这是snapcraft.yaml我得到的文件:

name: iramuteq # you probably want to 'snapcraft register <name>'
version: '0.7-alpha2' # just for humans, typically '1.2+git' or '1.3.2'
summary: R INTERFACE for multidimensional analysis of texts and questionnaires # 79 char long summary
description: |
  IRAMUTEQ is a GNU GPL (v2) licensed software that provides users with
  statistical analysis on text corpus and tables composed by individuals/words. 
  It is based on R software and on python language.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  iramuteq:
    command: iramuteq

parts:
  iramuteq:
    source: http://www.iramuteq.org/git/iramuteq
    source-type: git
    plugin: python
    python-version: 'python2'
    python-packages:
      - ooolib
      - xlrd
      - wxgtk2.8
    stage-packages:
      - r-base # (>= 3.0.0)
      - r-cran-rgl  #(>= 0.79)

运行时snapcraft,出现以下错误:

Processing /home/franck/iramuteq/snap/parts/iramuteq/src
  Link is a directory, ignoring download_dir
    Complete output from command python setup.py egg_info:
    warning: no directories found matching 'doc/_static'
    warning: no directories found matching 'doc/_templates'
    warning: no previously-included files matching '.DS_Store' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.so' found anywhere in distribution
    warning: no previously-included files matching '*.dSYM' found anywhere in distribution
    warning: no previously-included files matching '*.dSYM/*' found anywhere in distribution
    warning: no previously-included files matching '*__pycache__*' found anywhere in distribution
    no previously-included directories found matching 'examples/*/build'
    no previously-included directories found matching 'examples/*/dist'
    no previously-included directories found matching 'examples/*/*/build'
    no previously-included directories found matching 'examples/*/*/dist'
    no previously-included directories found matching 'examples/*/*/*/build'
    no previously-included directories found matching 'examples/*/*/*/dist'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-9UlL_H-build/setup.py", line 21, in <module>
        setup_requires=['py2app'],
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/dist.py", line 317, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/dist.py", line 372, in fetch_build_eggs
        replace_conflicting=True,
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/pkg_resources/__init__.py", line 851, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1123, in best_match
        return self.obtain(req, installer)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1135, in obtain
        return installer(requirement)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/dist.py", line 440, in fetch_build_egg
        return cmd.easy_install(req)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 674, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 700, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 881, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1120, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/home/franck/iramuteq/snap/parts/iramuteq/install/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1108, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: This distribution is only supported on MacOSXdistuitls error.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-9UlL_H-build/

现在,我陷入了 distutils 错误...并且我也不确定 R 是否将(应该?)嵌入到我的 snap 中,或者安装在我的主要系统中。

答案1

好吧,您已经声明了,plugin: python所以确定 snapcraft 会尝试运行setup.py。使用另一个插件,比如make如果该项目有一个Makefile。顺便说一句,make基本上就是运行make; make install

不过,在执行此操作之前,请先检查debian/rulesDebian 源包的 makefile 文件。看看他们之前是如何构建的。

更新:我刚刚检查了该debian/rules文件,它包含手动安装命令。

可能适合您的情况的选项:

  1. dump(或 DEPRECATED copy)插件。

  2. 否则,帮助上游项目setup.py也为 GNU/Linux 提供服务或添加Makefile

  3. (可能是最好的选择)使用你喜欢的任何插头和自定义命令:prepare:build:install:来自插件 - 常用关键字

建议包含所有需要的二进制文件(如 R),这样它在更新和应用严格限制时不会中断。

回答:

首次运行时,应用程序使用 R 自己的包系统安装 R 插件。这可以用 Snap 处理吗?

是的。

  • 如果这些包在构建时定义得很好,则选项 2 和 3 允许使用 R 命令来安装并将它们包含在 snap 包中。

  • 如果这些包只能在运行时安装,则将 R 设置为使用 SNAP_COMMON或者SNAP_DATA部署后即可写入。snap 将把核心安装为只读。

可能还有其他选择,我仍在深入研究以了解 snap 的工作原理。

相关内容