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

development-environment.rst 3.9KB

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