Data_files differences between pip and setuptools

I have a Python application that comes with a setup.py

script and can be installed via Pip or setuptools. However, I find some annoying differences between the two and I want to know the correct way to distribute data files.

import glob
import setuptools

long_description = ''
setuptools.setup(
  name='creator-build',
  version='0.0.3-dev',
  description='Meta Build System for Ninja',
  long_description=long_description,
  author='Niklas Rosenstein',
  author_email='rosensteinniklas@gmail.com',
  url='https://github.com/creator-build/creator',
  py_modules=['creator'],
  packages=setuptools.find_packages('.'),
  package_dir={'': '.'},
  data_files=[
    ('creator', glob.glob('creator/builtins/*.crunit')),
  ],
  scripts=['scripts/creator'],
  classifiers=[
    "Development Status :: 5 - Production/Stable",
    "Programming Language :: Python",
    "Intended Audience :: Developers",
    "Topic :: Utilities",
    "Topic :: Software Development :: Libraries",
    "Topic :: Software Development :: Libraries :: Python Modules",
    ],
  license="MIT",
)

      

  • Using Pip , the files specified in data_files

    go to the sys.prefix + '/creator'

    .
  • Using setuptools (i.e. running setup.py

    directly) the files end in lib/python3.4/site-packages/creator_build-0.0.3.dev0-py3.4.egg/creator

    .

Ideally , I would like the files to always be in the same location, regardless of the installation method. I would also prefer that the files be placed in the module directory (as setuptools does), but this can lead to problems if the package is installed as a Python Egg zip.

How can I make sure I data_files

end up in the same place with both installation methods? Also, how can I tell if my module was installed as a zipped Python Egg and how can I load the data files?

+3


source to share





All Articles