Help with plugin development (esp. djangocms-helper)

40 views
Skip to first unread message

Brian Rutledge

unread,
Nov 17, 2016, 10:39:32 AM11/17/16
to django CMS developers
In the process of submitting a PR for djangocms-style, I ran into some snags with getting my development environment set up. I started by following the instructions under Running Tests, but running `python setup.py test` resulted in the following error:

pkg_resources.VersionConflict: (Django 1.10.3 (/Users/brian/.virtualenvs/djangocms-style/lib/python2.7/site-packages), Requirement.parse('django<1.10,>=1.8'))

It looks like djangocms-helper from tests/requirements.txt doesn't specify a Django version in its setup.py, so the latest is installed, but that conflicts with the django CMS requirement. So, I did a manual install of Django 1.9.11, and then `python setup.py test` passed, which was sufficient for the work that I was doing.

However, it looks to me like more involved work would require using `djangocms_helper` to make migrations, etc. But, running `djangocms-helper djangocms_style test --cms` in a fresh virtualenv after `pip install -r tests/requirements.txt` gives me this error:

ImportError: No module named djangocms_admin_style

The How to use docs indicate that django CMS needs to be installed, but I don't know the "right way" to do that for plugin development. It's worth noting that I haven't really worked on pip-installable projects before, so I'm not familiar with how to use `setup.py` during development.

So, I'd like to understand how django CMS contributors work on plugins. Once I understand the process, I'm happy to improve the docs, if needed.

Iacopo Spalletti

unread,
Nov 17, 2016, 12:44:15 PM11/17/16
to django-cms...@googlegroups.com
Il 17/11/2016 16:39, Brian Rutledge ha scritto:
> In the process of submitting a PR for djangocms-style
> <https://github.com/divio/djangocms-style/pull/33>, I ran into some
> snags with getting my development environment set up. I started by
> following the instructions under Running Tests
> <https://github.com/divio/djangocms-style#running-tests>, but running
> `python setup.py test` resulted in the following error:
>
> pkg_resources.VersionConflict: (Django 1.10.3
> (/Users/brian/.virtualenvs/djangocms-style/lib/python2.7/site-packages),
> Requirement.parse('django<1.10,>=1.8'))
>
>
> It looks like djangocms-helper from tests/requirements.txt
> <https://github.com/divio/djangocms-style/blob/master/tests/requirements.txt>
> doesn't specify a Django version in its setup.py
> <https://github.com/nephila/djangocms-helper/blob/develop/setup.py>, so
> the latest is installed, but that conflicts with the django CMS
> requirement. So, I did a manual install of Django 1.9.11, and then
> `python setup.py test` passed, which was sufficient for the work that I
> was doing.
>
> However, it looks to me like more involved work would require using
> `djangocms_helper` to make migrations, etc. But, running
> `djangocms-helper djangocms_style test --cms` in a fresh virtualenv
> after `pip install -r tests/requirements.txt` gives me this error:
>
> ImportError: No module named djangocms_admin_style
>
>
> The How to use docs
> <https://djangocms-helper.readthedocs.io/en/develop/introduction.html> indicate
> that django CMS needs to be installed, but I don't know the "right way"
> to do that for plugin development. It's worth noting that I haven't
> really worked on pip-installable projects before, so I'm not familiar
> with how to use `setup.py` during development.
>
> So, I'd like to understand how django CMS contributors work on plugins.
> Once I understand the process, I'm happy to improve the docs, if needed.
>

For djangocms-helper to work, it needs the "helper file" (e.g: a special
file with custom settings and few functions).
The default helper file is cms_helper.py file in the git repository root.
You can easily integrate djangocms-helper with python setup.py using the
test_suite argument (see
https://djangocms-helper.readthedocs.io/en/develop/runner.html#integrated-runner),
but this will only work for running tests.
For all the other commands, like running migrations, you have to
explicitly tell the path of the settings file.
So the makemigrations command is something like:

djangocms-helper djangocms_style makemigrations
--extra-settings=tests/settings.py --cms

As the settings.py is configured as integrated runner you can actually
run commands in a simpler way:

python tests/settings.py makemigrations

Probably it just worth to mention the latter form in the readme

To properly setup the environment, I think it's easier if you just run
tox which knows all the versioned dependencies intricacies:

tox -epy27-dj19-cms33

will run the tests against the given set of python/django/cms

After that, you can easily reuse the same virtualenv to run commands etc.

I hope I answered your questions


> --
> Message URL: *MailScanner has detected definite fraud in the website at
> "groups.google.com". Do /not/ trust this website:*
> https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id <https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id>
> Unsubscribe: send a message to
> django-cms-devel...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google
> Groups "django CMS developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-cms-devel...@googlegroups.com
> <mailto:django-cms-devel...@googlegroups.com>.
> To view this discussion on the web, visit *MailScanner has detected
> definite fraud in the website at "groups.google.com". Do /not/ trust
> this website:*
> https://groups.google.com/d/msgid/django-cms-developers/cfb509d7-73f9-4340-b41f-8f0a9b4b45d0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-cms-developers/cfb509d7-73f9-4340-b41f-8f0a9b4b45d0%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit *MailScanner has detected definite fraud in the
> website at "groups.google.com". Do /not/ trust this website:*
> https://groups.google.com/d/optout <https://groups.google.com/d/optout>.


--
Iacopo Spalletti

Nephila s.a.s. - Firenze
Telefono: +39 055 5357189
Assistenza Tecnica: +39 055 3985730
http://nephi.la

signature.asc

Brian Rutledge

unread,
Nov 17, 2016, 8:52:23 PM11/17/16
to django CMS developers
Ah, yes, tox. I have that installed globally. So, this was successful:

$ git clone g...@github.com:divio/djangocms-style.git
$ cd djangocms-style
$ tox -e py27-latest
# ...
  py27-latest: commands succeeded
  congratulations :)

