python - 让 tox/pip 识别使用 Jenkins 部署的诗歌包的私有工件
问题描述
我有一个 python 包,我想使用 Jenkins 和 tox 进行测试和构建。但是,它取决于我们私人神器中的一个包。尽管诗歌正确地选择了它,但当 tox 启动时(并使用 pip 覆盖诗歌来安装依赖项),它找不到包。
我的诗歌锁定文件有
reference = "snakepit"
type = "legacy"
url = "https://our private artifactory
我的 Jenkinsfile 设置POETRY_HTTP_BASIC_PYPI_USERNAME
并POETRY_HTTP_BASIC_PYPI_PASSWORD
允许在没有我的凭据的锁定文件中的 url 的情况下安装诗歌。
经过一番搜索,我似乎需要在 pyproject.toml 中扩展 legacy_tox_ini。现在看起来像:
legacy_tox_ini = """
[tox]
isolated_build = true
envlist = py36,py37,py38
indexserver =
default = https://pypi.python.org/simple
ourartifactory = https://{env:POETRY_HTTP_BASIC_PYPI_USERNAME}:{env:POETRY_HTTP_BASIC_PYPI_PASSWORD}@our artifactory url
[testenv]
deps =
pytest
pytest-cov
setenv =
SOME_ENV={env:SOME_ENV}
commands =
pytest tests
我还测试了将 :ourartifactory:problempackage 添加到 deps ,但这也无济于事。
如何让 pip 在此设置中识别私有工件?
解决方案
最后整个 indexserver 和 deps 是不必要的,一个简单的
envVar(key: 'PIP_CONFIG_FILE', value: "/pypi-artifactory/pip.conf")
在 Jenkinsfile 中就足够了。当然,这需要您的 docker 映像具有正确的 pip.conf。
推荐阅读
- excel - 我的 Excel“运行时错误 91:对象变量或未设置块变量”
- c - cc 编译器和缓存
- css - 布局在 nuxt.js 中重叠
- firebase - firestore 是否支持 where 子句中的 BETWEEN 条件
- typo3 - TYPO3 8.7:自定义字段未从自定义扩展添加到 tt_content 表中
- java - 如何在 docker 上管理 Java 和 Python 应用程序?
- javascript - 将 bootstrap-vue 模式附加到应用程序模板
- php - 会话超时时如何配置重定向 URL - Laravel 5.8?
- excel - 使用自定义格式将 Excel 中的行转换为列
- python - torch.matmul和python内置@运算符做矩阵乘法的区别