When making a Python distribution it is often necessary to add some files to the package. The most common example of this is when you want to add a file to a package via thepip install
command installationPython
The package will be created in the
The default configuration file is automatically added to directories such as /etc/, which allows Python to work as soon as it's installed, and also provides a sample configuration for users to refer to.
consultation Installing Additional Files
If you use thesetuptools
In the file, you can find a list of all the files that can be accessed through the data_files
The configuration item configures additional files for the distribution package in the format: (<installation location>, [<file1>, <file2>, ...])
# from setuptools import setup setup(..., data_files=[('bitmaps', ['bm/', 'bm/']), ('config', ['cfg/'])], )
The above example <Installation Location> uses a relative path, which will be used during installation based on the installation prefix such as
(system-level installation) andsite.USER_BASE
(user-level installation) is interpreted as an absolute path. While it is possible to use absolute paths, it is not recommended because it is not compatible with wheel-formatted distributions. File paths are also relative paths, starting at
The directory where the file is located, i.e. the root directory of the project, note that the file cannot be renamed.
If you use thepbr To help with packaging, declare additional files in a similar way to the above, using the
fit as follows
[files] packages = pbr data_files = etc/pbr = etc/* etc/init =
summarize
The above is a small introduction to the Python distribution package to add additional files in the method, I hope to help you, if you have any questions please leave me a message, I will reply to you in a timely manner. Here also thank you very much for your support of my website!
If you find this article helpful, please feel free to reprint it, and please note the source, thank you!