7

I am trying to creat a Python module that has a utility command line program. I am using setuptools and Python3. I have the utility program being created just fine with the entry_points field of setup but I want to include a default configuration file and I want to place it in the user's home .config directory.

Here is my package directory layout:

⤷ tree
.
├── config
│   └── spt.config
├── README.org
├── utilityTool
│   ├── __init__.py
│   ├── file1.py
│   ├── file2.py
│   └── tools
│       ├── commandline.py
│       ├── __init__.py
└── setup.py
└── MANIFEST.in

And here is my setup.py:

import utilityTool
from setuptools import setup, find_packages
import os

setup(name='utilityTool',
      version=utilityTool.__version__,
      description='A utility tool',
      long_description='Longer package description',
      classifiers=[
          'Development Status :: 3 - Alpha',
          'License :: OSI Approved :: MIT License',
          'Programming Language :: Python :: 3',
          'Topic :: Software Development :: Build Tools',
          'Topic :: Utilities',
      ],
      keywords='utility tool',
      license='MIT',
      packages=find_packages(),
      install_requires=['yapsy', 'argparse'],
      include_package_data=True,
      zip_safe=False,
      entry_points={'console_scripts':['spt = utilityTool.tools.commandline:main']},
      data_files=[('{}/.config/spt/'.format(os.environ['HOME']),['config/spt.config'])],
)

In my MANIFEST.in file, I just have include config/spt.config

I am using a virtual environment just so I don't screw something up on my system also.

To install my package, I run pip install -e . from the package directory.

Like I said this installs my utility tool, spt, just fine but I cannot find where or if my config file that I have in the data_files list gets copied anywhere. It isn't in my home directory because I ran find -type f -name "spt.config" and no other results showed up.

If I run python3 setup.py install it does install to the correct place though.

Is the post install script required like in this answer? I figured this is something that setuptools should be able to do, but I thought I read somewhere that this was a feature of setuptools too. It seems like there is just something I have to do to make pip recognize it.

Thanks for any pointers or links to example projects that do similar things.

Jesse
  • 901
  • 1
  • 9
  • 25

0 Answers0