2 回答

TA貢獻2011條經驗 獲得超2個贊
我嘗試了幾次迭代但沒有成功。
Often packages will need to depend on files which are not .py files: e.g. images, data tables, documentation, etc. Those files need special treatment in order for setuptools to handle them correctly.
The mechanism that provides this is the MANIFEST.in file. This is relatively quite simple: MANIFEST.in is really just a list of relative file paths specifying files or globs to include.:
include README.rst
include docs/*.txt
include funniest/data.json
In order for these files to be copied at install time to the package’s folder inside site-packages, you’ll need to supply include_package_data=True to the setup() function.
超級容易做到,實際上只需將 MANIFEST.in 包含在與 setup.py 相同的目錄中,并且根據文檔,you’ll need to supply include_package_data=True to the setup() function.

TA貢獻1801條經驗 獲得超16個贊
#sql_file_picker.py -- 將文件提供給 setup.py 的腳本
import glob
class FilePicker:
? ? def __init__(self):
? ? ? ? pass
? ? def sql_file_picker(self):
? ? ? ? sql_files = []
? ? ? ? directories = glob.glob('master_sql_folder\\**\\')
? ? ? ? for directory in directories:
? ? ? ? ? ? files = glob.glob(directory + '*.sql')
? ? ? ? ? ? if len(files) != 0:
? ? ? ? ? ? ? ? sql_files.append((directory, files))
? ? ? ? return sql_files
在setup.py中
from wrapper_scripts.sql_file_picker import FilePicker
from setuptools import setup
setup(
? ? name='XXXXXXXXX',
? ? version='X.X.X',
? ? packages=['app', 'wrapper_scripts'],
? ? url='',
? ? license='',
? ? author='',
? ? author_email='',
? ? description='XXXXXXXXXXXXX',
? ? data_files=FilePicker().sql_file_picker()
)
添加回答
舉報