contrib/Makefile.python
author Pierre-Yves David <pierre-yves.david@fb.com>
Wed, 10 Jun 2015 19:58:27 -0700
changeset 25619 833fa28cd949
parent 23880 c0c4713c3010
child 26734 b000d34f863f
permissions -rw-r--r--
revset: use a baseset in _notpublic() The '_notpublic()' internal revset was "returning" a set. That was wrong. We now return a 'baseset' as appropriate. This has no effect on performance in most case, because we do the exact same operation than what the combination with a 'fullreposet' was doing. This as a small effect on some operation when combined with other set, because we now apply the filtering in all cases. I think the correctness is worth the impact on some corner cases. The optimizer should take care of these corner cases anyway. revset #0: not public() plain min max first last reverse 0) 0.000465 0.000491 0.000495 0.000500 0.000494 0.000479 1) 0.000484 0.000503 0.000498 0.000505 0.000504 0.000491 revset #1: (tip~1000::) - public() plain min max first last reverse 0) 0.002765 0.001742 0.002767 0.001730 0.002761 0.002782 1) 0.002847 0.001777 0.002776 0.001741 0.002764 0.002858 revset #2: not public() and branch("default") plain min max first last reverse 0) 0.012104 0.011138 0.011189 0.011138 0.011166 0.011578 1) 0.011387 94% 0.011738 105% 0.014220 127% 0.011223 0.011184 0.012077 revset #3: (not public() - obsolete()) plain min max first last reverse 0) 0.000583 0.000556 0.000552 0.000555 0.000552 0.000610 1) 0.000613 105% 0.000559 0.000557 0.000573 0.000558 0.000613 revset #4: head() - public() plain min max first last reverse 0) 0.010869 0.010800 0.011547 0.010843 0.010891 0.010891 1) 0.011031 0.011497 106% 0.011087 0.011100 0.011100 0.011085
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23880
c0c4713c3010 contrib: make Python 2.7.9 the default in Makefile.python
Mads Kiilerich <madski@unity3d.com>
parents: 23824
diff changeset
     1
PYTHONVER=2.7.9
20388
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     2
PYTHONNAME=python-
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     3
PREFIX=$(HOME)/bin/prefix-$(PYTHONNAME)$(PYTHONVER)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     4
SYMLINKDIR=$(HOME)/bin
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     5
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     6
help:
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     7
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     8
	@echo 'Make a custom installation of a Python version'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     9
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    10
	@echo 'Common make parameters:'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    11
	@echo '  PYTHONVER=...    [$(PYTHONVER)]'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    12
	@echo '  PREFIX=...       [$(PREFIX)]'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    13
	@echo '  SYMLINKDIR=...   [$(SYMLINKDIR) creating $(PYTHONNAME)$(PYTHONVER)]'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    14
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    15
	@echo 'Common make targets:'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    16
	@echo '  python    - install Python $$PYTHONVER in $$PREFIX'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    17
	@echo '  symlink   - create a $$SYMLINKDIR/$(PYTHONNAME)$$PYTHONVER symlink'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    18
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    19
	@echo 'Example: create a temporary Python installation:'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    20
	@echo '  $$ make -f Makefile.python python PYTHONVER=2.4 PREFIX=/tmp/p24'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    21
	@echo '  $$ /tmp/p24/bin/python -V'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    22
	@echo '  Python 2.4'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    23
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    24
	@echo 'Some external libraries are required for building Python: zlib bzip2 openssl.'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    25
	@echo 'Make sure their development packages are installed systemwide.'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    26
# fedora: yum install zlib-devel bzip2-devel openssl-devel
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    27
# debian: apt-get install zlib1g-dev libbz2-dev libssl-dev
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    28
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    29
	@echo 'To build a nice collection of interesting Python versions:'
23880
c0c4713c3010 contrib: make Python 2.7.9 the default in Makefile.python
Mads Kiilerich <madski@unity3d.com>
parents: 23824
diff changeset
    30
	@echo '  $$ for v in 2.{4{,.2,.3},5{,.6},6{,.1,.2,.9},7{,.8,.9}}; do'
