[Distutils] How to install examples files?

Thomas Kluyver thomas at kluyver.me.uk
Wed Apr 11 04:04:19 EDT 2018


If I recall correctly, 'pip install --target' works by installing into a
temporary directory, then copying only the library part to the target
directory. So it will throw away any docs/examples/scripts that would be
installed outside the importable package.

On Tue, Apr 10, 2018, at 10:08 PM, Michael Schwager wrote:
> It looks like the following setup.py will do what I want, but it won't
> install the examples when I use --target:> 
> 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='mschwage at gmail.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',
>        ]
>    )],
> )
> 
> 
> On Sat, Apr 7, 2018 at 12:48 AM, Michael Schwager
> <mschwage at gmail.com> wrote:>> Hello,
>> I am trying to install a module with a package and also an examples
>> directory. How do I get my examples installed on users' machines into
>> a reasonable location, in a cross-platform kind of way?>> 
>>  I notice that a number of Python examples are installed in
>>  /usr/share (in Linux) or in
>>  <home>\AppData\Local\Programs\Python\Python36\Share on Windows 8.>> 
>> So in my setup.py, I have this:
>> 
>> 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 at example.com',
>>    license='Apache License 2.0',
>>    keywords='kivy drag-n-drop',
>>    packages=find_packages(exclude=[]),
>>    data_files=[('share/kivydnd-examples',
>>    ['examples/dndexample1.py',])],>> )
>> 
>> But when I try to install them on Linux, I don't see the
>> dndexample1.py file anywhere:>> 
>> python setup.py sdist
>> pip install --target=/home/schwager/lib/python dist/kivydnd-
>> 0.5.0.tar.gz --log /tmp/piplog>> 
>> (Note that I am using a different target for testing).
>> 
>> The piplog shows that it at least tried to do something with the
>> examples, but I can find a directory by that name anywhere in my home
>> directory:>> 
>> <snippet from log>
>>    creating /tmp/tmpirrDx8/share/kivydnd-examples
>>    copying examples/dndexample1.py -> /tmp/tmpirrDx8/share/kivydnd-
>>    examples>> 
>> Thanks!
>> -- 
>> -Mike Schwager
>> 
> 
> 
> 
> -- 
> -Mike Schwager
> _________________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20180411/a63d3e68/attachment.html>


More information about the Distutils-SIG mailing list