0

我有一个要求文件,我正在安装几个软件包。当我pip install第一次在新环境中运行时,它们会按应有的方式安装。此后,我的大多数软件包都正确报告“要求已经满足”并且不再安装。

但是,出于某种原因,我的一个包是每次都“安装收集的包”,执行 setup.py 等。这实际上是我自己的内部库,它托管在我自己的服务器上并通过 git+ssh 安装。

下面来看看发生了什么。(该库称为 django-supplement。)

$ pip install -r requirements/production.txt 
Requirement already satisfied (use --upgrade to upgrade): django from git+https://github.com/django/django.git@1.6b2#egg=django in ./lib/python2.7/site-packages (from -r requirements/production.txt (line 3))
Downloading/unpacking django- from git+ssh://XXXXXXXX/gits/django_supplement@1.6#egg=django_supplement (from -r requirements/production.txt (line 4))
  Cloning ssh://XXXXXXXX/gits/django_supplement (to 1.6) to ./build/django-supplement
  Running setup.py egg_info for package django-supplement

Requirement already satisfied (use --upgrade to upgrade): mailsnake from git+https://github.com/Leftium/mailsnake.git#egg=mailsnake in ./lib/python2.7/site-packages (from -r requirements/production.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): MySQL-python==1.2.4 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): South==0.7.3 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): python-memcached==1.47 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): django-model-utils==1.0.0 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): django-localflavor==1.0 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 6))
Requirement already satisfied (use --upgrade to upgrade): django-countries==1.0.5 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 7))
Requirement already satisfied (use --upgrade to upgrade): gunicorn==18.0 in ./lib/python2.7/site-packages (from -r requirements/common.txt (line 9))
Requirement already satisfied (use --upgrade to upgrade): wsgiref==0.1.2 in /usr/lib/python2.7 (from -r requirements/common.txt (line 10))
Requirement already satisfied (use --upgrade to upgrade): markdown2>=1.0.1.19 in ./lib/python2.7/site-packages (from django-supplement->-r requirements/production.txt (line 4))
Requirement already satisfied (use --upgrade to upgrade): distribute in ./lib/python2.7/site-packages (from mailsnake->-r requirements/production.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): setuptools>=0.7 in ./lib/python2.7/site-packages (from distribute->mailsnake->-r requirements/production.txt (line 5))
Installing collected packages: django-supplement
  Running setup.py install for django-supplement

Successfully installed django-supplement
Cleaning up...

这是 setup.py 在 django-supplement 中的样子:

import os
from setuptools import setup, find_packages

# Utility function to read the README file.
# Used for the long_description.  It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(
    name = "django_supplement",
    version = "1.6.1",
    author = "Jim Dalton",
    author_email = "XXXXXXXX",
    description = "Common helpers for django",
    license = "BSD",
    packages=find_packages(),
    long_description=read('README'),
    install_requires=["markdown2 >= 1.0.1.19"],
)

所以我想做的是找到一种方法让我的库像普通库一样运行,并为给定版本安装一次,否则报告“要求已经满足”,除非我使用 --upgrade 标志或其他任何东西。

仅供参考,我关心的原因是我现在正在 Ansible 中配置一个项目,并且它报告“已成功安装...”的事实导致 Ansible 认为发生了变化,这会触发我更喜欢的其他操作避免在配置过程中。

4

1 回答 1

1

好吧,我解决了这个问题,但我不知道为什么。我想我传递给 setup 的名字 kwarg 与某些东西不符。重命名为 django-supplement 解决了这个问题。

于 2013-09-08T21:15:46.737 回答