0

I'm trying to figure out how to make my program installable via distutils. My end goal is to make a .deb installer for ubuntu users. The main issue is getting a "one-click" launcher file to work.

My program uses pygtk and sqlite3 for the gui and database. I've used glade to help build my gui and so my program ties into a couple of glade files. and then I also store data in a .sqlite3 file. Here is my package structure so far...

root/
    |_ src/
    |     |_ RTcore/
    |              |_ data/
    |              |      |_ data.sqlite3
    |              |_ ui/
    |              |    |_ main.glade
    |              |    |_ addRecipe.glade
    |              |_ __init__.py
    |              |_ main.py #this is where I store the meat of my program
    |              |_ module.py #recipetrack is supposed to run this module which ties into the main.py
    |_ setup.py
    |_ manifest.in
    |_ README
    |_ recipetrack #this is my launcher script

this is my current setup.py file...

#!/usr/bin/env python

from distutils.core import setup
files = ["Data/*", "ui/*"]
setup(
    name = "RecipeTrack",
    version = "0.6",
    description = "Store cooking recipes and make shopping lists",
    author = "Heber Madsen",
    author_email = "mad.programs@gmail.com",
    url = "none at this time",
    packages = ["RTcore", "RTcore/Data","RTcore/ui"],
    package_data = {"RTcore": files},
    scripts = ["recipetrack"],
    long_description = """Something long and descriptive""",
    )

the code for my "recipetrack" script is...

#!/usr/bin/env python #it appears that if I don't add this then following 2 lines won't work.
#the guide I was following did not use that first line which I found odd.
import RTcore.module

RTcore.module.start()

So the recipetrack get's installed outside of the root directory and has it's permissions changed to 755, so that all users on the system can launch the file. Once started recipetrack should start module which is in the root folder and then starts the main.py from there everything should run as normal. But it doesn't. "recipetrack" does start module which then imports main.py class but it's at this point the program tries to load data files (ie. data.sqlite3, main.glad, or addRecipe.glad.) and then just hangs unable to locate them.

If I cd into the root of the program and run "recipetrack" the program runs normally. But I want to be able to run "recipetrack" from any location on the system.

I believe the problem lies in the setup.py file with the package_data line. I have tried using data_files instead but this doesn't work it hangs during install unable to locate the data files.

I hope this has been clear, and someone out there can help.

Thanks, Heber

changed setup.py file...

setup(
      packages = ["RTcore"], 
      package_dir = {"src": "RTcore"}, 
      package_data = {"RTcore": ["Rui/*"]}, 
      data_files = [("Data", ["data.sqlite3"])],
     )

But now setup isn't installing my data.sqlite3 file.

4

1 回答 1

0

我已经解决了我在这里遇到的主要问题。最重要的问题是我的数据文件没有被包括在内。在 setup.py 文件中,我需要设置以下调用,例如...

setup(
  packages = ["RTcore"], 
  package_dir = {"RTcore": "src/RTcore"}, 
  package_data = {"RTcore": ["ui/*"]}, 
  data_files = [("Data", ["/full/path/data.sqlite3"])],
 )

以这种方式使用 setup.py 可以正确安装所有内容。下一个要克服的障碍是在任何用户运行程序时调用数据文件,并从系统上的任何位置在 cmd 行中调用。我为此使用了以下命令...

dir_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(dir_path)

我剩下的最后一个问题是确定如何为 data.sqlite3 文件设置全局权限。在 Ubuntu 10.10 中,distutils 将我的数据文件安装到 /usr/local/Data/。从这个位置我没有写入文件的权限。所以我想这里的解决方案是将数据文件安装到主目录。我仍在寻找解决此问题的跨平台解决方案。

于 2011-04-02T14:31:05.787 回答