jeudi 21 décembre 2017

Copying setup.py Dependencies with Tox

setup.py often depends on a couple external files, most notably README.md for long_description, and maybe VERSION for version. e.g.

root = os.path.dirname(os.path.abspath(__file__))
setuptools.setup(
    name             = 'package',
    version          = open(os.path.join(root, 'VERSION')).read().strip(),
    description      = 'A Simple Package',
    long_description = open(os.path.join(root, 'README.md')).read().strip(),
    # ...
)

However, when trying to run tests with tox on such a package, I get the following error:

ERROR: invocation failed (exit code 1), logfile: 
.tox/py36/log/py36-6.log
ERROR: actionid: py36
msg: installpkg
cmdargs: 
['.tox/py36/bin/pip', 'install', '-U', '--no-deps', '.tox/dist/package-0.1.0.zip']

Processing ./.tox/dist/package-0.1.0.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "setup.py", line 10, in <module>
        version          = open(os.path.join(root, 'VERSION')).read().strip(),
    FileNotFoundError: [Errno 2] No such file or directory: 'VERSION'

(Or a similar message with README.md). Obviously, tox only copies setup.py, and when it tries to run it, its dependencies are missing and it doesn't work.

I went over the documentation, but I can't seem to find a way to tell tox to copy these files. Is there a way to do it?

Aucun commentaire:

Enregistrer un commentaire