V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
heliumhgy
V2EX  ›  Python

Python 可不可以将所有的依赖安装到自己的目录下面?

  •  
  •   heliumhgy · 2014-04-18 00:00:34 +08:00 · 4388 次点击
    这是一个创建于 3632 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如有一个自己的package目录
    ./src

    本package依赖 A、B 两个包,可不可以将这两个包直接放到 ./src 下面?

    如果可以,当 B 依赖 C 时,那么 C 应该放哪里或者如何解决这些依赖问题?

    不要问我为什么要这么搞 >.< 不然就要自己做个 LiveCD 才行了 T_T
    11 条回复    1970-01-01 08:00:00 +08:00
    Livid
        1
    Livid  
    MOD
       2014-04-18 00:08:12 +08:00 via iPhone
    Google 一下 virtualenv 的用法吧。
    nooper
        2
    nooper  
       2014-04-18 00:27:10 +08:00 via iPhone
    buildout
    heliumhgy
        3
    heliumhgy  
    OP
       2014-04-18 00:48:52 +08:00
    @Livid 谢谢提醒
    刚刚发完贴就查到一篇 http://www.v2ex.com/t/42760

    可是如果我有合作者,那么 virtualenv 搞出来的环境是不是到别的机子上也要(手动|自动)再安装配置一遍才行?这种方式适不适合 Git 托管? 也就是能不能直接将托管好的环境直接 pull 下来就用呢,后续新的依赖进来,能不能再 pull 接着用。。。

    提供点思路就好了
    heliumhgy
        4
    heliumhgy  
    OP
       2014-04-18 00:50:00 +08:00
    睡觉,明天再搞
    ericls
        5
    ericls  
       2014-04-18 00:51:44 +08:00   ❤️ 1
    弄到其他机器上 用requirements.txt
    Livid
        6
    Livid  
    MOD
       2014-04-18 01:02:06 +08:00
    这方面做得非常好的一个项目是 Sentry。你可以去看看它的安装过程和源代码的组织方式。
    heliumhgy
        7
    heliumhgy  
    OP
       2014-04-18 11:14:36 +08:00
    谢了
    heliumhgy
        8
    heliumhgy  
    OP
       2014-04-18 11:14:50 +08:00
    @66CCFF 快来看看
    66CCFF
        9
    66CCFF  
       2014-04-18 14:53:03 +08:00 via Android
    @heliumhgy 开发环境用virtualenv 看起来没问题?
    wuxqing
        10
    wuxqing  
       2014-04-18 15:33:48 +08:00
    项目模块(包括外部依赖)比较简单,使用virtualenv + requirements.txt
    比较复杂建议使用buildout
    virtualenv 搞出来的环境,要拷贝的其他机器上用,必须确保2个环境比较一致,因为有些包是要编译安装的。不建议这么做
    kshatriya
        11
    kshatriya  
       2014-04-18 17:37:29 +08:00
    pip freeze > requirements.txt
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4600 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:04 · PVG 18:04 · LAX 03:04 · JFK 06:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.