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

development-environment.rst 3.7KB

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