setup.py: expected parenthesized list when required package name contains a dash
Asked Answered
G

1

24

I am writing a reusable Django app as described here: https://django.readthedocs.org/en/1.5.x/intro/reusable-apps.html

When I specify a requirement in setup.py that contains a dash in the package name, setup.py will not run. For example, if my setup.py contains this line:

requires=[ 'djangotinymce', 'MtFileUtil', 'Django', 'PyYAML', ],

Then it works properly.

python ./setup.py sdist
running sdist
...
Creating tar archive

If I change the line to look like this:

requires=[ 'django-tinymce', 'MtFileUtil', 'Django', 'PyYAML', ],

We get a strange error

Traceback (most recent call last):
  File "./setup.py", line 32, in <module>
    'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
  File "/usr/lib/python2.7/distutils/core.py", line 112, in setup
    _setup_distribution = dist = klass(attrs)
  File "/home/travis/venv/deleteme/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/setuptools/dist.py", line 225, in __init__
    _Distribution.__init__(self,attrs)
  File "/usr/lib/python2.7/distutils/dist.py", line 259, in __init__
    getattr(self.metadata, "set_" + key)(val)
  File "/usr/lib/python2.7/distutils/dist.py", line 1220, in set_requires
    distutils.versionpredicate.VersionPredicate(v)
  File "/usr/lib/python2.7/distutils/versionpredicate.py", line 113, in __init__
    raise ValueError("expected parenthesized list: %r" % paren)
ValueError: expected parenthesized list: '-tinymce'

I'm unsure what to make of this. I want to require django-tinymce but I can't see how to do it.

Gabler answered 21/4, 2013 at 1:29 Comment(0)
I
31

The require argument is from distutils and expects python package names (some documentation here). Since you're using setuptools, you should use the install_requires argument instead, which does support PyPI package names:

install_requires=['djangotinymce', 'MtFileUtil', 'Django', 'PyYAML'],

More info on Specifying Dependencies in the Python Packaging User Guide.

Internode answered 23/4, 2013 at 18:45 Comment(2)
Just to add clarification to the above comment, you need to remove the -'s. To python these are arithmetical operators. Ie 'django-tinymce' -> 'djangotinymce'.Rheo
They can be underscores instead of hyphens.Retarded

© 2022 - 2024 — McMap. All rights reserved.