Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make pip write a default config file when installing a python package? [duplicate]

Tags:

python

I'm packaging an in-house python app. My dir structure is something like:

/config
    \-- config.yaml
/app
    \-- ... (python files here...)

I've created a MANIFEST.in containing:

include config/*.yaml

When I extract the tarball created after running ./setup.py sdist, there are 2 directories, config (containing my config.yaml file) and app containing my package. However, when I pip install my app, only the python code is installed in dist-packages.

How can I make pip/setuptools copy config/config.yaml to /etc/xdg/app/ when I run pip install app?

Alternatively how can I at least make the config.yaml file end up somewhere on the filesystem so I can copy it where I want it later (e.g. /usr/share or somewhere - I don't care where it ends up after being installed)?

like image 269
jbrown Avatar asked Apr 24 '26 00:04

jbrown


1 Answers

The docs section Installing Additional Files Doc suggests:

You can set the relative real path into data_files.

setup(...,
          data_files=[...,
                      ('/etc/xdg/app/', ['config/config.yaml'])]
     )

Obs: "Note that you can specify the directory names where the data files will be installed, but you cannot rename the data files themselves."

like image 136
jcfaracco Avatar answered Apr 26 '26 16:04

jcfaracco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!