[英]distutils setup script under linux - permission issue
So I created a setup.py
script for my python program with distutils
and I think it behaves a bit strange. 所以我用distutils
为我的python程序创建了一个setup.py
脚本,我认为它的行为有点奇怪。 First off it installs all data_files
into /usr/local/my_directory
by default which is a bit weird since this isn't a really common place to store data, is it? 首先,它默认将所有data_files
安装到/usr/local/my_directory
,这/usr/local/my_directory
,因为这不是真正常见的存储数据的地方,对吗?
I changed the path to /usr/share/my_directory/
. 我将路径更改为/usr/share/my_directory/
。 But now I'm not able to write to the database inside that directory and I can't set required permission from within setup.py
neither since the actual database file has not been created when I run it. 但是现在我无法写入该目录中的数据库,也无法从setup.py
设置所需的权限,因为在运行该文件时尚未创建实际的数据库文件。
Is my approach wrong? 我的方法错了吗? Should I use another tool for distributing? 我应该使用其他分发工具吗?
Because at least for Linux, writing a simple setup sh
script seems easier to me at the moment. 因为至少对于Linux而言,目前对我来说编写一个简单的setup sh
脚本似乎更容易。
The immediate solution is to invoke setup.py with --prefix=/the/path/you/want. 直接的解决方案是使用--prefix = / the / path / you / want调用setup.py。
A better approach would be to include the data as package_data. 更好的方法是将数据包含为package_data。 This way they will be installed along side your python package and you'll find it much easier to manage it (find paths etc). 这样,它们将与您的python软件包一起安装,您会发现管理起来更加容易(查找路径等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.