使用pip安装软件包不会创建我的所有文件

时间:2018-04-05 00:01:14

标签: python pip setuptools

Stackness的交换你好Denizens,

我有一个我试图分发的图书馆。我创建了一个setup.py并运行

python setup.py sdist

我看到它在dist /目录下创建了一个.tar.gz文件,其中包含我想要的所有文件和文件夹。但是,当我在Windows 8盒子(运行Python 3.6.5rc1)上安装它时,我不能获得任何文件 - 只有kivydnd-0.5.dist-info目录。当我在Linux(运行Fedora 26,Python 2.7)上安装它时,我确实看到了包的文件,但我没有看到examples目录。

你能告诉我我做错了什么吗?

setup.py在这里:

from setuptools import setup, find_packages

setup(
    name='kivydnd',
    version='0.5',
    description='Kivy Drag-n-Drop for Widgets',
    url='https://github.com/GreyGnome/KivyDnD',
    author='GreyGnome',
    author_email='myemail@example.com',
    license='Apache License 2.0',
    #packages=find_packages('kivydnd'),
    packages=['kivydnd'],
    zip_safe=False,
    scripts=[
        'examples/dndexample1.py',
        'examples/dndexample2.py',
        'examples/dndexample3.py',
        'examples/dndexample_copy_draggable.py',
        'examples/dndexample_drop_groups.py',
        'examples/dndexample_relative_layout.py',
        'examples/example_base_classes.py',
        'examples/example_base_classes.pyc',
        ]
)

在我的开发目录中,执行:

    python setup.py sdist

结果.tar.gz看起来像这样;这也将反映我正在进行开发的目录的结构:

kivydnd-0.5/
kivydnd-0.5/setup.py
kivydnd-0.5/PKG-INFO
kivydnd-0.5/examples/
kivydnd-0.5/examples/example_base_classes.pyc
kivydnd-0.5/examples/dndexample1.py
kivydnd-0.5/examples/dndexample_copy_draggable.py
kivydnd-0.5/examples/dndexample3.py
kivydnd-0.5/examples/dndexample_relative_layout.py
kivydnd-0.5/examples/dndexample_drop_groups.py
kivydnd-0.5/examples/dndexample2.py
kivydnd-0.5/examples/example_base_classes.py
kivydnd-0.5/README.md
kivydnd-0.5/RELEASE_NOTES.md
kivydnd-0.5/LICENSE
kivydnd-0.5/kivydnd.egg-info/
kivydnd-0.5/kivydnd.egg-info/top_level.txt
kivydnd-0.5/kivydnd.egg-info/PKG-INFO
kivydnd-0.5/kivydnd.egg-info/not-zip-safe
kivydnd-0.5/kivydnd.egg-info/SOURCES.txt
kivydnd-0.5/kivydnd.egg-info/dependency_links.txt
kivydnd-0.5/setup.cfg
kivydnd-0.5/MANIFEST.in
kivydnd-0.5/kivydnd/
kivydnd-0.5/kivydnd/dnd_storage_singletons.py
kivydnd-0.5/kivydnd/debug_print.py
kivydnd-0.5/kivydnd/__init__.py
kivydnd-0.5/kivydnd/dropdestination.py
kivydnd-0.5/kivydnd/dragndropwidget.py

以下是Windows 8上发生的情况:

F:\>pip install kivydnd-0.5.tar.gz
Processing f:\kivydnd-0.5.tar.gz
Building wheels for collected packages: kivydnd
  Running setup.py bdist_wheel for kivydnd ... done
  Stored in directory: C:\Users\schwager\AppData\Local\pip\Cache\wheels\9a\11\cd
\68bfb0d34c7b73ec7e25c6f9c40c5926377747b5951ac2e6ab
Successfully built kivydnd
Installing collected packages: kivydnd
Successfully installed kivydnd-0.5
` c:\users\schwager\python\Lib\site-packages\kivydnd-0.5.dist-info\` I have:
        DESCRIPTION.rst
        INSTALLER
        METADATA
        metadata.json
        RECORD
        top_level.txt
        WHEEL

以下是Linux上发生的事情:

pip install --target=/home/schwager/lib/python kivydnd-0.5.tar.gz 
Processing ./kivydnd-0.5.tar.gz
Installing collected packages: kivydnd
  Running setup.py install for kivydnd ... done
Successfully installed kivydnd-0.5
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.                                                                                                   
 $ ls /home/schwager/lib/python
kivydnd  kivydnd-0.5-py2.7.egg-info
 $ ls -R /home/schwager/lib/python
/home/schwager/lib/python:
kivydnd  kivydnd-0.5-py2.7.egg-info

/home/schwager/lib/python/kivydnd:
debug_print.py   dnd_storage_singletons.py   dragndropwidget.py   dropdestination.py   __init__.py
debug_print.pyc  dnd_storage_singletons.pyc  dragndropwidget.pyc  dropdestination.pyc  __init__.pyc

/home/schwager/lib/python/kivydnd-0.5-py2.7.egg-info:
dependency_links.txt  installed-files.txt  not-zip-safe  PKG-INFO  SOURCES.txt  top_level.txt

1 个答案:

答案 0 :(得分:0)

我看来我的setup.py应该是这样的。该软件包将安装在Python的site-packages目录下,<path-to-share>/kivydnd-examples下的示例。

from setuptools import setup, find_packages
from codecs import open
from os import path

with open(path.join('.', 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='kivydnd',
    version='0.5.0',
    description='Kivy Drag-n-Drop for Widgets',
    long_description=long_description,
    long_description_content_type='text/markdown',
    url='https://github.com/GreyGnome/KivyDnD',
    author='GreyGnome',
    author_email='myemail@example.com',
    license='Apache License 2.0',
    keywords='kivy drag-n-drop',
    packages=find_packages(exclude=[]),
    data_files=[('share/kivydnd-examples',
        [
            'examples/dndexample1.py',
            'examples/dndexample2.py',
            'examples/dndexample3.py',
            'examples/dndexample_copy_draggable.py',
            'examples/dndexample_drop_groups.py',
            'examples/dndexample_relative_layout.py',
            'examples/example_base_classes.py',
            'examples/example_base_classes.pyc',
        ]
    )],
)