How can I include package_data without a MANIFEST.in file?

后端 未结 2 1475
名媛妹妹
名媛妹妹 2020-12-03 04:23

How can I include package_data for sdist without a MANIFEST.in file?

My setup.py looks like this:

import setuptools

setupt         


        
相关标签:
2条回答
  • 2020-12-03 05:00

    I had the same issue and fixed it be removing :

    include_package_data=True
    
    0 讨论(0)
  • 2020-12-03 05:21

    TL;DR: The keys in the package_data dictionaries are packages; the values are lists of globs. '' is not a valid name for any Python package.

    If you want to have bar.txt be installed next to the __init__.py of package foo, use

     package_data={'foo': ['bar.txt']}
    

    I have the layout:

    foo/
            __init__.py
            bar.txt
    setup.py
    

    Now, if foo is a package like above, do:

    import setuptools
    
    setuptools.setup(
        name='foo',
        version='2015.3',
        license='commercial',
        packages=setuptools.find_packages(),
        package_data={'foo': ['bar.txt']},
    )
    

    And after python setup.py sdist, I check the contents of dist/foo-2015.3.tar.gz

    % tar tfz dist/foo-2015.3.tar.gz
    ...
    foo-2015.3/foo/bar.txt
    ...
    

    However, if I run your setup.py with package_data={'': ['foo/bar.txt']}, I can concur that the foo/bar.txt will not be added to the source distribution, except if the foo-2015.3.egg-info/SOURCES.txt already has the line for foo/bar.txt - in that case the file will pop up in the source distribution too

    No manifest was used; the setuptools version was 3.6 (I deliberately installed the same, old version that you were using):

    >>> import setuptools
    >>> setuptools.__version__
    '3.6'
    

    The behaviour above also works in standard distutils: 2.6 Installing package data of the "legacy" distutils documentation; with a comment for 2.7, 3.1:

    Changed in version [2.7, 3.1]: All the files that match package_data will be added to the MANIFEST file if no template is provided.

    0 讨论(0)
提交回复
热议问题