Python私有pypi源注冊自定義依賴包Windows詳解
一、pypi 源
1. 進(jìn)入C盤,用戶目錄下,創(chuàng)建.pypirc文件(若報錯沒有文件名,則命名時為 .pypirc. ,保存后即為.pypirc)
2. 配置私有源,上傳庫及用戶名密碼,可配置多個
[distutils]
index-servers =
nexus,
pypi
[nexus]
repository:
username:
password:
[pypi]
username:
password: 二、開發(fā)包
2.1開發(fā)包結(jié)構(gòu)

2.1.1 創(chuàng)建一個項目,項目名稱需要為所上傳依賴庫中沒有的名字
2.1.2 文件夾中未具體實現(xiàn)代碼
2.1.3 __init__.py文件,from .文件名 import *,有幾個文件from幾次
2.1.4 LICENSE,可參考 Choose an open source licenseChoose an open source license | Choose a LicenseChoose an open source license
The MIT License (MIT)
Copyright (c) 2013 Steve Canny, https://github.com/scannyPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHERDEALINGS IN
THE SOFTWARE.
2.1.5 README.md 項目簡介
2.1.6 setup.py
import setuptools
setuptools.setup(
# 項目的名稱
name="",
# 項目的版本
version="0.0.1",
# 項目的作者
author="",
# 作者的郵箱
author_email="",
# 項目描述
description="",
# 項目的長描述
long_description="",
# 以哪種文本格式顯示長描述
long_description_content_type="text/markdown", # 所需要的依賴
install_requires=[
'pymongo'
],
# 項目中包含的子包,find_packages() 是自動發(fā)現(xiàn)根目錄中的所有的子包。
packages=setuptools.find_packages(),
# 其他信息,這里寫了使用 Python3,MIT License許可證,不依賴操作系統(tǒng)。
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
三、生成包并上傳
3.1生成 dist 目錄
pip install wheel python setup.py sdist bdist_wheel
生成build、dist、xxx.egg.info
3.2上傳
pip install twine twine upload dist/* -r nexus(nexus為配置文件中名稱)
四、安裝
4.1配置臨時源
pip install jcdependency==0.0.1 -i 源 --trusted-host 信任 或 pip install jcdependency==0.0.1 -i 源
4.2配置永久源
進(jìn)入進(jìn)入C盤,用戶目錄下,創(chuàng)建pip文件夾,新增pip.ini
[global] timeout = 6000 index-url = 源 trusted-host = 信任 pip install jcdependency==0.0.1
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python實現(xiàn)刪除列表首元素的多種方式總結(jié)
在Python中,處理列表的操作是日常開發(fā)中不可避免的任務(wù)之一,其中,刪除列表中的元素是一個常見的需求,本文為大家整理了Python中刪除列表中的第一個元素的多種方法,需要的可以參考下2023-12-12
Python通過zookeeper實現(xiàn)分布式服務(wù)代碼解析
這篇文章主要介紹了Python通過zookeeper實現(xiàn)分布式服務(wù)代碼解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-07-07
Python中的進(jìn)程操作模塊(multiprocess.process)
這篇文章介紹了Python中的進(jìn)程操作模塊(multiprocess.process),文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-05-05
利用Python代碼實現(xiàn)數(shù)據(jù)可視化的5種方法詳解
淺談Scrapy框架普通反爬蟲機(jī)制的應(yīng)對策略