$ source .tox/py27-latest/bin/activate
(py27-latest)$ coverage run setup.py test && coverage report
# ...
---------------------------------------------------------------------------------------------------------
TOTAL                                                                     157     51     56      2    54%

(py27-latest)$ python tests/settings.py server
# ...
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C

Here's another thing that worked (using `virtualenvwrapper`, but `virtualenv` would work, too):

$ git clone g...@github.com:divio/djangocms-style.git
$ mkproject -f djangocms-style
(djangocms-style)$ pip install -e .
(djangocms-style)$ pip install -r tests/requirements.txt
(djangocms-style)$ coverage run setup.py test && coverage report
# ...
---------------------------------------------------------------------------------------------------------
TOTAL                                                                     157     51     56      2    54%

(djangocms-style)$ python tests/settings.py server
# ...
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C

So, in the first version, I'm using re-using the `tox` virtualenv. In the second, I'm creating my own. The `pip install -e .` was what I was missing to work in "development mode" (i.e., with django-cms installed).

Does one of these more closely reflect how the current contributors do plugin development? Do you have any other recommendations? Any thoughts on how should this be documented?

Iacopo Spalletti

unread,
Nov 19, 2016, 1:31:32 PM11/19/16
to django-cms...@googlegroups.com
> <https://packaging.python.org/distributing/#working-in-development-mode> (i.e.,
> with django-cms installed).
>
> Does one of these more closely reflect how the current contributors do
> plugin development? Do you have any other recommendations? Any thoughts
> on how should this be documented?

I think it's mostly a personal taste.
I generally use the first approach which allows to control the package
versions much more closely.
To me it's customary to test changes on multiple Django / django CMS
(not only automated testing, but also manual one), and tox-based
approach proved more robust.
But it's definitely not the "official" approach, so other core devs and
regular contributors have their own workflow and may provide their opinion.

Cheers,
Iacopo

>
>
>
> On Thursday, November 17, 2016 at 10:39:32 AM UTC-5, Brian Rutledge wrote:
>
> In the process of submitting a PR for djangocms-style
> <https://github.com/divio/djangocms-style/pull/33>, I ran into some
> snags with getting my development environment set up. I started by
> following the instructions under Running Tests
> <https://github.com/divio/djangocms-style#running-tests>, but
> running `python setup.py test` resulted in the following error:
>
> pkg_resources.VersionConflict: (Django 1.10.3
> (/Users/brian/.virtualenvs/djangocms-style/lib/python2.7/site-packages),
> Requirement.parse('django<1.10,>=1.8'))
>
>
> It looks like djangocms-helper from tests/requirements.txt
> <https://github.com/divio/djangocms-style/blob/master/tests/requirements.txt>
> doesn't specify a Django version in its setup.py
> <https://github.com/nephila/djangocms-helper/blob/develop/setup.py>,
> so the latest is installed, but that conflicts with the django CMS
> requirement. So, I did a manual install of Django 1.9.11, and then
> `python setup.py test` passed, which was sufficient for the work
> that I was doing.
>
> However, it looks to me like more involved work would require using
> `djangocms_helper` to make migrations, etc. But, running
> `djangocms-helper djangocms_style test --cms` in a fresh virtualenv
> after `pip install -r tests/requirements.txt` gives me this error:
>
> ImportError: No module named djangocms_admin_style
>
>
> The How to use docs
> <https://djangocms-helper.readthedocs.io/en/develop/introduction.html> indicate
> that django CMS needs to be installed, but I don't know the "right
> way" to do that for plugin development. It's worth noting that I
> haven't really worked on pip-installable projects before, so I'm not
> familiar with how to use `setup.py` during development.
>
> So, I'd like to understand how django CMS contributors work on
> plugins. Once I understand the process, I'm happy to improve the
> docs, if needed.
>
> --
> Message URL: *MailScanner has detected definite fraud in the website at
> "groups.google.com". Do /not/ trust this website:*
> https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id <https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id>
> Unsubscribe: send a message to
> django-cms-devel...@googlegroups.com
> ---
> You received this message because you are subscribed to the Google
> Groups "django CMS developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-cms-devel...@googlegroups.com
> <mailto:django-cms-devel...@googlegroups.com>.
> To view this discussion on the web, visit *MailScanner has detected
> definite fraud in the website at "groups.google.com". Do /not/ trust
> this website:*
> https://groups.google.com/d/msgid/django-cms-developers/1b4d0ebf-cb29-4bc2-9ffc-39d888a384f9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-cms-developers/1b4d0ebf-cb29-4bc2-9ffc-39d888a384f9%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc
Reply all
Reply to author
Forward
0 new messages