Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

development-environment.rst 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 # needs virtualenvwrapper
  8. $ make install
  9. If using Ubuntu, the ``python-dev`` package is required for some packages to
  10. compile.
  11. The :doc:`sandbox </internals/sandbox>` site can be used to test our changes in
  12. a browser. It is easily created with ``make sandbox``.
  13. JPEG Support
  14. ------------
  15. On Ubuntu, you need to install a few libraries to get JPEG support with Pillow.
  16. $ sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev
  17. If you did already install PIL (you did if you ran ``make install`` previously),
  18. reinstall it:
  19. $ pip uninstall Pillow
  20. $ pip install Pillow
  21. Creating migrations
  22. ===================
  23. As the sandbox is a vanilla Oscar site, it is what we use to build migrations
  24. against::
  25. $ make sandbox
  26. $ sites/sandbox/manage.py schemamigration $YOURAPP --auto
  27. Writing LESS/CSS
  28. ================
  29. Oscar's CSS files are build using LESS_. However, the sandbox defaults to
  30. serving CSS files directly, bypassing LESS compilation.
  31. .. _LESS: http://lesscss.org/
  32. If you want to develop the LESS files, set::
  33. USE_LESS = True
  34. COMPRESS_ENABLED = False
  35. in ``sites/sandbox/settings_local.py``. This will cause Oscar to use
  36. `django-compressor`_ to compile the LESS files as they are requested. For this to
  37. work, you will need to ensure that the LESS compiler ``lessc`` is installed.
  38. This can be acheived by running::
  39. pip install -r requirements_less.txt
  40. .. _`django-compressor`: http://django_compressor.readthedocs.org/en/latest/
  41. which will install the `virtual-node`_ and `virtual-less`_ packages, which will
  42. install node.js and LESS in your virtualenv.
  43. .. _`virtual-node`: https://github.com/elbaschid/virtual-node
  44. .. _`virtual-less`: https://github.com/elbaschid/virtual-less
  45. If you have npm installed already,
  46. you install LESS using::
  47. npm install less
  48. You can manually compile the CSS files by running::
  49. make css
  50. .. warning::
  51. If you do submit a pull request that changes the LESS files. Please also
  52. recompile the CSS files and include them in your pull request.
  53. Vagrant
  54. =======
  55. Oscar ships with a Vagrant_ virtual machine that can be used to test integration
  56. with various services in a controlled environment. For instance, it is used to
  57. test that the migrations run correctly in both MySQL and Postgres.
  58. .. _Vagrant: http://vagrantup.com/
  59. Building the Vagrant machine
  60. ----------------------------
  61. To create the machine, first ensure that Vagrant and puppet_ are installed. You will require a
  62. puppet version that supports ``puppet module install``, that is > 2.7.14. Now
  63. run::
  64. make puppet
  65. .. _puppet: http://docs.puppetlabs.com/guides/installation.html
  66. to fetch the required puppet modules for provisioning. Finally, run::
  67. vagrant up
  68. to create the virtual machine and provision it.
  69. Testing migrations against MySQL and Postgres
  70. ---------------------------------------------
  71. To test the migrations against MySQL and Postgres, do the following:
  72. 1. SSH onto the VM::
  73. vagrant ssh
  74. 2. Change to sandbox folder and activate virtualenv::
  75. cd /vagrant/sites/sandbox
  76. source /var/www/virtualenv/bin/activate
  77. 3. Run helper script::
  78. ./test_migrations.sh
  79. This will recreate the Oscar database in both MySQL and Postgres and rebuild
  80. it using ``syncdb`` and ``migrate``.
  81. Testing WSGI server configurations
  82. ----------------------------------
  83. You can browse the Oscar sandbox site with different deployment setups. Just
  84. open up http://localhost:808x on your host machine.
  85. * Django's development server runs on port 8080.
  86. * The Vagrant machine runs Apache2 and mod_wsgi on port 8081.
  87. * Nginx acts as a reverse proxy to Apache on port 8082.
  88. * Nginx acts as a reverse proxy to gunicorn on port 8083.