Makefile 11.0 KB
Newer Older
1 2 3 4 5 6

################################################################################ 
# Makefile  Makefile for Python Modules and other utilities
# Copyright Greenplum 2006-2011
################################################################################

7
default: install
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

top_builddir=../..
ifneq "$(wildcard $(top_builddir)/src/Makefile.global)" ""
include $(top_builddir)/src/Makefile.global
endif

#
# SOURCE DIRECTORIES
#
SRC=$(CURDIR)
PYLIB_SRC=$(SRC)/pythonSrc
PYLIB_SRC_EXT=$(PYLIB_SRC)/ext
SBIN_DIR=$(SRC)/../sbin
SERVER_SRC=$(SRC)
SERVER_SBIN=$(SERVER_SRC)/../sbin


#
# INSTALL DIRECTORY
#
LIB_DIR=$(SRC)/lib
PYLIB_DIR=$(SRC)/ext

core: pygresql subprocess32
32
	python gpconfig_modules/parse_guc_metadata.py $(prefix)
33

34
ifneq "$(wildcard $(CURDIR)/pythonSrc/ext/*.tar.gz)" ""
N
Nadeem Ghani 已提交
35
install: core lockfile paramiko ecdsa pycrypto stream psutil
36
else
37
install: core stream
38 39 40 41 42 43 44
endif

#
# Python Libraries
#

#
45
#  STREAM which is used by gpcheckperf for memory bandwidth testing.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
#
STREAM_DIR=$(SRC)/src/stream
stream:
	@echo "--- stream"
	cd $(STREAM_DIR) && NO_M64=TRUE $(CC) stream.c -o stream
	cp $(STREAM_DIR)/stream $(SERVER_SRC)/lib/stream

#
# PyGreSQL
#
PYGRESQL_VERSION=4.0
PYGRESQL_DIR=PyGreSQL-$(PYGRESQL_VERSION)

pygresql:
	@echo "--- PyGreSQL"
	. $(prefix)/greenplum_path.sh && unset PYTHONHOME && \
	if [ `uname -s` = 'HP-UX' ]; then \
63
	    cd $(PYLIB_SRC)/$(PYGRESQL_DIR) && DESTDIR="$(DESTDIR)" CC="$(CC)" LDFLAGS="-L../../../../gpAux/ext/hpux_ia64/python-2.5.6/lib" python setup.py build; \
A
Adam Lee 已提交
64
	elif [ "$(BLD_ARCH)" = 'aix7_ppc_64' ]; then \
65
	    unset PYTHONPATH && cd $(PYLIB_SRC)/$(PYGRESQL_DIR) && DESTDIR="$(DESTDIR)" CC="$(CC)" python_64 setup.py build; \
66 67
	elif [ `uname -s` = 'OpenBSD' ]; then \
	    cd $(PYLIB_SRC)/$(PYGRESQL_DIR) && DESTDIR="$(DESTDIR)" CC=cc python setup.py build; \
68
	else \
69
	    cd $(PYLIB_SRC)/$(PYGRESQL_DIR) && DESTDIR="$(DESTDIR)" CC="$(CC)" python setup.py build; \
70 71
	fi
	mkdir -p $(PYLIB_DIR)/pygresql
72 73
	if [ `uname -s` = 'Darwin' ]; then \
	  cp -r $(PYLIB_SRC)/$(PYGRESQL_DIR)/build/lib.macosx*/* $(PYLIB_DIR)/pygresql; \
74 75
	elif [ `uname -s` = 'AIX' ]; then \
	  cp -r $(PYLIB_SRC)/$(PYGRESQL_DIR)/build/lib.aix*/* $(PYLIB_DIR)/pygresql; \
76 77
	elif [ `uname -s` = 'OpenBSD' ]; then \
	  cp -r $(PYLIB_SRC)/$(PYGRESQL_DIR)/build/lib.openbsd*/* $(PYLIB_DIR)/pygresql; \
78 79 80
	else \
	  cp -r $(PYLIB_SRC)/$(PYGRESQL_DIR)/build/lib.linux*/* $(PYLIB_DIR)/pygresql; \
	fi
81 82 83 84 85
	touch $(PYLIB_DIR)/__init__.py

#
# PARAMIKO
#
N
Nadeem Ghani 已提交
86
PARAMIKO_VERSION=1.18.4
87 88 89 90 91
PARAMIKO_DIR=paramiko-$(PARAMIKO_VERSION)
paramiko:
	@echo "--- paramiko"
	cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PARAMIKO_DIR).tar.gz
	cd $(PYLIB_SRC_EXT)/$(PARAMIKO_DIR)/ && python setup.py build
