Python私有pypi源注册自定义依赖包Windows

一、pypi 源

1、进入C盘,用户目录下,创建.pypirc文件(若报错没有文件名,则命名时为 .pypirc. ,保存后即为.pypirc)

2、配置私有源,上传库及用户名密码,可配置多个

[distutils]
index-servers =
    nexus, 
   
pypi

[nexus]
repository: 
username: 
password: 

[pypi]
username: 
password: 

二、开发包

2.1开发包结构

2.1.1 创建一个项目,项目名称需要为所上传依赖库中没有的名字

2.1.2文件夹中未具体实现代码

2.1.3__init__.py文件,from .文件名 import *,有几个文件from几次

2.1.4LICENSE,可参考 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/scanny

Permission 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 OTHER

DEALINGS IN
THE SOFTWARE.

 2.1.4README.md 项目简介

 2.1.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() 是自动发现根目录中的所有的子包。
    packages=setuptools.find_packages(),
    # 其他信息,这里写了使用 Python3,MIT License许可证,不依赖操作系统。
    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配置永久源

进入进入C盘,用户目录下,创建pip文件夹,新增pip.ini

[global]
timeout = 6000
index-url = 源
trusted-host = 信任

 pip install jcdependency==0.0.1

学习过程参考:Python搭建私有pypi源发包——pypi-server_pypiserver_XerCis的博客-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值