[PATCH 1 of 2] setup: test setproctitle before building osutil

Jun Wu quark at fb.com
Fri Nov 11 16:23:08 EST 2016


Sorry, I forgot to use --flag V2.

V1 was at https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-August/087134.html

V2 replaces the prctl approach to the Py_GetArgcArgv + argv rewrite
approach. Good news is it supports OS X. Bad news is it won't work in
Python 3 - Python 3 copies argv and returns the wchar_t version.

Excerpts from Jun Wu's message of 2016-11-11 21:14:36 +0000:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1478897140 0
> #      Fri Nov 11 20:45:40 2016 +0000
> # Node ID 98761d64eaaf67f3bdb99f3f80a57910e2624b78
> # Parent  038547a14d850f14ecd2671852093dc07848a134
> # Available At https://bitbucket.org/quark-zju/hg-draft 
> #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 98761d64eaaf
> setup: test setproctitle before building osutil
> 
> We are going to use setproctitle (provided by FreeBSD) if it's available in
> the next patch. Therefore provide a macro to give some clues to the C
> pre-processor so it could choose code path wisely.
> 
> diff --git a/setup.py b/setup.py
> --- a/setup.py
> +++ b/setup.py
> @@ -68,4 +68,5 @@ if 'FORCE_SETUPTOOLS' in os.environ:
>  else:
>      from distutils.core import setup
> +from distutils.ccompiler import new_compiler
>  from distutils.core import Command, Extension
>  from distutils.dist import Distribution
> @@ -554,6 +555,12 @@ common_depends = ['mercurial/bitmanipula
>                    'mercurial/util.h']
>  
> +osutil_cflags = []
>  osutil_ldflags = []
>  
> +# platform specific macros: HAVE_SETPROCTITLE
> +for plat, func in [(re.compile('freebsd'), 'setproctitle')]:
> +    if plat.search(sys.platform) and hasfunction(new_compiler(), func):
> +        osutil_cflags.append('-DHAVE_%s' % func.upper())
> +
>  if sys.platform == 'darwin':
>      osutil_ldflags += ['-framework', 'ApplicationServices']
> @@ -576,4 +583,5 @@ extmodules = [
>                depends=common_depends),
>      Extension('mercurial.osutil', ['mercurial/osutil.c'],
> +              extra_compile_args=osutil_cflags,
>                extra_link_args=osutil_ldflags,
>                depends=common_depends),


More information about the Mercurial-devel mailing list