92
	cp -r $(PYLIB_SRC_EXT)/$(PARAMIKO_DIR)/build/lib*/paramiko $(PYLIB_DIR)/
93

N
Nadeem Ghani 已提交
94 95 96 97 98 99 100 101 102 103 104
#
# ecdsa
#
ECDSA_VERSION=0.13
ECDSA_DIR=ecdsa-$(ECDSA_VERSION)
ecdsa:
	@echo "--- ecdsa"
	cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(ECDSA_DIR).tar.gz
	cd $(PYLIB_SRC_EXT)/$(ECDSA_DIR)/ && python setup.py build
	cp -r $(PYLIB_SRC_EXT)/$(ECDSA_DIR)/build/lib*/ecdsa $(PYLIB_DIR)/

105 106 107 108 109 110 111 112 113
#
# LOCKFILE
#
# note the awk commands are used to eliminate references to code in __init__.py
# that we don't use and also to insert a comment to tell pylint not to complain
# about these files since we are not in a position to correct those warnings.
#
LOCKFILE_VERSION=0.9.1
LOCKFILE_DIR=lockfile-$(LOCKFILE_VERSION)
114
LOCKFILE_SRC=$(PYLIB_SRC_EXT)/$(LOCKFILE_DIR)/build/lib*/lockfile
115 116 117 118 119
LOCKFILE_DST=$(PYLIB_DIR)/lockfile
lockfile:
	@echo "--- lockfile"
	cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(LOCKFILE_DIR).tar.gz
	cd $(PYLIB_SRC_EXT)/$(LOCKFILE_DIR)/ && python setup.py build
120 121 122
	mkdir -p $(LOCKFILE_DST)
	awk 'BEGIN{print "# pylint: disable-all"} /^if hasattr/ {exit} { print }' < `echo $(LOCKFILE_SRC)/__init__.py`    > $(LOCKFILE_DST)/__init__.py
	awk 'BEGIN{print "# pylint: disable-all"} { print }'                      < `echo $(LOCKFILE_SRC)/pidlockfile.py` > $(LOCKFILE_DST)/pidlockfile.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

subprocess32:
	@echo "--- subprocess32, Linux only"
	@if [ `uname -s` = 'Linux' ]; then \
		  cd $(PYLIB_SRC)/subprocess32 && CC="$(CC)" python setup.py build; \
		  cp -f $(PYLIB_SRC)/subprocess32/build/lib.*/* $(PYLIB_DIR)/;  \
	  fi

#
# PYCRYPTO
#
PYCRYPTO_VERSION=2.0.1
PYCRYPTO_DIR=pycrypto-$(PYCRYPTO_VERSION)

pycrypto:
	@echo "--- pycrypto"
139
ifeq "$(findstring $(BLD_ARCH),aix7_ppc_64 )" ""
140 141 142
	cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PYCRYPTO_DIR).tar.gz
	cd $(PYLIB_SRC_EXT)/$(PYCRYPTO_DIR)/ && CC="$(CC)" python setup.py build
	cp -r $(PYLIB_SRC_EXT)/$(PYCRYPTO_DIR)/build/lib.*/Crypto $(PYLIB_DIR)
143 144 145 146 147 148 149 150 151 152 153 154 155 156
endif

#
# PSI
PSI_DIR=PSI-$(PSI_VERSION)

 psi:
	@echo "--- psi"
ifeq "$(findstring $(BLD_ARCH),aix7_ppc_64 )" ""
	cd $(PYLIB_SRC)/ && $(TAR) xzf $(PSI_DIR).tar.gz
	cd $(PYLIB_SRC)/$(PSI_DIR)/ && CC="$(CC)" python setup.py build
	cp -r $(PYLIB_SRC)/$(PSI_DIR)/build/lib.*/psi $(PYLIB_DIR)
endif

157 158

#
159
# PSUTIL
160
#
161 162
PSUTIL_VERSION=4.0.0
PSUTIL_DIR=psutil-$(PSUTIL_VERSION)
163

164 165
psutil:
	@echo "--- psutil"
166
ifeq "$(findstring $(BLD_ARCH),aix7_ppc_64 )" ""
167 168 169
	cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PSUTIL_DIR).tar.gz
	cd $(PYLIB_SRC_EXT)/$(PSUTIL_DIR)/ && CC="$(CC)" python setup.py build
	cp -r $(PYLIB_SRC_EXT)/$(PSUTIL_DIR)/build/lib.*/psutil $(PYLIB_DIR)
170
endif
171 172 173 174 175 176 177 178 179 180 181 182 183 184

#
# PYLINT
#

