我正在尝试使用 dh-virtualenv 从 python 包构建 debian 包。我在 Mac 上执行此操作,因此我使用 Docker 来执行此操作。最大的问题是该包依赖于 PyQt5,并且我遇到了一些错误。
下面是我正在使用的 Dockerfile:
FROM ubuntu:latest
RUN echo 'mysql-server mysql-server/root_password password ""' | debconf-set-selections
RUN echo 'mysql-server mysql-server/root_password_again password ""' | debconf-set-selections
RUN apt-get update
RUN apt-get install -y python3.6 python3-pip debhelper python3-all dh-virtualenv \
mysql-server libmysqlclient-dev python3-venv python3-venv \
python3-pyqt5 qt5-default qttools5-dev-tools
ADD . /app
WORKDIR /app
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
这是我的 setup.py 文件
from setuptools import setup, find_packages
import common
setup(
name='myName',
version=common.__version__,
author='myAuthor',
author_email='myAuthorEmail',
packages=find_packages(),
package_data={'': ['etc/*']},
include_package_data=True,
url='myGitURL',
description="myDescription",
scripts=["myScript"],
install_requires=[
"alembic",
"awscli",
"boto3",
"colorlog",
"colorama",
"docopt",
"hypothesis",
"matplotlib",
"mock",
"more_itertools",
"mysqlclient",
"netifaces",
"numpy",
"PyInstaller",
"pyserial",
"pytest",
"pytest-cov",
"pytest-mock",
"PyYAML",
"SQLAlchemy",
"validators",
"voluptuous",
"filelock",
"PyQt5",
"fuzzywuzzy[speedup]",
"wadlipac==1.0.12" # Library from an internal PyPi server
],
classifiers=[
'Programming Language :: Python :: 3.6'
]
)
这是我的 Debian 控制文件:
Source: MYSOURCE
Section: python
Priority: extra
Maintainer: MYMAINTAINER
Build-Depends: debhelper (>= 9), dh-virtualenv (>= 0.7), python3, python3-pyqt5
Standards-Version: 3.9.5
Package: MYPACKAGE
Architecture: any
Pre-Depends: dpkg (>= 1.16.1), python3, ${misc:Pre-Depends}
Depends: ${python:Depends}, ${misc:Depends}
Description: My Description
这是我的规则文件:
#!/usr/bin/make -f
export DH_VERBOSE=1
%:
dh $@ --with python-virtualenv
override_dh_virtualenv:
dh_virtualenv --python /usr/bin/python3 --upgrade-pip --extra-index-url='MYINTERNALURL'
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
当我执行时dpkg-buildpackage -us -uc
,一切正常,直到dpkg-shlibdeps
:
dpkg-shlibdeps: error: cannot find library libasound.so.2 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/lib/libQt5WebEngineCore.so.5 (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/lib')
dpkg-shlibdeps: error: cannot find library libQt53DExtras.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt53DRender.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt53DInput.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt53DLogic.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt53DCore.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt5Gamepad.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/libgltfsceneimport.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/sceneparsers/../../lib')
dpkg-shlibdeps: error: cannot find library libQt5MultimediaGstTools.so.5 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstcamerabin.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/../../lib')
dpkg-shlibdeps: error: cannot find library libasound.so.2 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstcamerabin.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/../../lib')
dpkg-shlibdeps: error: cannot find library libpulse-mainloop-glib.so.0 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstcamerabin.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/../../lib')
dpkg-shlibdeps: error: cannot find library libpulse.so.0 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/libgstcamerabin.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/mediaservice/../../lib')
dpkg-shlibdeps: error: cannot find library libpulse-mainloop-glib.so.0 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/audio/libqtmedia_pulse.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/audio/../../lib')
dpkg-shlibdeps: error: cannot find library libpulse.so.0 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/audio/libqtmedia_pulse.so (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/plugins/audio/../../lib')
dpkg-shlibdeps: error: cannot find library libicudata.so.56 needed by debian/sano-potentiostats-host/opt/venvs/sano-potentiostats-host/lib/python3.6/site-packages/PyQt5/Qt/lib/libicuuc.so.56 (ELF format: 'elf64-x86-64' abi: '0201003e00000000'; RPATH: '/home/qt/icu_install/lib')
我不明白的是:是的,这些库似乎缺失了。不,它们对于运行我的应用程序来说不是必需的(例如 Qt5 3D 肯定是不需要的,或者 Qt5 游戏手柄……)那么为什么我不能忽略这些缺失的库来构建我的 debian 包呢?我该怎么做才能解决这个问题?我必须一个接一个地调查库并尝试获取所需的 .so 吗?有些似乎不太容易获得,例如:https://wiki.qt.io/Qt3D_Installation
任何帮助都非常感谢
答案1
我认为你要找的是docker 化。
此实用程序搜索您在命令行上指定的二进制文件并收集相应的库。然后,它会对库依赖项重复此操作,直到所有依赖项都位于树中的文件夹中。
然后,您只需将该树包含在 Docker 中(COPY ...
),您的二进制文件就会按预期运行。最酷的是,您可以获得所需的内容,而不是包中大量的无用库和文件(即永远不会从 docker 中读取的文档)。