Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

development-environment.rst 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. Playing in the sandbox
  10. ======================
  11. Oscar ships with a 'sandbox' site which can be run locally to play around with
  12. Oscar using a browser. Set it up by::
  13. make sandbox
  14. cd sites/sandbox
  15. ./manage.py runserver
  16. This will create the database and load some fixtures for categories and shipping
  17. countries.
  18. Note that Oscar uses PIL_ and Sorl_ for thumbnailing, and so you will need
  19. ``libjpeg-dev`` installed in your OS so that your PIL installation supports
  20. JPEGS.
  21. .. _PIL: http://www.pythonware.com/products/pil/
  22. .. _Sorl: http://sorl-thumbnail.readthedocs.org/en/latest/
  23. Writing LESS/CSS
  24. ================
  25. The sandbox Oscar site defaults to serving the CSS files directly, bypassing
  26. LESS compilation. If you want to develop the LESS files, set::
  27. USE_LESS = True
  28. COMPRESS_ENABLED = False
  29. in ``sites/sandbox/settings_local.py``. You will also need to ensure that
  30. ``lessc`` is installed. This can be acheived by running::
  31. pip install -r requirements_less.txt
  32. which will install the `virtual-node`_ and `virtual-less`_ packages, which will
  33. install node.js and LESS in your virtualenv.
  34. .. _`virtual-node`: https://github.com/elbaschid/virtual-node
  35. .. _`virtual-less`: https://github.com/elbaschid/virtual-less
  36. Vagrant
  37. =======
  38. Oscar ships with a Vagrant_ virtual machine that can be used to test integration
  39. with various services in a controlled environment. For instance, it is used to
  40. test that the migrations run correctly in both MySQL and Postgres.
  41. .. _Vagrant: http://vagrantup.com/
  42. Building the Vagrant machine
  43. ----------------------------
  44. To create the machine, first ensure that Vagrant and puppet_ are installed. You will require a
  45. puppet version that supports ``puppet module install``, that is > 2.7.14. Now
  46. run::
  47. make puppet
  48. .. _puppet: http://docs.puppetlabs.com/guides/installation.html
  49. to fetch the required puppet modules for provisioning. Finally, run::
  50. vagrant up
  51. to create the virtual machine and provision it.
  52. Testing migrations against MySQL and Postgres
  53. ---------------------------------------------
  54. To test the migrations against MySQL and Postgres, do the following:
  55. 1. SSH onto the VM::
  56. vagrant ssh
  57. 2. Change to sandbox folder and activate virtualenv::
  58. cd /vagrant/sites/sandbox
  59. source /var/www/virtualenv/bin/activate
  60. 3. Run helper script::
  61. ./test_migrations.sh
  62. This will recreate the Oscar database in both MySQL and Postgres and rebuild
  63. it using ``syncdb`` and ``migrate``.
  64. Testing WSGI server configurations
  65. ----------------------------------
  66. You can browse the Oscar sandbox site in two ways:
  67. * Start Django's development server on port 8000::
  68. vagrant ssh
  69. cd /vagrant/sites/sandbox
  70. source /var/www/virtualenv/bin/activate
  71. ./manage.py runserver 0.0.0.0:8000
  72. The Vagrant machine forwards port 8000 to post 8080 and so the site can be
  73. accessed at http://localhost:8080 on your host machine.
  74. * The Vagrant machine install Apache2 and mod_wsgi. You can browse the site
  75. through Apache at http://localhost:8081 on your host machine.