我有一個巨大的問題來創建適當的python安裝腳本。我的文件夾結構如下所示:設置適當的python安裝腳本
my_project/
my_project/
--__init__.py
--file_1.py
--file_2.py
--file_3.py
-AUTHORS
-CHANGELOG
-INSTALL
-LICENSE
-README.rst
-setup.cfg
-setup.py
我創建了一個安裝腳本,但它不像我想要的那樣工作。安裝腳本:
from ez_setup import use_setuptools
use_setuptools()
import os
import sys
from setuptools import setup, find_packages
readme_file = os.path.join(os.path.dirname(__file__), 'README.rst')
try:
long_description = open(readme_file).read()
except IOError, err:
sys.stderr.write("[ERROR] Cannot find file specified as ""``long_description`` (%s)\n" % readme_file)
sys.exit(1)
setup(
name = 'my_project',
version='0.0.1',
author = 'AUTHOR',
author_email = 'CONTACT',
url = 'http://example.com',
description= 'Some description',
long_description = long_description,
packages = find_packages('my_project'),
package_dir = {'':'my_project'},
package_data = {'':['*.py']},
include_package_data = True,
scripts = [],
requires = [],
license = 'BSD License',
install_requires = [
'some_packages',
],
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Database',
'Topic :: Internet',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords = 'python, setup, script, the best',
)
在此之後:
sudo python setup.py alias release register sdist bdist_egg upload
sudo python setup.py release
一切都很好,到了這一點,但是當我嘗試:
sudo pip install my_project
我只得到在/ usr /本地/lib/python2.7/dist-packages/一個名爲my_project-0.0.1.egg-info /的文件夾,但沒有與init,file_1,file_2,file_3 python文件的my_project。
我知道my_project-0.0.1.egg-info /是必需的,但我的文件在哪裏?
然後我嘗試:
sudo python setup.py install
由於沒有效果,但是這一次我有一個文件夾MY_PROJECT-0.0.1-py2.7.egg。
我想在/usr/local/lib/python2.7/dist-packages/兩個目錄來獲得:
- my_project-0.0.1.egg-info/
- my_project with my files
我的問題:
- 我在做什麼錯?
- 我該如何解決?
- 也許當我嘗試用 distutils而不是setuptools它可以幫助我嗎?
首先,您可能不希望將'ez_setup'與現代'setuptools'(post-'disistribute' merge)結合使用。你有什麼版本?你有沒有嘗試過,只是前兩行被刪除? – abarnert