Skip to main content
 首页 » 编程设计

python之使用 PIP 安装 python 项目

2025年02月15日12lyj

我开发了一个聊天机器人项目,这是它的文件夹结构:

chatbot1: 
     __init__.py 
     __pycache__ 
     build 
     chatbot_script.egg-info 
     dist 
     MANIFEST.in  
     package_data.dat 
     README.rst 
     setup.cfg 
     setup.py 
     stanford-postagger-full-2015-04-20 
     main_chatbot.py 
     Female_chatbot.py 
     Male_chatbot.py 
     arabic_const.py 
     normalize.py 
     stem_const.py 
     stemming.py 

这是 setup.py:

from setuptools import setup, find_packages 
from codecs import open 
from os import path 
 
here = path.abspath(path.dirname(__file__)) 
with open(path.join(here, 'README.rst'), encoding='utf-8') as f: 
long_description = f.read() 
setup(name='chatbot_script', 
      version='1.2.0', 
      description='is a simple chatbot_script that uses simple matching ', 
      long_description=long_description,  
      url='https://github.com/pypi/chatbot_script',license='MIT', classifiers=    
      ['Development Status :: 3 - Alpha','Intended Audience :: Developers', 
        'Topic :: Software Development :: Build Tools', 
        'License :: OSI Approved :: MIT License', 
        'Programming Language :: Python :: 2', 
        'Programming Language :: Python :: 2.6', 
        'Programming Language :: Python :: 2.7', 
        'Programming Language :: Python :: 3', 
        'Programming Language :: Python :: 3.3', 
        'Programming Language :: Python :: 3.4', 
        'Programming Language :: Python :: 3.5',], 
      keywords='sample setuptools development', 
      packages=find_packages(), 
      install_requires=['peppercorn'], 
      extras_require={ 
             'dev': ['check-manifest'], 
             'test': ['coverage'],}, 
       package_data={ 
             'sample': ['package_data.dat'],}, 
       entry_points={ 
             'console_scripts': [ 
             'sample=sample:main',],},) 

我成功地将 chatbot_script 上传到 PyPi 和 testPyPi。但是当我下载它时,只有这些文件:

chatbot_script-1.2.0: 
    chatbot_script.egg-info 
    PKG-INFO 
    README.rst 
    setup.cfg 
    setup.py 

为什么我不能上传其他文件?

请您参考如下方法:

你的主要文件应该放在一个包装文件夹中

并且在您的 MANIFEST.in 中您可以包含/排除文件

例如

文件结构:

chatbot1: 
    MANIFEST.in  
    setup.cfg 
    setup.py 
    README.rst 
    chatbot1: 
        <package files> 

MANIFEST.in

recursive-include chatbot1 .* 
graft chatbot1 
prune chatbot1/unwanted_files