Python distutils error: “[directory]… doesn't exist or not a regular file”

后端 未结 4 1184
耶瑟儿~
耶瑟儿~ 2021-02-05 03:54

Let\'s take the following project layout:

$ ls -R .
.:
package  setup.py

./package:
__init__.py  dir  file.dat  module.py

./package/dir:
tool1.dat  tool2.dat
<         


        
4条回答
  •  天命终不由人
    2021-02-05 04:07

    In your package_data, your '*' glob will match package/dir itself, and try to copy that dir as a file, resulting in a failure. Find a glob that won't match the directory package/dir, rewriting your setup.py along these lines:

    from distutils.core import setup
    
    setup(name='pyproj',
          version='0.1',
    
          packages=[
              'package',
          ],
          package_data={
              'package': [
                  '*.dat',
                  'dir/*'
              ],
          },
         )
    

    Given your example, that's just changing '*' to '*.dat', although you'd probably need to refine your glob more than that, just ensure it won't match 'dir'

提交回复
热议问题