Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip setup.py does not copy extra data files to destination despite they are present in the source package

In my package I need to deploy a number of auxillary js and json files.

In my MANIFEST.IN file I specified:

include config/*.json
include bin/*.js
include lib/*.js

After I run the python setup.py sdist, I use tar txvf dist/mypackage-1.2.1.tar.gz to check the content. I can see the json and js files.

However when I run pip install /path/to/sdist/file/mypackage-1.2.1.tar.gz, it only installs python files to the site-packages/mypackage location. What do I need to do to copy the other files over?

import os
import shutil
import subprocess
import json

from setuptools import setup
from setuptools.command.install import install
from distutils.sysconfig import get_python_lib


class Installer(install):

    def run(self):
        install.run(self)
        install_folder = '%s/mypackage' % get_python_lib()
        # Just to check what I got
        for n, ds, fs in os.walk(install_folder):
            print n, d, fs


setup(name='mypackage',
      version='1.2.1',
      description='mypackage',
      url='https://github.com/myrepo/mypackage',
      author='me',
      author_email='[email protected]',
      license='MIT',
      packages=['mypackage'],
      package_data={'js': ['config/*json', 'lib/*js', 'bin/*js']},
      include_package_data=True,
      cmdclass={'install': Installer})

And here is the output from pip setup.py sdist

$ python setup.py sdist                                                                                                                                
running sdist
running egg_info
writing mypackage.egg-info/PKG-INFO
writing top-level names to mypackage.egg-info/top_level.txt
writing dependency_links to mypackage.egg-info/dependency_links.txt
reading manifest file 'mypackage.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'mypackage.egg-info/SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt

running check
creating mypackage-1.2.2
creating mypackage-1.2.2/bin
creating mypackage-1.2.2/config
creating mypackage-1.2.2/mypackage
creating mypackage-1.2.2/mypackage.egg-info
creating mypackage-1.2.2/lib
making hard links in mypackage-1.2.2...
hard linking MANIFEST.in -> mypackage-1.2.2
hard linking package.json -> mypackage-1.2.2
hard linking setup.py -> mypackage-1.2.2
hard linking bin/cli.js -> mypackage-1.2.2/bin
hard linking config/appengine-endpoint.json -> mypackage-1.2.2/config
hard linking config/bugsense.json -> mypackage-1.2.2/config
hard linking config/youtube.json -> mypackage-1.2.2/config
hard linking mypackage/__init__.py -> mypackage-1.2.2/mypackage
hard linking mypackage.egg-info/PKG-INFO -> mypackage-1.2.2/mypackage.egg-info
hard linking mypackage.egg-info/SOURCES.txt -> mypackage-1.2.2/mypackage.egg-info
hard linking mypackage.egg-info/dependency_links.txt -> mypackage-1.2.2/mypackage.egg-info
hard linking mypackage.egg-info/pbr.json -> mypackage-1.2.2/mypackage.egg-info
hard linking mypackage.egg-info/top_level.txt -> mypackage-1.2.2/mypackage.egg-info
hard linking lib/mypackage.js -> mypackage-1.2.2/lib
hard linking lib/templater.js -> mypackage-1.2.2/lib
Writing mypackage-1.2.2/setup.cfg
Creating tar archive
removing 'mypackage-1.2.2' (and everything under it)
like image 759
Anthony Kong Avatar asked Jan 05 '16 06:01

Anthony Kong


1 Answers

Change your package_data so that it points relative to the package directory like so:

package_data={'mypackage': ['config/*json', 'lib/*js', 'bin/*js']}

like image 193
sushant Avatar answered Sep 27 '22 17:09

sushant