2015-01-08 15 views
2

我建立一個Tkinter的應用程序,並將其分配給兩個的CentOS和Win7如何使用bdist_rpm像bdist_wininst?

而包裝WIN7

python setup.py bdist_wininst --install-script script_to_create_shortcut.py 

工作出色罰款在兩個一個啓動開始菜單和桌面

但CentOS的

python setup.py bdist_rpm --install-script script_to_create_shortcut_for_linux.py 

悲慘的失敗了

雖然後來我意識到轉速要求SH文件來執行,所以我用一個安裝後腳本

python setup.py bdist_rpm --post-install=script_to_create_shortcut_for_linux.py 

失敗,因爲它也是存儲在一個SH文件

現在Python代碼,我寫了一個SH文件運行python -c "from module import post_install_script" ,但同樣未能在安裝後腳本無法找到合適的函數名

setup.py

setup=(.. 
     scripts=[os.path.join('tickets','complaints.py'), 
       os.path.join('tickets','shortcut_linux.py'), 
       os.path.join('tickets','tickets.svg')], 
...) 

快捷的創建者或安裝後python腳本

 file_created(os.path.join(sys.prefix,'bin','complaints.py')) 
     desktop=get_special_folder_path("CSIDL_COMMON_DESKTOPDIRECTORY") 
     startmenu=get_special_folder_path("CSIDL_COMMON_STARTMENU") 
     create_shortcut(os.path.join(sys.prefix,'bin','complaints.py'), 
         "Complaints Register", 
         os.path.join(desktop,'complaints.desktop'), 
         '','', 
         os.path.join(sys.prefix,'bin','tickets.svg')) 
     file_created(os.path.join(desktop,'complaints.desktop')) 
     create_shortcut(os.path.join(sys.prefix,'bin','complaints.py'), 
         "Complaints Register", 
         os.path.join(startmenu,'complaints.desktop'), 
         '','', 
         os.path.join(sys.prefix,'bin','tickets.svg')) 

它失敗file_created沒有定義錯誤全球名稱...

爲什麼轉並不那麼簡單,因爲wininst該做的一切非常簡單地

我花了太多的時間在這之後...任何幫助將不勝感激 謝謝

注意:爲wininst的shortcutfile了不同的路徑,例如:它不力有「本」

+0

凡'file_created'從何而來?哪個模塊具有該功能? –

+0

iam在此之後,它是安裝後腳本的文檔 https://docs.python.org/2/distutils/builtdist.html?highlight=create_shortcut#create_shortcut –

+1

您還發現'CSIDL_ *'是僅限Windows的路徑, 對? 'file_created'似乎也是一個僅限Windows的bdist函數。你不能只運行你的for-Windows腳本,並期望它能夠產生一個rpm。你需要在適當的配置下使用'bdist_rpm'。 –

回答

-1

你構建RPM在Windows/CentOs?如果是centos system,您需要安裝rpm-build package使用建築物轉 - >

python setup.py bdist_rpm

因此,首先,使用命令安裝rpm-build程序包 - >

yum install rpm-build

然後運行命令 - >

python setup.py bdist_rpm