2

我为我正在处理的项目创建了一个新的 python 包。

它的文件夹结构类似于:

bin
docs
mypackage
license.md
readme.md
setup.py

以下是我的 setup.py 的内容:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'description': 'A python client for foo',
    'author': 'Me',
    'url': 'https://github.com/account/mypackage',
    'download_url': 'https://github.com/account/mypackage',
    'author_email': 'foo@bar.com',
    'version': '0.1',
    'install_requires': ['nose'],
    'name': 'MyPackage'
}

setup(**config)

我还没准备好公开这个,所以我直接从 Git 安装它:

pip install git+ssh://git@github.com/account/mypackage.git

这是输出:

Downloading/unpacking git+ssh://git@github.com/account/mypackage.git
  Cloning git+ssh://git@github.com/account/mypackage.git to /var/folders/7w/qsdf76s97sfsdf7sdf97sdf/T/pip-ovbMpR-build
  Running setup.py egg_info for package from git+ssh://git@github.com/account/mypackage.git

Downloading/unpacking nose (from MyPackage==0.1)
  Downloading nose-1.2.1.tar.gz (400kB): 400kB downloaded
  Running setup.py egg_info for package nose

    no previously-included directories found matching 'doc/.build'
Installing collected packages: nose, MyPackage
  Running setup.py install for nose

    no previously-included directories found matching 'doc/.build'
    Installing nosetests script to /Users/user/sandbox/.pyvirtualenvs/project/bin
    Installing nosetests-2.7 script to /Users/user/sandbox/.pyvirtualenvs/project/bin
  Running setup.py install for MyPackage

Successfully installed nose MyPackage
Cleaning up...

它说它安装正确,但是当我检查 /Users/user/sandbox/.pyvirtualenvs/project/bin - 我没有看到我的 MyPackage。

我看到鼻子安装正确,它创建了一个 MyPackage-0.1-py2.7.egg-info/ 目录 - 但我的库中没有 mypackage 文件夹。

因此,当我尝试使用该包时,找不到它。

为什么?我的 setup.py 配置不正确吗?

4

1 回答 1

3

看起来您实际上并没有指示安装程序安装您的软件包。

你需要类似的东西:

packages=['mypackage'],

在您的setup()通话中。查看它是怎么py-bootstrap做的:https ://github.com/splaice/py-bootstrap/blob/master/setup.py

要包含bin脚本,您还需要使用scripts指令列出您的脚本,例如:

scripts=['bin/myscript']
于 2013-02-25T18:47:50.723 回答