- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在某处读到,如果您为专有工作制作内部 Python 包,您仍应在 PyPi 上注册名称以避免 future 潜在的依赖性问题。
如何在不公开发布我的代码的情况下执行此操作?这个包包含在我的工作中内部使用的代码。我应该使用我想要保留的名称制作一个空的 python 包并将其上传到 PyPi 吗?然后在工作时使用 git 而不是 PyPi 安装我的包?
上传一个空包似乎是一件愚蠢的事情,只会惹恼其他人。但是我找不到只注册名称的方法。
最佳答案
Since the register
command is deprecated and not supported anymore ,您将必须执行以下步骤:
setup.py
,包含空包列表、初始版本和填充的元数据这样,包名称将保留给您,因为您现在已注册为它的所有者,但搜索包将不会产生任何结果,任何直接访问都将导致 404。
假设您要保留包名称 foo
。步骤:
创建一个新的 setup.py
stub 。确保 packages
列表是空的,这样你就不会不小心上传一些代码:
from setuptools import setup
setup(
name='foo',
version='0.0.1',
description='',
long_description='',
url='https://www.example.com',
author='me',
author_email='me@example.com',
packages=[],
classifiers=['Development Status :: 1 - Planning'],
)
构建并上传包:
$ python setup.py bdist_wheel upload
running bdist_wheel
running build
...
running upload
Submitting /tmp/foo/dist/foo-0.0.1-py3-none-any.whl to https://upload.pypi.org/legacy/
Server response (200): OK
删除上传的轮子:转到项目页面https://pypi.python.org/pypi?%3Aaction=pkg_edit&name=foo
,在这里您可以找到上传的列表wheels - 选择你上传的一个,然后按 Remove
。
现在您已经保留了项目名称,因为没有人能够上传包 foo
除非您授予他们 PyPI 的管理员权限:
$ python setup.py bdist_wheel upload
running bdist_wheel
running build
...
running upload
Submitting /tmp/foo/dist/foo-0.0.2-py3-none-any.whl to https://upload.pypi.org/legacy/
Upload failed (403): The user 'bar' is not allowed to upload to project 'foo'. See https://pypi.org/help#project-name for more information.
error: Upload failed (403): The user 'bar' is not allowed to upload to project 'foo'. See https://pypi.org/help#project-name for more information.
$ twine upload dist/foo-0.0.2-py3-none-any.whl
Uploading distributions to https://upload.pypi.org/legacy/
Uploading foo-0.0.2-py3-none-any.whl
HTTPError: 403 Client Error: The user 'bar' is not allowed to
upload to project 'foo'. See https://pypi.org/help#project-name for
more information. for url: https://upload.pypi.org/legacy/
任何直接访问尝试都将以 404 结束:
$ curl -I https://pypi.python.org/pypi/foo
HTTP/2 404
通过 pip
安装将按预期失败:
$ pip install foo
Collecting foo
Could not find a version that satisfies the requirement foo (from versions: )
No matching distribution found for foo
请注意,包索引名称保留 ( PEP 541
) 上有一个 PEP,它定义了包索引中无法访问、已放弃和无效的项目。在 Name conflict resolution for active projects 部分,它指出:
None of the following qualify for package name ownership transfer:
...
User A owns a project X outside the Package Index. User B creates a package under the name X on the Index. After some time, User A wants to publish project X on the Index but realizes name is taken. This is true even if User A's project X gains notability and User B's project X is not notable.
因此,尽管 PEP 确认没有人可以从您那里拿走一个活跃项目的名称,但在不活跃项目的情况下并不能保证这一点,这是防止域名抢注的一个很好的对策.我对此的理解是,如果你现在保留一个名称而不开发任何东西,而在未来,一个开源项目以该名称出现并变得非常流行,你可以打赌项目所有者的权利将被剥夺。
另外,请注意,空包或没有功能的包可能会被视为无效包并被删除:
A project published on the Package Index meeting ANY of the following is considered invalid and will be removed from the Index:
...
project is name squatting (package has no functionality or is empty);
project name, description, or content violates the Code of Conduct; or
project is abusing the Package Index for purposes it was not intended.
关于python - 在 Pypi 上注册一个内部包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47676721/
通过终端,您可以使用命令 - “SetFile -a B 文件名” 以编程方式,我认为我应该通过[[NSFileManager defaultManager] createDirectoryAtPat
嗨,正在尝试书中的一些示例:Practical Graph mining with R对于子图挖掘: library(subgraphMining) library(igraph) graph1 =
代码中的相同问题: class Foo { int getIntProperty () { ... } CustomObject getObjectProperty () { ... }
所以这可能是一个愚蠢的问题,但它已经困扰我一段时间了。 使用 React,我创建了两个组件(Buttons.js 和 Message.js),每个组件都有一个导出。但是,现在我希望将这两个组件用作 n
从今天早上开始,我发现我无法再从某个范围安装任何 NPM 包(或任何具有依赖项的包)。例如,如果我输入 npm i webpack 我会收到以下错误... npm ERR! code E401 npm
我在这里搜索过,Angular 2, @ngtools/webpack, AOT ,但对我不起作用。我运行了 npm install 命令。我正在做的是创建一个新的 Angular 2 项目。当我运行
情况: 我有一个 Swift 包,将其命名为 lib。 lib 位于其自己的存储库中。在lib的仓库中,有一堆本地包;也就是说,这些包是在 lib 中定义的,使用本地路径依赖格式 .package(p
我想在工作中学习和使用nodejs,但是在使用 de npm 命令安装模块/包时遇到网络问题。我是否可以使用我的家用计算机构建完整的 Node js 包,然后将其安装在另一台计算机(我的工作场所计算机
我需要将一些 .tar.bz2 格式的非 Python 包转换为 Anaconda/miniConda .egg 文件并安装它们。为此,我需要一个适用于 Windows 的 bld.bat 文件。互联
我需要共享库文件 libthrift-0.9.3.so 作为其他包的依赖项。我在构建 thrift-0.9.3 包时看到编译问题(我确实从 https://thrift.apache.org/down
我尝试在 R 版本 3.5.0 中安装“arcgisbinding”包。但是我失败了,得到以下错误和警告。 Installing package into ‘C:/Users/Lenovo/Docum
我尝试在 R 版本 3.5.0 中安装“arcgisbinding”包。但是我失败了,得到以下错误和警告。 Installing package into ‘C:/Users/Lenovo/Docum
我试图在 flutter 中测试这个应用程序,但我无法运行该应用程序,因为出现此错误“名称‘Page’在库‘package:burn_off/widgets/page.dart’和‘package’中
试图理解和学习如何编写包...用我一直使用的东西进行测试,记录... 您能帮我理解为什么“日志”变量不起作用...并且屏幕上没有日志记录吗? 谢谢! 主要文件: #!/opt/local/bin/py
我尝试运行此使用 Google 云的代码。 import signal import sys from google.cloud import language, exceptions # creat
我想知道是否有人找到了一个很好的 R 包来分析眼动追踪数据? 我遇到了 eyetrackR,但据我所知,没有可用的英文支持文档: http://read.psych.uni-potsdam.de/pm
我正在 R 上制作一个包。我有两个函数共享一个变量(全局)。 如何将其导入到包中? 例如, m<-0 f<-function() { m <- m+1 } g<-function() { m <- m
我用 C 为 Lua 编写了很多模块。每个模块都包含一个 Lua 用户数据类型,我像这样加载和使用它们: A = require("A") B = require("B") a = A.new(3,{
我正在尝试在 R 中的 Ubuntu 上安装 xlsx 包,以便使用允许在 R 中插入链接然后将它们导出到 Excel 的功能。 话虽如此,我根本无法安装该软件包。 显然它必须与 rJava 一起使用
我想在 Haskell 中做一些蒙特卡洛分析。我希望能够编写这样的代码: do n <- poisson lambda xs <- replicateM n $ normal mu sigma
我是一名优秀的程序员,十分优秀!