Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tox can't copy non-python file while installing the module

This is the tree structure of the module I'm writing the setup.py file for:

ls .

LICENSE
README.md
bin
examples
module
scratch
setup.py
tests
tox.ini

I configured my setup.py as follows:

from setuptools import setup, find_packages

setup(
    name="package_name",
    version="0.1",
    packages=find_packages(),

    install_requires=[
        # [...]
    ],

    extras_require={
        # [...]

    },

    tests_require={
        'pytest',
        'doctest'
    },

    scripts=['bin/bootstrap'],

     data_files=[
        ('license', ['LICENSE']),
     ],

    # [...]
    # could also include long_description, download_url, classifiers, etc.
)

If I install the package from my python environment (also a virtualenv)

pip install .

the LICENSE file gets correctly installed.

But running tox:

[tox]
envlist = py27, py35

[testenv]
deps = 
    pytest
    git+https://github.com/djc/couchdb-python
    docopt

commands = py.test \
    {posargs}

I get this error:

running install_data
  creating build/bdist.macosx-10.11-x86_64/wheel/leafline-0.1.data
  creating build/bdist.macosx-10.11-x86_64/wheel/leafline-0.1.data/data
  creating build/bdist.macosx-10.11-x86_64/wheel/leafline-0.1.data/data/license
  error: can't copy 'LICENSE': doesn't exist or not a regular file

Removing the data_files part from the setup.py makes tox running correctly.

like image 243
rdbisme Avatar asked Jun 10 '16 17:06

rdbisme


1 Answers

Your issue here is that setuptools is not able to find the 'LICENSE' file in the files that have been included for building the source distribution. You have 2 options, to tell setuptools to include that file (both have been pointed to here):

  • Add a MANIFEST.in file (like https://github.com/pypa/sampleproject/)
  • Use include_package_data=True in your setup.py file.

Using MANIFEST.in is often simpler and easier to verify due to https://pypi.org/project/check-manifest/, making it possible to use automation to verify that things are indeed correct (if you use a VCS like Git or SVN).


pip install . builds a wheel using python setup.py bdist_wheel which is installed by simply unpacking it appropriately, as defined in the Wheel Specification: https://www.python.org/dev/peps/pep-0427/

tox builds a source distribution using python setup.py sdist, which is then unpacked and installed using python setup.py install.

That might be a reason for the difference in behavior for you.

like image 134
pradyunsg Avatar answered Oct 19 '22 07:10

pradyunsg