20388
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    31
	@echo '    make -f Makefile.python symlink PYTHONVER=$$v || break; done'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    32
	@echo 'To run a Mercurial test on all these Python versions:'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    33
	@echo '  $$ for py in `cd ~/bin && ls $(PYTHONNAME)2.*`; do'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    34
	@echo '    echo $$py; $$py run-tests.py test-http.t; echo; done'
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    35
	@echo
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    36
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    37
export LANGUAGE=C
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    38
export LC_ALL=C
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    39
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    40
python: $(PREFIX)/bin/python docutils
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    41
	printf 'import sys, zlib, bz2, docutils\nif sys.version_info >= (2,6):\n import ssl' | $(PREFIX)/bin/python
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    42
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    43
PYTHON_SRCDIR=Python-$(PYTHONVER)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    44
PYTHON_SRCFILE=$(PYTHON_SRCDIR).tgz
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    45
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    46
$(PREFIX)/bin/python:
23824
e278fc8bb0c3 Makefile.python: try curl if wget fails
Augie Fackler <augie@google.com>
parents: 23140
diff changeset
    47
	[ -f $(PYTHON_SRCFILE) ] || wget http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || curl -OL http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || [ -f $(PYTHON_SRCFILE) ]
20388
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    48
	rm -rf $(PYTHON_SRCDIR)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    49
	tar xf $(PYTHON_SRCFILE)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    50
	# Ubuntu disables SSLv2 the hard way, disable it on old Pythons too
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    51
	-sed -i 's,self.*SSLv2_method(),0;//\0,g' $(PYTHON_SRCDIR)/Modules/_ssl.c
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    52
	# Find multiarch system libraries on Ubuntu with Python 2.4.x
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    53
	# http://lipyrary.blogspot.dk/2011/05/how-to-compile-python-on-ubuntu-1104.html
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    54
	-sed -i "s|lib_dirs = .* \[|\0'/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`',|g" $(PYTHON_SRCDIR)/setup.py
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    55
	# Find multiarch system libraries on Ubuntu and disable fortify error when setting argv
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    56
	LDFLAGS="-L/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`"; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    57
	BASECFLAGS=-U_FORTIFY_SOURCE; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    58
	export LDFLAGS BASECFLAGS; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    59
	cd $(PYTHON_SRCDIR) && ./configure --prefix=$(PREFIX) && make all SVNVERSION=pwd && make install
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    60
	printf 'import sys, zlib, bz2\nif sys.version_info >= (2,6):\n import ssl' | $(PREFIX)/bin/python
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    61
	rm -rf $(PYTHON_SRCDIR)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    62
23140
fbd79c2552a6 contrib: update build defaults to latest Python and docutils versions
Mads Kiilerich <madski@unity3d.com>
parents: 20388
diff changeset
    63
DOCUTILSVER=0.12
20388
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    64
DOCUTILS_SRCDIR=docutils-$(DOCUTILSVER)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    65
DOCUTILS_SRCFILE=$(DOCUTILS_SRCDIR).tar.gz
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    66
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    67
docutils: $(PREFIX)/bin/python
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    68
	@$(PREFIX)/bin/python -c 'import docutils' || ( set -ex; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    69
	[ -f $(DOCUTILS_SRCFILE) ] || wget http://downloads.sourceforge.net/project/docutils/docutils/$(DOCUTILSVER)/$(DOCUTILS_SRCFILE) || [ -f $(DOCUTILS_SRCFILE) ]; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    70
	rm -rf $(DOCUTILS_SRCDIR); \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    71
	tar xf $(DOCUTILS_SRCFILE); \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    72
	cd $(DOCUTILS_SRCDIR) && $(PREFIX)/bin/python setup.py install --prefix=$(PREFIX); \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    73
	$(PREFIX)/bin/python -c 'import docutils'; \
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    74
	rm -rf $(DOCUTILS_SRCDIR); )
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    75
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    76
symlink: python $(SYMLINKDIR)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    77
	ln -sf $(PREFIX)/bin/python $(SYMLINKDIR)/$(PYTHONNAME)$(PYTHONVER)
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    78
9fe578297b5c contrib/Makefile.python: build local Python from source
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    79
.PHONY: help python docutils symlink