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

后端 未结 4 1185
耶瑟儿~
耶瑟儿~ 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:18

    I created a function that gives me all the files that I need

    def find_files(directory, strip):
      """
      Using glob patterns in ``package_data`` that matches a directory can
      result in setuptools trying to install that directory as a file and
      the installation to fail.
    
      This function walks over the contents of *directory* and returns a list
      of only filenames found. The filenames will be stripped of the *strip*
      directory part.
      """
    
      result = []
      for root, dirs, files in os.walk(directory):
        for filename in files:
          filename = os.path.join(root, filename)
          result.append(os.path.relpath(filename, strip))
      return result
    

    And used that as arugment for package_data

提交回复
热议问题