Makefile.vars 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # Licensed to Cloudera, Inc. under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. Cloudera, Inc. licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Public (SDK) Makefile variables. It requires the following to be defined:
  18. # ROOT
  19. # Points to the root of the Hue installation.
  20. # From here, we can include $(ROOT)/Makefile.vars
  21. # to access various
  22. #
  23. SHELL := /bin/bash
  24. ##############################
  25. # 1. Check for python-dev
  26. # 2. Locate the system Python
  27. ##############################
  28. # If we're an installed Makefile, allow the build to override
  29. # some things. This allows the install to prepopulate
  30. # SYS_PYTHON, in particular.
  31. ifneq ($(wildcard $(ROOT)/Makefile.buildvars),)
  32. include $(ROOT)/Makefile.buildvars
  33. endif
  34. VER_ERR_MSG = "Variable PYTHON_VER is $(PYTHON_VER) but it only supports >= python3.8. If not set, defaults to python3.8."
  35. # Major rewrite to support multi-python environments.
  36. PYTHON_VERSIONS ?= python3.8 python3.9 python3.10 python3.11
  37. PYTHON_VER ?= python3.11
  38. ifeq ($(filter $(PYTHON_VER), $(PYTHON_VERSIONS)),)
  39. $(error PYTHON_VER ($(PYTHON_VER)) is not in PYTHON_VERSIONS ($(PYTHON_VERSIONS)))
  40. endif
  41. ##############################
  42. # Location of the virtual environment
  43. ##############################
  44. BLD_DIR := $(ROOT)/build
  45. # Default case for Python 3.11
  46. ifeq ($(PYTHON_VER),python3.11)
  47. BLD_DIR_ENV := $(BLD_DIR)/env
  48. else
  49. BLD_DIR_ENV := $(BLD_DIR)/venvs/$(PYTHON_VER)
  50. endif
  51. ifdef INSTALL_DIR
  52. INST_DIR := $(INSTALL_DIR)/build
  53. ifeq ($(PYTHON_VER),python3.11)
  54. INST_DIR_ENV := $(INST_DIR)/env
  55. else
  56. INST_DIR_ENV := $(INST_DIR)/venvs/$(PYTHON_VER)
  57. endif
  58. endif
  59. BLD_DIR_BIN := $(BLD_DIR_ENV)/bin
  60. # Adds detection and configuration for python3.8 through python3.11.
  61. # Sets up per-version BLD_DIR_ENV and INST_DIR_ENV variables.
  62. # Introduces version-specific requirement file generation via generate_requirements.py.
  63. SYS_PYTHON := $(shell IFS=:; for p in $$PATH; do if [ -x "$$p/$(PYTHON_VER)" ]; then echo "$$p/$(PYTHON_VER)"; break; fi; done)
  64. SYS_PIP := $(shell echo $(SYS_PYTHON) | sed "s/python\([0-9]\+\.[0-9]\+\)$$/pip\1/")
  65. ENV_PYTHON := $(shell echo $(BLD_DIR_BIN)/$(shell basename $(SYS_PYTHON)))
  66. ENV_PIP := $(shell echo $(BLD_DIR_BIN)/$(shell basename $(SYS_PIP)))
  67. PYTHON_INCLUDE_DIR := $(shell $(SYS_PYTHON) -c "import sysconfig; print(sysconfig.get_path('include'))" 2>/dev/null)
  68. PYTHON_H := $(shell [ -f "$(PYTHON_INCLUDE_DIR)/Python.h" ] && echo "$(PYTHON_INCLUDE_DIR)/Python.h" || echo "")
  69. PYTHON_VERSION = $(shell $(SYS_PYTHON) -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
  70. $(info "PYTHON_VER is $(PYTHON_VER).")
  71. ifeq ($(shell echo $(PYTHON_VER) | head -c 8),python3.)
  72. MINOR_VER = $(shell $(SYS_PYTHON) --version | sed -E 's/Python [0-9]+\.([0-9]+).*/\1/')
  73. ifeq ($(shell test $(MINOR_VER) -lt 8; echo $$?),0)
  74. $(error "$(VER_ERR_MSG)")
  75. endif
  76. EXT_ENV_INSTALL = ext-env-pip-install
  77. else
  78. $(error "$(VER_ERR_MSG)")
  79. endif
  80. ifndef SKIP_PYTHONDEV_CHECK
  81. ifeq ($(PYTHON_H),)
  82. $(error "Error: must have python development packages for $(PYTHON_VER). Could not find Python.h. Please install $(PYTHON_VER)-devel or $(PYTHON_VER)-dev")
  83. endif
  84. endif
  85. ifeq ($(SYS_PYTHON),)
  86. $(error "Error: Need python version >= 3.8")
  87. endif
  88. HADOOP_HOME ?= /usr/lib/hadoop
  89. THIRDPARTY_DIR := $(ROOT)/ext/thirdparty
  90. THIRDPARTY_JS_DIR := $(THIRDPARTY_DIR)/js
  91. STATIC_DIR := $(BLD_DIR)/static
  92. ##############################
  93. # ENV_EASY_INSTALL uses the easy_install script installed in the virtual
  94. # environment. It must be called as an argument to ENV_PYTHON so the
  95. # problem of the shebang being truncated at 80 characters in most kernels
  96. # doesn't arise.
  97. ##############################
  98. ENV_EASY_INSTALL := $(ENV_PYTHON) $(BLD_DIR_BIN)/easy_install
  99. $(info "ENV_PYTHON is $(ENV_PYTHON).")
  100. $(info "ENV_PIP is $(ENV_PIP).")
  101. $(info "BLD_DIR_BIN is $(BLD_DIR_BIN).")
  102. ##############################
  103. # This version is substituted through to the tarballs and packages.
  104. ##############################
  105. DESKTOP_VERSION := $(shell $(SYS_PYTHON) <(cat $(ROOT)/VERSION; echo print '(VERSION)'))
  106. MAVEN_VERSION = $(DESKTOP_VERSION)-SNAPSHOT
  107. ##############################
  108. # Path to the desktop dbproxy jar
  109. ##############################
  110. DB_PROXY_JAR := $(ROOT)/desktop/libs/librdbms/java-lib/dbproxy-1.0.jar
  111. ################################################
  112. # Internationalization
  113. ################################################
  114. PYBABEL := $(ROOT)/build/env/bin/pybabel
  115. ##############################
  116. # Path to files for pip requirements
  117. ##############################
  118. REQUIREMENT_FILE := $(shell $(SYS_PYTHON) $(ROOT)/desktop/core/generate_requirements.py)
  119. REQUIREMENT_TEST_FILE := $(ROOT)/desktop/core/test_requirements.txt
  120. REQ_DIR := $(dir $(REQUIREMENT_FILE))
  121. REQ_BASE := $(notdir $(REQUIREMENT_FILE))
  122. REQ_BASE_NOEXT := $(basename $(REQ_BASE))
  123. NAVOPTAPI_WHL := $(ROOT)/desktop/core/wheels/navoptapi-1.0.0-py3-none-any.whl
  124. LOCAL_PY_BASE := $(shell $(SYS_PYTHON) -m site --user-base)
  125. LOCAL_PY_BIN := $(LOCAL_PY_BASE)/bin
  126. export PATH := $(PATH):$(LOCAL_PY_BIN)
  127. RELOCATABLE := $(shell which virtualenv-make-relocatable)
  128. ##############################
  129. # Set specific versions for some libraries
  130. ##############################
  131. PIP_VERSION := 22.2.2
  132. VIRTUAL_ENV_RELOCATABLE_VERSION := 0.0.1
  133. # Set VIRTUAL_ENV_VERSION based on PYTHON_VER
  134. ifeq ($(PYTHON_VER),python3.9)
  135. VIRTUAL_ENV_VERSION := 20.19.0
  136. else
  137. VIRTUAL_ENV_VERSION := 20.24.4
  138. endif