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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. VENV = venv
  2. PYTEST = $(PWD)/$(VENV)/bin/py.test
  3. # These targets are not files
  4. .PHONY: build_sandbox clean compile_translations coverage css docs extract_translations help install install-python \
  5. install-test install-js lint release retest sandbox_clean sandbox_image sandbox test todo venv package
  6. help: ## Display this help message
  7. @echo "Please use \`make <target>\` where <target> is one of"
  8. @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; \
  9. {printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}'
  10. ##################
  11. # Install commands
  12. ##################
  13. install: install-python install-test assets ## Install requirements for local development and production
  14. install-python: ## Install python requirements
  15. pip install -r requirements.txt --upgrade --upgrade-strategy=eager
  16. install-test: ## Install test requirements
  17. pip install -e .[test] --upgrade --upgrade-strategy=eager
  18. install-migrations-testing-requirements: ## Install migrations testing requirements
  19. pip install -r requirements_migrations.txt
  20. assets: ## Install static assets
  21. npm install
  22. npm run build
  23. venv: ## Create a virtual env and install test and production requirements
  24. $(shell which python3) -m venv $(VENV)
  25. $(VENV)/bin/pip install -e .[test]
  26. $(VENV)/bin/pip install -r docs/requirements.txt
  27. #############################
  28. # Sandbox management commands
  29. #############################
  30. sandbox: install build_sandbox ## Install requirements and create a sandbox
  31. build_sandbox: sandbox_clean sandbox_load_user sandbox_load_data ## Creates a sandbox from scratch
  32. sandbox_clean: ## Clean sandbox images,cache,static and database
  33. # Remove media
  34. -rm -rf sandbox/public/media/images
  35. -rm -rf sandbox/public/media/cache
  36. -rm -rf sandbox/public/static
  37. -rm -f sandbox/db.sqlite
  38. # Create database
  39. sandbox/manage.py migrate
  40. sandbox_load_user: ## Load user data into sandbox
  41. sandbox/manage.py loaddata sandbox/fixtures/auth.json
  42. sandbox_load_data: ## Import fixtures and collect static
  43. # Import some fixtures. Order is important as JSON fixtures include primary keys
  44. sandbox/manage.py loaddata sandbox/fixtures/child_products.json
  45. sandbox/manage.py oscar_import_catalogue sandbox/fixtures/*.csv
  46. sandbox/manage.py oscar_import_catalogue_images sandbox/fixtures/images.tar.gz
  47. sandbox/manage.py oscar_populate_countries --initial-only
  48. sandbox/manage.py loaddata sandbox/fixtures/pages.json sandbox/fixtures/ranges.json sandbox/fixtures/offers.json
  49. sandbox/manage.py loaddata sandbox/fixtures/orders.json
  50. sandbox/manage.py clear_index --noinput
  51. sandbox/manage.py update_index catalogue
  52. sandbox/manage.py thumbnail cleanup
  53. sandbox/manage.py collectstatic --noinput
  54. sandbox_image: ## Build latest docker image of django-oscar-sandbox
  55. docker build -t django-oscar-sandbox:latest .
  56. ##################
  57. # Tests and checks
  58. ##################
  59. test: venv ## Run tests
  60. $(PYTEST)
  61. retest: venv ## Run failed tests only
  62. $(PYTEST) --lf
  63. coverage: venv ## Generate coverage report
  64. $(PYTEST) --cov=oscar --cov-report=term-missing
  65. lint:
  66. @black --check --exclude "migrations/*" src/oscar/
  67. @black --check --exclude "migrations/*" tests/
  68. @pylint setup.py src/oscar/
  69. @pylint setup.py tests/
  70. black:
  71. @black --exclude "migrations/*" src/oscar/
  72. @black --exclude "migrations/*" tests/
  73. test_migrations: install-migrations-testing-requirements ## Tests migrations
  74. cd sandbox && ./test_migrations.sh
  75. #######################
  76. # Translations Handling
  77. #######################
  78. extract_translations: ## Extract strings and create source .po files
  79. cd src/oscar; django-admin.py makemessages -a
  80. compile_translations: ## Compile translation files and create .mo files
  81. cd src/oscar; django-admin compilemessages
  82. ######################
  83. # Project Management
  84. ######################
  85. clean: ## Remove files not in source control
  86. find . -type f -name "*.pyc" -delete
  87. rm -rf nosetests.xml coverage.xml htmlcov *.egg-info *.pdf dist violations.txt
  88. docs: venv ## Compile docs
  89. make -C docs html SPHINXBUILD=$(PWD)/$(VENV)/bin/sphinx-build
  90. todo: ## Look for areas of the code that need updating when some event has taken place (like Oscar dropping support for a Django version)
  91. -grep -rnH TODO *.txt
  92. -grep -rnH TODO src/oscar/apps/
  93. -grep -rnH "django.VERSION" src/oscar/apps
  94. package: clean
  95. pip install --upgrade pip twine wheel
  96. npm ci
  97. rm -rf src/oscar/static/
  98. rm -rf dist/
  99. rm -rf build/
  100. npm run build
  101. python setup.py clean --all
  102. python setup.py sdist bdist_wheel
  103. release: package ## Creates release
  104. twine upload -s dist/*