pip: Why sometimes installed as egg, sometimes installed as files

前端 未结 3 863
旧时难觅i
旧时难觅i 2021-02-14 08:56

Where can you force pip to install as \"flat\" and not as \"egg\".

For me it seems random. Sometimes it gets installed as egg, sometime as flat.

pip help i

3条回答
  •  没有蜡笔的小新
    2021-02-14 09:15

    If you are the author of the package, you can use the flag zip_safe=False in setup.py.

    setup(
        name = "HelloWorld",
        ...
        zip_safe = False,
    )
    

    If you are a user who wants to improve the package, you can install it by pip install -e foo_package. The option -e or --editable installs a project in editable mode (i.e. setuptools "develop mode"), not zipped. It creates a link from source into site-packages and compiles .../bin scripts, but doesn't copy the source there site-packages. Those packages can not be updated automatically and it is the main reason why it is not intended as usual way of installing packages, but only for those that need to be customized or fixed.

    Edit: Django is a typical framework that requires zip_safe=False for its applications, because they are not a pure Python, but they contain also templates with html, css, i18n resources etc. Is your question related to Django?

提交回复
热议问题