Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top