Is it possible to include subdirectories using dist utils (setup.py) as part of package data?

前端 未结 6 1577
礼貌的吻别
礼貌的吻别 2021-01-03 17:54

Basically my python package is setup like:

module
\\_examples
  \\_folder1
     \\_file1.py
     \\_file2.py
  \\_folder2
    \\_file1.py
    \\_file2.py
         


        
6条回答
  •  孤独总比滥情好
    2021-01-03 18:50

    Yes, you can include all the subdirectories.

    You just need to pass the below args to setup() function:

    packages=find_packages()
    
    include_package_data=True
    

    Along with this you need to have a MANIFEST.in file, with contents as

    recursive-include examples *
    

    This ensures all the files are recursively included.

    If you want to exclude certain extensions specifically, you can do so by specifying exclude array in the find_packages() argument.

    Ex: To exclude .txt files

    packages=find_packages(exclude=['.txt'])
    

    You can read more about include_package_data here.

    And also here is another link which tells you when you should not use include_package_data

提交回复
热议问题