简体   繁体   English

在我的 python 项目中使用我自己的模块的最佳方式

[英]Best way to use my own module in my python project

I can't find an answer for this question.我找不到这个问题的答案。 Probably because I have not the good keywords.可能是因为我没有好的关键字。 If this is too basic, please just tell me where to look for.如果这太基本了,请告诉我在哪里寻找。

We have a Python project our_project in which I want to use a little Python module that I wrote : my_module .我们有一个 Python 项目our_project ,我想在其中使用我编写的一个小 Python 模块: my_module

our_project and my_module both have a git repo. our_projectmy_module都有一个 git repo。 I do not want to just put my_module.py into our_project/ because I want to keep improving my_module independently of our_project and be abble to use it in other projects.我不想只是将my_module.py放入our_project/因为我想独立于our_project不断改进my_module并且能够在其他项目中使用它。

I'm looking for a simple way to acces the most rencent version of my_module from our_project .我正在寻找一种简单的方法来访问 our_project 中最新版本的my_module (for me and my collaborators) (对于我和我的合作者)

What should I do ?我该怎么办 ?

I would suggest to create a library on another repo with its own setuptools configuration .我建议使用自己的setuptools 配置在另一个 repo 上创建一个库。

You can use pip's editable install to install it and also keep it updated while being develop.您可以使用pip 的可编辑安装来安装它,并在开发过程中保持更新。 It allows you to install dependencies directly from git repositories.它允许您直接从 git 存储库安装依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM