##// END OF EJS Templates
make: switch the PYTHON default to `py.exe -3` on Windows...
Matt Harbison -
r46510:4f6816e8 default
parent child Browse files
Show More
@@ -1,268 +1,268 b''
1 # If you want to change PREFIX, do not just edit it below. The changed
1 # If you want to change PREFIX, do not just edit it below. The changed
2 # value wont get passed on to recursive make calls. You should instead
2 # value wont get passed on to recursive make calls. You should instead
3 # override the variable on the command like:
3 # override the variable on the command like:
4 #
4 #
5 # % make PREFIX=/opt/ install
5 # % make PREFIX=/opt/ install
6
6
7 export PREFIX=/usr/local
7 export PREFIX=/usr/local
8
8
9 # Default to Python 3.
9 # Default to Python 3.
10 #
10 #
11 # Windows ships Python 3 as `python.exe`.
11 # Windows ships Python 3 as `python.exe`, which may not be on PATH. py.exe is.
12 ifeq ($(OS),Windows_NT)
12 ifeq ($(OS),Windows_NT)
13 PYTHON?=python
13 PYTHON?=py -3
14 else
14 else
15 PYTHON?=python3
15 PYTHON?=python3
16 endif
16 endif
17
17
18 PYOXIDIZER?=pyoxidizer
18 PYOXIDIZER?=pyoxidizer
19
19
20 $(eval HGROOT := $(shell pwd))
20 $(eval HGROOT := $(shell pwd))
21 HGPYTHONS ?= $(HGROOT)/build/pythons
21 HGPYTHONS ?= $(HGROOT)/build/pythons
22 PURE=
22 PURE=
23 PYFILESCMD=find mercurial hgext doc -name '*.py'
23 PYFILESCMD=find mercurial hgext doc -name '*.py'
24 PYFILES:=$(shell $(PYFILESCMD))
24 PYFILES:=$(shell $(PYFILESCMD))
25 DOCFILES=mercurial/helptext/*.txt
25 DOCFILES=mercurial/helptext/*.txt
26 export LANGUAGE=C
26 export LANGUAGE=C
27 export LC_ALL=C
27 export LC_ALL=C
28 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
28 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
29 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
29 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
30 CARGO = cargo
30 CARGO = cargo
31
31
32 # Set this to e.g. "mingw32" to use a non-default compiler.
32 # Set this to e.g. "mingw32" to use a non-default compiler.
33 COMPILER=
33 COMPILER=
34
34
35 COMPILERFLAG_tmp_ =
35 COMPILERFLAG_tmp_ =
36 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
36 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
37 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
37 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
38
38
39 help:
39 help:
40 @echo 'Commonly used make targets:'
40 @echo 'Commonly used make targets:'
41 @echo ' all - build program and documentation'
41 @echo ' all - build program and documentation'
42 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
42 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
43 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
43 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
44 @echo ' local - build for inplace usage'
44 @echo ' local - build for inplace usage'
45 @echo ' tests - run all tests in the automatic test suite'
45 @echo ' tests - run all tests in the automatic test suite'
46 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
46 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
47 @echo ' dist - run all tests and create a source tarball in dist/'
47 @echo ' dist - run all tests and create a source tarball in dist/'
48 @echo ' clean - remove files created by other targets'
48 @echo ' clean - remove files created by other targets'
49 @echo ' (except installed files or dist source tarball)'
49 @echo ' (except installed files or dist source tarball)'
50 @echo ' update-pot - update i18n/hg.pot'
50 @echo ' update-pot - update i18n/hg.pot'
51 @echo
51 @echo
52 @echo 'Example for a system-wide installation under /usr/local:'
52 @echo 'Example for a system-wide installation under /usr/local:'
53 @echo ' make all && su -c "make install" && hg version'
53 @echo ' make all && su -c "make install" && hg version'
54 @echo
54 @echo
55 @echo 'Example for a local installation (usable in this directory):'
55 @echo 'Example for a local installation (usable in this directory):'
56 @echo ' make local && ./hg version'
56 @echo ' make local && ./hg version'
57
57
58 all: build doc
58 all: build doc
59
59
60 local:
60 local:
61 $(PYTHON) setup.py $(PURE) \
61 $(PYTHON) setup.py $(PURE) \
62 build_py -c -d . \
62 build_py -c -d . \
63 build_ext $(COMPILERFLAG) -i \
63 build_ext $(COMPILERFLAG) -i \
64 build_hgexe $(COMPILERFLAG) -i \
64 build_hgexe $(COMPILERFLAG) -i \
65 build_mo
65 build_mo
66 env HGRCPATH= $(PYTHON) hg version
66 env HGRCPATH= $(PYTHON) hg version
67
67
68 build:
68 build:
69 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
69 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
70
70
71 wheel:
71 wheel:
72 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
72 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
73
73
74 doc:
74 doc:
75 $(MAKE) -C doc
75 $(MAKE) -C doc
76
76
77 cleanbutpackages:
77 cleanbutpackages:
78 rm -f hg.exe
78 rm -f hg.exe
79 -$(PYTHON) setup.py clean --all # ignore errors from this command
79 -$(PYTHON) setup.py clean --all # ignore errors from this command
80 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
80 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
81 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
81 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
82 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
82 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
83 rm -f mercurial/__modulepolicy__.py
83 rm -f mercurial/__modulepolicy__.py
84 if test -d .hg; then rm -f mercurial/__version__.py; fi
84 if test -d .hg; then rm -f mercurial/__version__.py; fi
85 rm -rf build mercurial/locale
85 rm -rf build mercurial/locale
86 $(MAKE) -C doc clean
86 $(MAKE) -C doc clean
87 $(MAKE) -C contrib/chg distclean
87 $(MAKE) -C contrib/chg distclean
88 rm -rf rust/target
88 rm -rf rust/target
89 rm -f mercurial/rustext.so
89 rm -f mercurial/rustext.so
90
90
91 clean: cleanbutpackages
91 clean: cleanbutpackages
92 rm -rf packages
92 rm -rf packages
93
93
94 install: install-bin install-doc
94 install: install-bin install-doc
95
95
96 install-bin: build
96 install-bin: build
97 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
97 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
98
98
99 install-doc: doc
99 install-doc: doc
100 cd doc && $(MAKE) $(MFLAGS) install
100 cd doc && $(MAKE) $(MFLAGS) install
101
101
102 install-home: install-home-bin install-home-doc
102 install-home: install-home-bin install-home-doc
103
103
104 install-home-bin: build
104 install-home-bin: build
105 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
105 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
106
106
107 install-home-doc: doc
107 install-home-doc: doc
108 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
108 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
109
109
110 MANIFEST-doc:
110 MANIFEST-doc:
111 $(MAKE) -C doc MANIFEST
111 $(MAKE) -C doc MANIFEST
112
112
113 MANIFEST.in: MANIFEST-doc
113 MANIFEST.in: MANIFEST-doc
114 hg manifest | sed -e 's/^/include /' > MANIFEST.in
114 hg manifest | sed -e 's/^/include /' > MANIFEST.in
115 echo include mercurial/__version__.py >> MANIFEST.in
115 echo include mercurial/__version__.py >> MANIFEST.in
116 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
116 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
117
117
118 dist: tests dist-notests
118 dist: tests dist-notests
119
119
120 dist-notests: doc MANIFEST.in
120 dist-notests: doc MANIFEST.in
121 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
121 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
122
122
123 check: tests
123 check: tests
124
124
125 tests:
125 tests:
126 # Run Rust tests if cargo is installed
126 # Run Rust tests if cargo is installed
127 if command -v $(CARGO) >/dev/null 2>&1; then \
127 if command -v $(CARGO) >/dev/null 2>&1; then \
128 $(MAKE) rust-tests; \
128 $(MAKE) rust-tests; \
129 fi
129 fi
130 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
130 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
131
131
132 test-%:
132 test-%:
133 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
133 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
134
134
135 testpy-%:
135 testpy-%:
136 @echo Looking for Python $* in $(HGPYTHONS)
136 @echo Looking for Python $* in $(HGPYTHONS)
137 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
137 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
138 cd $$(mktemp --directory --tmpdir) && \
138 cd $$(mktemp --directory --tmpdir) && \
139 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
139 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
140 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
140 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
141
141
142 rust-tests: py_feature = $(shell $(PYTHON) -c \
142 rust-tests: py_feature = $(shell $(PYTHON) -c \
143 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
143 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
144 rust-tests:
144 rust-tests:
145 cd $(HGROOT)/rust/hg-cpython \
145 cd $(HGROOT)/rust/hg-cpython \
146 && $(CARGO) test --quiet --all \
146 && $(CARGO) test --quiet --all \
147 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
147 --no-default-features --features "$(py_feature) $(HG_RUST_FEATURES)"
148
148
149 check-code:
149 check-code:
150 hg manifest | xargs python contrib/check-code.py
150 hg manifest | xargs python contrib/check-code.py
151
151
152 format-c:
152 format-c:
153 clang-format --style file -i \
153 clang-format --style file -i \
154 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
154 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
155
155
156 update-pot: i18n/hg.pot
156 update-pot: i18n/hg.pot
157
157
158 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
158 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
159 $(PYTHON) i18n/hggettext mercurial/commands.py \
159 $(PYTHON) i18n/hggettext mercurial/commands.py \
160 hgext/*.py hgext/*/__init__.py \
160 hgext/*.py hgext/*/__init__.py \
161 mercurial/fileset.py mercurial/revset.py \
161 mercurial/fileset.py mercurial/revset.py \
162 mercurial/templatefilters.py \
162 mercurial/templatefilters.py \
163 mercurial/templatefuncs.py \
163 mercurial/templatefuncs.py \
164 mercurial/templatekw.py \
164 mercurial/templatekw.py \
165 mercurial/filemerge.py \
165 mercurial/filemerge.py \
166 mercurial/hgweb/webcommands.py \
166 mercurial/hgweb/webcommands.py \
167 mercurial/util.py \
167 mercurial/util.py \
168 $(DOCFILES) > i18n/hg.pot.tmp
168 $(DOCFILES) > i18n/hg.pot.tmp
169 # All strings marked for translation in Mercurial contain
169 # All strings marked for translation in Mercurial contain
170 # ASCII characters only. But some files contain string
170 # ASCII characters only. But some files contain string
171 # literals like this '\037\213'. xgettext thinks it has to
171 # literals like this '\037\213'. xgettext thinks it has to
172 # parse them even though they are not marked for translation.
172 # parse them even though they are not marked for translation.
173 # Extracting with an explicit encoding of ISO-8859-1 will make
173 # Extracting with an explicit encoding of ISO-8859-1 will make
174 # xgettext "parse" and ignore them.
174 # xgettext "parse" and ignore them.
175 $(PYFILESCMD) | xargs \
175 $(PYFILESCMD) | xargs \
176 xgettext --package-name "Mercurial" \
176 xgettext --package-name "Mercurial" \
177 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
177 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
178 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
178 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
179 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
179 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
180 -d hg -p i18n -o hg.pot.tmp
180 -d hg -p i18n -o hg.pot.tmp
181 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
181 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
182 # The target file is not created before the last step. So it never is in
182 # The target file is not created before the last step. So it never is in
183 # an intermediate state.
183 # an intermediate state.
184 mv -f i18n/hg.pot.tmp i18n/hg.pot
184 mv -f i18n/hg.pot.tmp i18n/hg.pot
185
185
186 %.po: i18n/hg.pot
186 %.po: i18n/hg.pot
187 # work on a temporary copy for never having a half completed target
187 # work on a temporary copy for never having a half completed target
188 cp $@ $@.tmp
188 cp $@ $@.tmp
189 msgmerge --no-location --update $@.tmp $^
189 msgmerge --no-location --update $@.tmp $^
190 mv -f $@.tmp $@
190 mv -f $@.tmp $@
191
191
192 # Packaging targets
192 # Packaging targets
193
193
194 packaging_targets := \
194 packaging_targets := \
195 centos7 \
195 centos7 \
196 centos8 \
196 centos8 \
197 deb \
197 deb \
198 docker-centos7 \
198 docker-centos7 \
199 docker-centos8 \
199 docker-centos8 \
200 docker-debian-bullseye \
200 docker-debian-bullseye \
201 docker-debian-buster \
201 docker-debian-buster \
202 docker-debian-stretch \
202 docker-debian-stretch \
203 docker-fedora \
203 docker-fedora \
204 docker-ubuntu-trusty \
204 docker-ubuntu-trusty \
205 docker-ubuntu-trusty-ppa \
205 docker-ubuntu-trusty-ppa \
206 docker-ubuntu-xenial \
206 docker-ubuntu-xenial \
207 docker-ubuntu-xenial-ppa \
207 docker-ubuntu-xenial-ppa \
208 docker-ubuntu-artful \
208 docker-ubuntu-artful \
209 docker-ubuntu-artful-ppa \
209 docker-ubuntu-artful-ppa \
210 docker-ubuntu-bionic \
210 docker-ubuntu-bionic \
211 docker-ubuntu-bionic-ppa \
211 docker-ubuntu-bionic-ppa \
212 fedora \
212 fedora \
213 linux-wheels \
213 linux-wheels \
214 linux-wheels-x86_64 \
214 linux-wheels-x86_64 \
215 linux-wheels-i686 \
215 linux-wheels-i686 \
216 ppa
216 ppa
217
217
218 # Forward packaging targets for convenience.
218 # Forward packaging targets for convenience.
219 $(packaging_targets):
219 $(packaging_targets):
220 $(MAKE) -C contrib/packaging $@
220 $(MAKE) -C contrib/packaging $@
221
221
222 osx:
222 osx:
223 rm -rf build/mercurial
223 rm -rf build/mercurial
224 /usr/bin/python2.7 setup.py install --optimize=1 \
224 /usr/bin/python2.7 setup.py install --optimize=1 \
225 --root=build/mercurial/ --prefix=/usr/local/ \
225 --root=build/mercurial/ --prefix=/usr/local/ \
226 --install-lib=/Library/Python/2.7/site-packages/
226 --install-lib=/Library/Python/2.7/site-packages/
227 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
227 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
228 # Place a bogon .DS_Store file in the target dir so we can be
228 # Place a bogon .DS_Store file in the target dir so we can be
229 # sure it doesn't get included in the final package.
229 # sure it doesn't get included in the final package.
230 touch build/mercurial/.DS_Store
230 touch build/mercurial/.DS_Store
231 # install zsh completions - this location appears to be
231 # install zsh completions - this location appears to be
232 # searched by default as of macOS Sierra.
232 # searched by default as of macOS Sierra.
233 install -d build/mercurial/usr/local/share/zsh/site-functions/
233 install -d build/mercurial/usr/local/share/zsh/site-functions/
234 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
234 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
235 # install bash completions - there doesn't appear to be a
235 # install bash completions - there doesn't appear to be a
236 # place that's searched by default for bash, so we'll follow
236 # place that's searched by default for bash, so we'll follow
237 # the lead of Apple's git install and just put it in a
237 # the lead of Apple's git install and just put it in a
238 # location of our own.
238 # location of our own.
239 install -d build/mercurial/usr/local/hg/contrib/
239 install -d build/mercurial/usr/local/hg/contrib/
240 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
240 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
241 make -C contrib/chg \
241 make -C contrib/chg \
242 HGPATH=/usr/local/bin/hg \
242 HGPATH=/usr/local/bin/hg \
243 PYTHON=/usr/bin/python2.7 \
243 PYTHON=/usr/bin/python2.7 \
244 DESTDIR=../../build/mercurial \
244 DESTDIR=../../build/mercurial \
245 PREFIX=/usr/local \
245 PREFIX=/usr/local \
246 clean install
246 clean install
247 mkdir -p $${OUTPUTDIR:-dist}
247 mkdir -p $${OUTPUTDIR:-dist}
248 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
248 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
249 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
249 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
250 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
250 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
251 --identifier org.mercurial-scm.mercurial \
251 --identifier org.mercurial-scm.mercurial \
252 --version "$${HGVER}" \
252 --version "$${HGVER}" \
253 build/mercurial.pkg && \
253 build/mercurial.pkg && \
254 productbuild --distribution contrib/packaging/macosx/distribution.xml \
254 productbuild --distribution contrib/packaging/macosx/distribution.xml \
255 --package-path build/ \
255 --package-path build/ \
256 --version "$${HGVER}" \
256 --version "$${HGVER}" \
257 --resources contrib/packaging/macosx/ \
257 --resources contrib/packaging/macosx/ \
258 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
258 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
259
259
260 pyoxidizer:
260 pyoxidizer:
261 $(PYOXIDIZER) build --path ./rust/hgcli --release
261 $(PYOXIDIZER) build --path ./rust/hgcli --release
262
262
263 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
263 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
264 install-doc install-home install-home-bin install-home-doc \
264 install-doc install-home install-home-bin install-home-doc \
265 dist dist-notests check tests rust-tests check-code format-c \
265 dist dist-notests check tests rust-tests check-code format-c \
266 update-pot pyoxidizer \
266 update-pot pyoxidizer \
267 $(packaging_targets) \
267 $(packaging_targets) \
268 osx
268 osx
General Comments 0
You need to be logged in to leave comments. Login now