Mike S
Mike S

Reputation: 1361

Install a package using pip does not create all my files

Hello Denizens of the Exchange of Stackness,

I have a library that I'm trying to distribute. I have created a setup.py and run

python setup.py sdist

I see that it creates a .tar.gz file under the dist/ directory, which has all my files and folders that I want in it. However, when I install it on a Windows 8 box (running Python 3.6.5rc1), I don't get any files- only a kivydnd-0.5.dist-info directory. When I install it on Linux (running Fedora 26, Python 2.7), I do see the package's files but I don't see the examples directory.

Can you tell me what I'm doing wrong?

The setup.py is here:

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='[email protected]',
    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',
        ]
)

In my development directory, I perform:

    python setup.py sdist

The resulting .tar.gz looks like this; this will also reflect the structure of the directory where I'm doing my development:

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

Here is what happens on 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

Here is what happens on 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

Upvotes: 0

Views: 2270

Answers (1)

Mike S
Mike S

Reputation: 1361

I appears that my setup.py should look like this. The package will get installed under Python's site-packages directory, the examples under <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='[email protected]',
    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',
        ]
    )],
)

Upvotes: 1

Related Questions