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.

Travis Bear
  • 13,039
  • 7
  • 42
  • 51

1 Answers1

30

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.

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
Nicolas Cortot
  • 6,591
  • 34
  • 44
  • 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'. – Rebs May 09 '14 at 02:26
  • They can be underscores instead of hyphens. – user394430 Dec 27 '21 at 15:01