PYLINT_VERSION=0.21.0
PYLINT_DIR=pylint-$(PYLINT_VERSION)
LOGILAB_ASTNG_VERSION=0.20.1
LOGILAB_ASTNG_DIR=logilab-astng-$(LOGILAB_ASTNG_VERSION)
LOGILAB_COMMON_VERSION=0.50.1
LOGILAB_COMMON_DIR=logilab-common-$(LOGILAB_COMMON_VERSION)
PYLINT_PYTHONPATH=$(PYLIB_DIR):$(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
MOCK_VERSION=1.0.1
MOCK_DIR=mock-$(MOCK_VERSION)
T
Todd Sedano 已提交
185
BEHAVE_VERSION=1.2.4
186
SETUP_TOOLS_VERSION=36.6.0
187 188 189 190 191 192 193
PARSE_VERSION=1.5.3
ARG_PARSE_VERSION=1.2.1
BEHAVE_DIR=behave-$(BEHAVE_VERSION)
SETUP_TOOLS_DIR=setuptools-$(SETUP_TOOLS_VERSION)
PARSE_DIR=parse-$(PARSE_VERSION)
ARG_PARSE_DIR=argparse-$(ARG_PARSE_VERSION)
PYTHONSRC_INSTALL=$(PYLIB_SRC_EXT)/install
H
Hubert Zhang 已提交
194
PYTHON_VERSION=$(shell python -c "import sys; print ('%s.%s' % (sys.version_info[0:2]))")
195
PYTHONSRC_INSTALL_SITE=$(PYLIB_SRC_EXT)/install/lib/python$(PYTHON_VERSION)/site-packages
196 197
PYTHONSRC_INSTALL_PYTHON_PATH=$(PYTHONPATH):$(PYTHONSRC_INSTALL_SITE)
BEHAVE_BIN=$(PYTHONSRC_INSTALL)/bin/behave
198 199
# TODO: mock-1.0.1-py2.6.egg package should be updated.
MOCK_BIN=$(PYTHONSRC_INSTALL)/lib/python$(PYTHON_VERSION)/site-packages/mock-1.0.1-py2.6.egg
200
UBUNTU_PLATFORM=$(shell if lsb_release -a 2>/dev/null | grep -q 'Ubuntu' ; then echo "Ubuntu"; fi)
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215

pylint:
	@echo "--- pylint"
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PYLINT_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(LOGILAB_ASTNG_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(LOGILAB_COMMON_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/ && python setup.py build 1> /dev/null
	@cd $(PYLIB_SRC_EXT)/$(LOGILAB_ASTNG_DIR)/ && python setup.py build 1> /dev/null
	@cd $(PYLIB_SRC_EXT)/$(LOGILAB_COMMON_DIR)/ && python setup.py build 1> /dev/null
	@cp -r $(PYLIB_SRC_EXT)/$(LOGILAB_COMMON_DIR)/build/lib/logilab $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
	@cp -r $(PYLIB_SRC_EXT)/$(LOGILAB_ASTNG_DIR)/build/lib/logilab $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/
	@touch $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/__init__.py
	@touch $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/build/lib/logilab/__init__.py

$(MOCK_BIN):
216 217 218 219 220 221 222 223 224
	@echo "--- mock for platform $(UBUNTU_PLATFORM)"
	@if [ $(UBUNTU_PLATFORM) = "Ubuntu" ]; then\
       pip install mock;\
     else\
       mkdir -p $(PYTHONSRC_INSTALL_SITE) && \
	   cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(MOCK_DIR).tar.gz && \
	   cd $(PYLIB_SRC_EXT)/$(MOCK_DIR)/ && \
	   PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python setup.py install --prefix $(PYTHONSRC_INSTALL) ; \
	 fi;
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

#
# BEHAVE 
#

$(BEHAVE_BIN):
	@echo "--- build $(BEHAVE_BIN)"
	@mkdir -p $(PYTHONSRC_INSTALL_SITE)
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(BEHAVE_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(SETUP_TOOLS_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(PARSE_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/ && $(TAR) xzf $(ARG_PARSE_DIR).tar.gz
	@cd $(PYLIB_SRC_EXT)/$(SETUP_TOOLS_DIR)/ && PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python setup.py install --prefix $(PYTHONSRC_INSTALL)
	@cd $(PYLIB_SRC_EXT)/$(PARSE_DIR)/ && PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python setup.py install --prefix $(PYTHONSRC_INSTALL)
	@cd $(PYLIB_SRC_EXT)/$(ARG_PARSE_DIR)/ && PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python setup.py install --prefix $(PYTHONSRC_INSTALL)
240 241 242 243 244
	# We're forcing a change in the requirements since we're in python
	# 2.7.12. There's a new syntax in the python requirements for
	# parse_type 0.4.2 which breaks if you're under 2.7.13
	@cd $(PYLIB_SRC_EXT)/$(BEHAVE_DIR)/ && sed -i 's/parse_type>=0.3.4/parse_type==0.4.1/' setup.py \
		&& PYTHONPATH=$(PYTHONSRC_INSTALL_PYTHON_PATH) python setup.py install --prefix $(PYTHONSRC_INSTALL)
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
	@echo "--- behave done"

PYTHON_FILES=`grep -l --exclude=Makefile --exclude=gplogfilter "/bin/env python" *`\
			 `grep -l "/bin/env python" $(SRC)/../sbin/*`\
			 `find ./gppylib -name "*.py"`\
			 `find $(SRC)/../sbin -name "*.py"`

checkcode: pylint
	@echo "Running pylint on management scripts..."
	@PYTHONPATH=$(PYTHONPATH):$(PYLINT_PYTHONPATH) $(PYLIB_SRC_EXT)/$(PYLINT_DIR)/bin/pylint -i y $(PYTHON_FILES) --rcfile=.rcfile > $(SRC)/../pylint.txt || true
	@echo -n "pylint_score=" > $(SRC)/../pylint_score.properties
	@grep "Your code has been rated at" $(SRC)/../pylint.txt | sed -e "s|Your .* \(.*\)/.*|\1|" >> $(SRC)/../pylint_score.properties

check-regress:
	@echo "Running regression tests..."
	@PYTHONPATH=$(SRC):$(SRC)/ext:$(PYTHONPATH) \
	gppylib/gpunit discover --verbose -s gppylib -p "test_regress*.py" 2> $(SRC)/../gpMgmt_testregress_results.log 1> $(SRC)/../gpMgmt_testregress_output.log

263
check: $(MOCK_BIN)
264
	@echo "Running pure unit and also "unit" tests that require cluster to be up..."
265
	@TMPDIR=/tmp PYTHONPATH=$(SERVER_SRC):$(SERVER_SBIN):$(PYTHONPATH):$(PYTHONSRC_INSTALL_PYTHON_PATH):$(SRC)/ext:$(SBIN_DIR):$(LIB_DIR):$(PYLIB_DIR)/mock-1.0.1 \
266
	gppylib/gpunit discover --verbose -s $(SRC)/gppylib -p "test_unit*.py" 2> $(SRC)/../gpMgmt_testunit_results.log 1> $(SRC)/../gpMgmt_testunit_output.log
267
	@TMPDIR=/tmp PYTHONPATH=$(SERVER_SRC):$(SERVER_SBIN):$(PYTHONPATH):$(PYTHONSRC_INSTALL_PYTHON_PATH):$(SRC)/ext:$(SBIN_DIR):$(LIB_DIR):$(PYLIB_DIR)/mock-1.0.1 \
268 269 270 271
	gppylib/gpunit discover --verbose -s $(SRC)/gppylib -p "test_cluster*.py" 2>> $(SRC)/../gpMgmt_testunit_results.log 1>> $(SRC)/../gpMgmt_testunit_output.log

unitdevel:
	@echo "Running pure unit tests..."
272
	python -m unittest discover --verbose -s $(SRC)/gppylib -p "test_unit*.py"
273 274 275 276 277 278

solarisTest:
	@if [ `uname -s` = 'SunOS' ]; then \
		echo "SOLARIS" ; \
	fi

N
Ning Wu 已提交
279 280 281 282
.PHONY: installcheck
installcheck:
	$(MAKE) -C gpload_test $@

283 284 285 286 287 288 289 290 291 292 293 294
clean distclean:
	rm -rf $(PYLIB_SRC_EXT)/$(LOCKFILE_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(PARAMIKO_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(PYCRYPTO_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(PYLINT_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(LOGILAB_COMMON_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(LOGILAB_ASTNG_DIR)
	rm -rf $(PYLIB_SRC_EXT)/$(PYGRESQL_DIR)/build
	rm -rf $(PYLIB_SRC)/$(PYGRESQL_DIR)/build
	rm -rf $(PYLIB_SRC)/subprocess32/build
	rm -rf $(STREAM_DIR)/stream lib/stream
	rm -rf *.pyc lib/*.pyc
295
	rm -f gpcheckcatc gpexpandc gptransferc
296 297
	rm -f gpconfig_modules/gucs_disallowed_in_file.txt
	rm -f gppylib/data/$(GP_MAJORVERSION).json