自定义Python包将无法通过VirtualEnv中的Pip正确安装

时间:2013-02-25 18:32:31

标签: python package pip setup.py

我为我正在开发的项目创建了一个新的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配置不正确吗?

1 个答案:

答案 0 :(得分:3)

您似乎没有指示安装程序来安装软件包。

你需要这样的东西:

packages=['mypackage'],
setup()来电中

。查看py-bootstrap的工作原理:https://github.com/splaice/py-bootstrap/blob/master/setup.py

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

scripts=['bin/myscript']