You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

development-environment.rst 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ======================================
  2. Setting up the development environment
  3. ======================================
  4. Fork the repo and run::
  5. $ git clone git@github.com:<username>/django-oscar.git
  6. $ cd django-oscar
  7. $ mkvirtualenv oscar # using virtualenvwrapper
  8. $ make install
  9. The :doc:`sandbox </internals/sandbox>` site can be used to test our changes in
  10. a browser. It is easily created with ``make sandbox``.
  11. Creating migrations
  12. ===================
  13. As the sandbox is a vanilla Oscar site, it is what we use to build migrations
  14. against::
  15. $ make sandbox
  16. $ sites/sandbox/manage.py schemamigration $YOURAPP --auto
  17. Writing LESS/CSS
  18. ================
  19. Oscar's CSS files are build using LESS_. However, the sandbox defaults to
  20. serving CSS files directly, bypassing LESS compilation.
  21. .. _LESS: http://lesscss.org/
  22. If you want to develop the LESS files, set::
  23. USE_LESS = True
  24. COMPRESS_ENABLED = False
  25. in ``sites/sandbox/settings_local.py``. This will cause Oscar to use
  26. `django-compressor`_ to compile the LESS files as they are requested. For this to
  27. work, you will need to ensure that the LESS compiler ``lessc`` is installed.
  28. This can be acheived by running::
  29. pip install -r requirements_less.txt
  30. .. _`django-compressor`: http://django_compressor.readthedocs.org/en/latest/
  31. which will install the `virtual-node`_ and `virtual-less`_ packages, which will
  32. install node.js and LESS in your virtualenv.
  33. .. _`virtual-node`: https://github.com/elbaschid/virtual-node
  34. .. _`virtual-less`: https://github.com/elbaschid/virtual-less
  35. If you have npm installed already,
  36. you install LESS using::
  37. npm install less
  38. You can manually compile the CSS files by running::
  39. make css
  40. .. warning::
  41. If you do submit a pull request that changes the LESS files. Please also
  42. recompile the CSS files and include them in your pull request.
  43. Vagrant
  44. =======
  45. Oscar ships with a Vagrant_ virtual machine that can be used to test integration
  46. with various services in a controlled environment. For instance, it is used to
  47. test that the migrations run correctly in both MySQL and Postgres.
  48. .. _Vagrant: http://vagrantup.com/
  49. Building the Vagrant machine
  50. ----------------------------
  51. To create the machine, first ensure that Vagrant and puppet_ are installed. You will require a
  52. puppet version that supports ``puppet module install``, that is > 2.7.14. Now
  53. run::
  54. make puppet
  55. .. _puppet: http://docs.puppetlabs.com/guides/installation.html
  56. to fetch the required puppet modules for provisioning. Finally, run::
  57. vagrant up
  58. to create the virtual machine and provision it.
  59. Testing migrations against MySQL and Postgres
  60. ---------------------------------------------
  61. To test the migrations against MySQL and Postgres, do the following:
  62. 1. SSH onto the VM::
  63. vagrant ssh
  64. 2. Change to sandbox folder and activate virtualenv::
  65. cd /vagrant/sites/sandbox
  66. source /var/www/virtualenv/bin/activate
  67. 3. Run helper script::
  68. ./test_migrations.sh
  69. This will recreate the Oscar database in both MySQL and Postgres and rebuild
  70. it using ``syncdb`` and ``migrate``.
  71. Testing WSGI server configurations
  72. ----------------------------------
  73. You can browse the Oscar sandbox site in two ways:
  74. * Start Django's development server on port 8000::
  75. vagrant ssh
  76. cd /vagrant/sites/sandbox
  77. source /var/www/virtualenv/bin/activate
  78. ./manage.py runserver 0.0.0.0:8000
  79. The Vagrant machine forwards port 8000 to post 8080 and so the site can be
  80. accessed at http://localhost:8080 on your host machine.
  81. * The Vagrant machine installs Apache2 and mod_wsgi. You can browse the site
  82. through Apache at http://localhost:8081 on your host machine.