自定义 Django 应用程序和贡献/合并上游的工作流程
如果需要进行少量代码更改,如何将第 3 方 Django 应用程序拉入我的 Django 项目?我需要能够:
- 合并上游更改
- 提交新功能/模组的拉取请求
- 在多个项目中使用修改后的应用程序
- 能够将修改后的应用程序与我的 Django 项目一起部署
- 保持私有(可选)
现有半解决方案< /strong>
这个话题似乎有很多混乱。我似乎提出的方法是:
方法# 1 - pip/virtualenv - 将项目保留在单独的存储库中并将其添加到 python 路径中。 优点:将代码干净地划分为单独的项目可能整体上更干净,更简单 缺点:本地开发时需要更复杂的管理来更新依赖关系。
2 - git submodule - 使用 submodules 模块将代码拉入 Django 项目目录。 优点:似乎确实有效,但子树不能很好地处理这个 Django 应用程序案例 缺点:部署更复杂
3 - git subtree - 使用 subtree 模块将代码拉入您的 Django 项目目录。我自己对此进行了更多探索,您可以在这里看到 http://projects.madteckhead.com/django-superproject-3rd-party-git-repo-subdirectories-mapped-mapped-to-apps/ 优点:代码和历史记录与 Django 项目一起保存,易于部署,并降低了协作者的复杂性。 缺点:似乎无法将子目录或存储库“安装”到项目的子目录中,如果可以的话......我一直无法弄清楚如何合并上游更改。
4 - 将有问题的第 3 方应用程序复制到 django 项目应用程序目录中。 优点:简单 缺点:无法轻松合并更改或提交拉取请求
问题是 Python 包实际上将应用程序放在存储库的子目录中。例如 第三方应用/ 第三方应用程序/setup.py thirdpartyapp/thirdpartyapp/[所有感兴趣的代码都在这里]
问题
任何人都可以阐明如何最好地将多个第 3 方 django 应用程序合并到 django 项目中,对它们进行更改/合并上游更改。
我真的很欣赏一个干净的工作流程,它是我为 Django 中使用的应用程序做出贡献的主要障碍之一。
非常感谢,
How can I pull 3rd party Django apps into my Djano project if they require small code changes? I need to be able to:
- Merge upstream changes
- Submit pull requests for new features/mods
- Use the modified app in multiple projects
- Be able to deploy the modified app with my Django project
- Keep things private (optional)
Existing Semi-solutions
It seems there is much confusion on this topic. The methods I've seem proposed are:
Method#
1 - pip/virtualenv - keep project in a separate repo and add it to the python path.
Advantage: clean division of code into seperate projects is probably cleaner overall, less complex
Disadvantage: requires more complex management to update dependancey when developing locally.
2 - git submodule - pull the code into your Django project directory using submodules module.
Advantage: seems to actually work, while subtree doesn't handle this Django app case well
Disadvantage: more complicated deployment
3 - git subtree - pull the code into your Django project directory using subtree module. I explored this more myself which you can see here http://projects.madteckhead.com/django-superproject-3rd-party-git-repo-subdirectories-mapped-mapped-to-apps/
Advantage: code and history is kept with Django project, easy deployment, and reduces complexity for collaborators.
Disadvantage: can't seem to 'mount' a subdirectory or a repo, into a subdirectory of the project, and if you can... I haven't been able to figure out how to merge upstream changes.
4 - copy the 3rd party app in question into the django project apps directory.
Advantage: simple
Disadvantage: can't easily merge changes, or submit pull requets
The problem is that Python packages actually have the app in a subdirectory of the repo. e.g.
thirdpartyapp/
thirdpartyapp/setup.py
thirdpartyapp/thirdpartyapp/[all the code of interest is here]
Question
Can anyone shed light on how to best incorporate multiple 3rd party django apps into a django project, make changes to them/merge upstream changes.
I'd really appreciate a clean workflow, Its been one of the MAJOR barriers for me contributing back to the apps I use in Django.
Many thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用方法#1(pip/virtualenv)有一段时间了,我不觉得管理或开发第三方应用程序代码很复杂。
通过在
requirements.txt
中使用第三方应用程序外部存储库的完整路径,pip 会将这些应用程序安装在PROJECT_ROOT/env/src/application_dir
目录中,并具有所有优点任何版本控制系统。在那里,您可以开发、将更改拉到您自己的 fork 中或像通常的 git 子模块一样执行所有操作。如果您需要对第三方应用程序进行更改或应用一些补丁,而不需要将更改拉到外部存储库,但能够在生产中进行更改,我可以推荐您 fabriclassed 包。我是 fabric 工具的简单包装器,帮助您使用类组织 fab 文件几乎没有默认任务。例如,使用 FabricClassed,您可以使用自动生成的 *.diff 文件和命令来修补 virtualenv 目录中的任何依赖项:
I'm using method# 1 (pip/virtualenv) for a while and I don't feel way to manage or develop code of 3th party applications is complex.
In the way of using full paths to external repositories of 3th party applications in
requirements.txt
, pip will install these application inPROJECT_ROOT/env/src/application_dir
directory with all advantages of any version control system. There you can develop, pull changes to your own fork or do everything like with usual git submodules.If you need to make changes or apply some patches to 3th party application without pulling changes to the external repos but with ability get changes on production, I can recommend you fabriclassed package. I's simple wrapper for fabric tool helping to keep you fab files organized using classes with few default tasks. For example with fabriclassed you can patch anysome of dependencies inside virtualenv directory using automatically generated *.diff files with commands:
我将使用 git 子模块。这样做有很大的优势,因为如果您必须与其他人合作开发一个不属于您的主要存储库并且由其他人大量开发的应用程序,那么您的情况会更好。技术上并没有那么复杂。
I am going to use git submodules. there is a great deal of advantage doing that because if you have to collaborate on an app with others that is not part of your main repo and is being heavily developed by others, you are better off. it is not that complex technically.