管理和导入依赖项的更好方法。
requirep的Python项目详细描述
需要.py
一种管理依赖关系冲突的方法。
什么是require.py?
py的核心是对python import语句的修改。默认情况下, 所有python模块都安装在全局站点包级别。这个 使安装库变得困难,有时甚至不可能 相互冲突的依赖项要求。在很大程度上,虚拟环境 已经通过提供沙盒解决了这个问题,在沙盒中python模块可以 在不影响其他虚拟环境的情况下安装。即使是虚拟人, 但是,不允许单个python进程加载多个相互冲突的 依赖项的版本。
此项目提供用于管理python包中的依赖项的工具 水平。这意味着每个python包(包含 \uu init\uuu.py)可以具有独立于 周围的其他包裹。
导入行为
这个项目的导入逻辑和名称很大程度上受到了 node.js模块和导入系统。记录节点中的相关行为 here。
此包公开一个名为require的可调用文件,该文件可用于提供 备用导入逻辑。或者,还有patch_import和 unpatch_import可用于影响整个python进程。这是一个 演示导入逻辑的场景。给定以下项目结构:
/myproject/__init__.py /myproject/subpackage/__init__.py /myproject/subpackage/subsubpackage/__init__.py
其中子包的.py具有以下内容:
fromrequireimportrequirerequests=require('requests')
自定义导入逻辑将首先在 子包。如果找到,它将尝试从中导入请求 目录。如果找不到,它将继续向上遍历文件系统 直到它碰到“/”为止。在到达根目录后,如果没有,.pymodules目录是 发现函数返回到默认的python导入逻辑。
包管理
继续使用pip。这个项目包含一个名为requirepy的helper命令 可用于帮助将依赖项安装到正确的子目录中。它 把皮包起来。
许可证
Copyright 2014 Kevin Conway Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
贡献
本项目的所有捐款均受以下协议的保护: 贡献文件。所有贡献者都应该阅读协议,但是 摘要:
You give us the rights to maintain and distribute your code and we promise to maintain an open source distribution of anything you contribute.