日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

centos7利用nexus离线搭建局域网pypi源

發布時間:2025/3/11 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 centos7利用nexus离线搭建局域网pypi源 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

centos7利用nexus離線搭建局域網pypi源

1、官網下載nexus oss版本

https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.29.2-02-unix.tar.gz

[root@localhost bin]# wget https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.29.2-02-unix.tar.gz

2、解壓nexus至本地目錄

[root@localhost bin]# tar -zxvf nexus-3.29.2-02-unix.tar.gz

3、啟動nexus服務 ,如果提示JAVA_HOME沒有設置,請安裝java的JDK環境

[root@localhost bin]# cd /opt/nexus-3.29.2-02/bin/ [root@localhost bin]# ./nexus start WARNING: ************************************************************ WARNING: Detected execution as "root" user. This is NOT recommended! WARNING: ************************************************************ Starting nexus

4、創建pypi倉庫


hosted – 宿主倉庫,用戶可以 deploy 到 hosted 中,也可以手工上傳構件到 hosted 里,在 central repository 是獲取不到的,就需要手工上傳到hosted里


group – 倉庫組,將上述多個倉庫聚合,對用戶暴露統一的地址

5、上傳pypi包

1)通過web頁面上傳(適合包比較少時)

2)命令行上傳,需要先安裝twine(適合批量上傳)
pip3 install twine twine upload --repository-url twine upload --repository-url http://10.4.7.23:8081/repository/pypi-hosted/ -u admin -p admin123 /opt/pypi/* //要上傳的路徑為http://10.4.7.23:8081/repository/pypi-hosted/ 登錄用戶名為admin 密碼為admin123pypi包所在的路徑為/opt/pypi/
3)twine 各參數含義
$ twine upload -h usage: twine upload [-h] [-r REPOSITORY] [--repository-url REPOSITORY_URL][-s] [--sign-with SIGN_WITH] [-i IDENTITY] [-u USERNAME][-p PASSWORD] [-c COMMENT] [--config-file CONFIG_FILE][--skip-existing] [--cert path] [--client-cert path][--verbose] [--disable-progress-bar]dist [dist ...]positional arguments:dist The distribution files to upload to the repository(package index). Usually dist/* . May additionallycontain a .asc file to include an existing signaturewith the file upload.optional arguments:-h, --help show this help message and exit-r REPOSITORY, --repository REPOSITORYThe repository (package index) to upload the packageto. Should be a section in the config file (default:pypi). (Can also be set via TWINE_REPOSITORYenvironment variable.)--repository-url REPOSITORY_URLThe repository (package index) URL to upload thepackage to. This overrides --repository. (Can also beset via TWINE_REPOSITORY_URL environment variable.)-s, --sign Sign files to upload using GPG.--sign-with SIGN_WITHGPG program used to sign uploads (default: gpg).-i IDENTITY, --identity IDENTITYGPG identity used to sign files.-u USERNAME, --username USERNAMEThe username to authenticate to the repository(package index) as. (Can also be set viaTWINE_USERNAME environment variable.)-p PASSWORD, --password PASSWORDThe password to authenticate to the repository(package index) with. (Can also be set viaTWINE_PASSWORD environment variable.)--non-interactive Do not interactively prompt for username/passwordif the required credentials are missing. (Can alsobe set via TWINE_NON_INTERACTIVE environmentvariable.)-c COMMENT, --comment COMMENTThe comment to include with the distribution file.--config-file CONFIG_FILEThe .pypirc config file to use.--skip-existing Continue uploading files if one already exists. (Onlyvalid when uploading to PyPI. Other implementationsmay not support this.)--cert path Path to alternate CA bundle (can also be set viaTWINE_CERT environment variable).--client-cert path Path to SSL client certificate, a single filecontaining the private key and the certificate in PEMformat.--verbose Show verbose output.--disable-progress-barDisable the progress bar.

6、上傳后結果

7、pip使用本地源進行安裝

[root@localhost bin]# pip install requests -i http://10.4.7.23:8081/repository/pypi-group/simple --trusted-host 10.4.7.23 //-i 指定pypi源 Collecting requestsDownloading http://10.4.7.23:8081/repository/pypi-group/packages/requests/2.25.1/requests-2.25.1-py2.py3-none-any.whl (61kB)100% |████████████████████████████████| 61kB 6.3MB/s Collecting certifi>=2017.4.17 (from requests)Downloading http://10.4.7.23:8081/repository/pypi-group/packages/certifi/2020.12.5/certifi-2020.12.5-py2.py3-none-any.whl (147kB)

總結

以上是生活随笔為你收集整理的centos7利用nexus离线搭建局域网pypi源的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。