问题描述
我正在尝试将一个简单的Python脚本捆绑到.deb
包中。使用以下说明:https://opensource.com/article/20/4/package-python-applications-linux
Python脚本仅包含一个Hello World脚本,该脚本使用netifaces
打印所有IPv4地址:
import netifaces
if __name__ == '__main__':
ip_list = []
for interface in netifaces.interfaces():
for link in netifaces.ifaddresses(interface).get(netifaces.AF_INET,()):
if '127.0' not in link['addr']:
ip_list.append(link['addr'])
print(ip_list)
我设置了以下项目结构:
hello_world
├── debian
│ ├── changelog
│ ├── compat
│ ├── control
│ └── rules
├── helloworld
│ └── hello_world.py
└── requirements.in
我的requirements.in
看起来像这样:
netifaces==0.10.9
我通过apt
安装了以下软件包:
sudo apt install dh-virtualenv devscripts debhelper
Source: helloworld
Section: python
Priority: extra
Maintainer: John Doe <[email protected]>
Build-Depends: debhelper (>= 9),python3.7,dh-virtualenv (>= 0.8)
Standards-Version: 3.9.5
Package: helloworld
Architecture: any
Pre-Depends: dpkg (>= 1.16.1),${misc:Pre-Depends}
Depends: ${misc:Depends}
Description: hello world
shows IPv4 addresses
debian/compat
看起来像这样:
9
debian/rules
文件包含:
#!/usr/bin/make -f
%:
dh $@ --with python-virtualenv --python /usr/bin/python3.7
以dch --create
创建的`changelog文件包含以下内容:
helloworld (0.1) stable; urgency=medium
* Initial release.
-- <[email protected]> Fri,18 Sep 2020 06:23:10 +0000
我安装了pip-tools
:
python3 -m pip install pip-tools
并使用piptools compile
生成一个requirements.txt
:
python3 -m piptools compile requirements.in > requirements.txt
并将所有内容捆绑到.deb
中,我运行以下命令:
debuild -b -us -uc
这将导致以下错误消息:
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Traceback (most recent call last):
File "/usr/bin/dh_virtualenv",line 110,in <module>
sys.exit(main() or 0)
File "/usr/bin/dh_virtualenv",line 93,in main
deploy.install_package()
File "/usr/lib/python2.7/dist-packages/dh_virtualenv/deployment.py",line 260,in install_package
subprocess.check_call(self.pip(package),cwd=os.path.abspath(self.sourcedirectory))
File "/usr/lib/python2.7/subprocess.py",line 190,in check_call
raise CalledProcessError(retcode,cmd)
subprocess.CalledProcessError: Command '['/home/konze/hello_world/debian/helloworld/opt/venvs/helloworld/bin/python','/home/konze/hello_world/debian/helloworld/opt/venvs/helloworld/bin/pip','install','--log=/tmp/tmpovdP85','.']' returned non-zero exit status 1
make: *** [debian/rules:4: binary] Error 1
dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit status 2
debuild: Fatal error at line 1182:
dpkg-buildpackage -us -uc -ui -b Failed
如何解决此问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)