[英]Python package naming convention
I want to create some python packages and deploy them in my company, not on PyPi.我想创建一些 python 包并将它们部署在我的公司中,而不是在 PyPi 上。
I stumbled over the problem that one package name already existed.我偶然发现了一个包名已经存在的问题。 So instead of mypackage from our repo I installed a PyPi package.
因此,我安装了一个 PyPi 包,而不是我们 repo 中的 mypackage。
The obvious solution is to change the name of the package.显而易见的解决方案是更改包的名称。 However, if I don't put the package on PyPi, there are chances somebody will place another package with that name.
但是,如果我不将包放在 PyPi 上,则可能有人会放置另一个具有该名称的包。
I currently see two options.我目前看到两个选项。 Create a dummy package and put it on PyPi to reserve the name.
创建一个虚拟包并将其放在 PyPi 上以保留名称。 Or use something like a namespace.
或者使用类似名称空间的东西。
I read about PEP 423, which propose this idea, but it seems not to be agreed on.我读到了 PEP 423,它提出了这个想法,但似乎没有达成一致。
Is it anyway a good idea to use this?无论如何使用它是个好主意吗? How would I do it?
我该怎么做? company.package or company_package?
company.package 还是 company_package? Both are not confirming to PEP 8.
两者都没有确认 PEP 8。
Or is there another way?或者还有其他方法吗?
Don't squat on a name with an empty project.不要蹲在一个空项目的名字上。 You have already proven your project may have names that are somewhat common "one package name already existed" .
您已经证明您的项目可能具有一些常见的名称“一个包名称已经存在” 。
According to PEP541 (which was accepted ), Your project would be invalid and considered for removal.根据PEP541 (已被接受),您的项目将无效并考虑删除。
A project published on the Package Index meeting ANY of the following is considered invalid and will be removed from the Index:
在 Package Index 上发布的项目满足以下任何一项都被视为无效并将从索引中删除:
... ...
project is name squatting (package has no functionality or is empty); 项目被抢名(包没有功能或为空);
... ...
Instead, use a namespace as you already mentioned.相反,使用您已经提到的命名空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.