CONTRIBUTORS
author Gregory Szorc <gregory.szorc@gmail.com>
Thu, 03 Dec 2015 21:37:01 -0800
changeset 27220 4374d819ccd5
parent 5514 c29efd272395
permissions -rw-r--r--
mercurial: implement import hook for handling C/Python modules There are a handful of modules that have both pure Python and C extension implementations. Currently, setup.py copies files from mercurial/pure/*.py to mercurial/ during the install process if C extensions are not available. This way, "import mercurial.X" will work whether C extensions are available or not. This approach has a few drawbacks. First, there aren't run-time checks verifying the C extensions are loaded when they should be. This could lead to accidental use of the slower pure Python modules. Second, the C extensions aren't compatible with PyPy and running Mercurial with PyPy requires installing Mercurial - you can't run ./hg from a source checkout. This makes developing while running PyPy somewhat difficult. This patch implements a PEP-302 import hook for finding and loading the modules with both C and Python implementations. When a module with dual implementations is requested for import, its import is handled by our import hook. The importer has a mechanism that controls what types of modules we allow to load. We call this loading behavior the "module load policy." There are 3 settings: * Only load C extensions * Only load pure Python * Try to load C and fall back to Python An environment variable allows overriding this policy at run time. This is mainly useful for developers and for performing actions against the source checkout (such as installing), which require overriding the default (strict) policy about requiring C extensions. The default mode for now is to allow both. This isn't proper and is technically backwards incompatible. However, it is necessary to implement a sane patch series that doesn't break the world during future bisections. The behavior will be corrected in future patch. We choose the main mercurial/__init__.py module for this code out of necessity: in a future world, if the custom module importer isn't registered, we'll fail to find/import certain modules when running from a pure installation. Without the magical import-time side-effects, *any* importer of mercurial.* modules would be required to call a function to register our importer. I'm not a fan of import time side effects and I initially attempted to do this. However, I was foiled by our own test harness, which has numerous `python` invoked scripts that "import mercurial" and fail because the importer isn't registered. Realizing this problem is probably present in random Python scripts that have been written over the years, I decided that sacrificing purity for backwards compatibility is necessary. Plus, if you are programming Python, "import" should probably "just work." It's worth noting that now that we have a custom module loader, it would be possible to hook up demand module proxies at this level instead of replacing __import__. We leave this work for another time, if it's even desired. This patch breaks importing in environments where Mercurial modules are loaded from a zip file (such as py2exe distributions). This will be addressed in a subsequent patch.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5514
c29efd272395 Add note to CONTRIBUTORS file
Matt Mackall <mpm@selenic.com>
parents: 2947
diff changeset
     1
[This file is here for historical purposes, all recent contributors
c29efd272395 Add note to CONTRIBUTORS file
Matt Mackall <mpm@selenic.com>
parents: 2947
diff changeset
     2
should appear in the changelog directly]
c29efd272395 Add note to CONTRIBUTORS file
Matt Mackall <mpm@selenic.com>
parents: 2947
diff changeset
     3
c29efd272395 Add note to CONTRIBUTORS file
Matt Mackall <mpm@selenic.com>
parents: 2947
diff changeset
     4
Andrea Arcangeli <andrea at suse.de>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
     5
Thomas Arendsen Hein <thomas at intevation.de>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
     6
Goffredo Baroncelli <kreijack at libero.it>
756
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
     7
Muli Ben-Yehuda <mulix at mulix.org>
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
     8
Mikael Berthe <mikael at lilotux.net>
1450
199bb2b4ed4a Add Benoit to CONTRIBUTORS
Matt Mackall <mpm@selenic.com>
parents: 1310
diff changeset
     9
Benoit Boissinot <bboissin at gmail.com>
2947
2d865068f72e Add self to contributors
Brendan Cully <brendan@kublai.com>
parents: 2162
diff changeset
    10
Brendan Cully <brendan at kublai.com>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    11
Vincent Danjean <vdanjean.ml at free.fr>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    12
Jake Edge <jake at edge2.net>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    13
Michael Fetterman <michael.fetterman at intel.com>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    14
Edouard Gomez <ed.gomez at free.fr>
1231
effff847870f CONTRIBUTORS update
mpm@selenic.com
parents: 1080
diff changeset
    15
Eric Hopper <hopper at omnifarious.org>
756
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
    16
Alecs King <alecsk at gmail.com>
1310
7e8a55c9ee5c Updated CONTRIBUTORS.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1231
diff changeset
    17
Volker Kleinfeld <Volker.Kleinfeld at gmx.de>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    18
Vadim Lebedev <vadim at mbdsys.com>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    19
Christopher Li <hg at chrisli.org>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    20
Chris Mason <mason at suse.com>
2162
dac432a521d8 Add self to CONTRIBUTORS
Colin McMillen <mcmillen@cs.cmu.edu>
parents: 2120
diff changeset
    21
Colin McMillen <mcmillen at cs.cmu.edu>
1080
253072f39205 Updated list of contributors.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 896
diff changeset
    22
Wojciech Milkowski <wmilkowski at interia.pl>
756
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
    23
Chad Netzer <chad.netzer at gmail.com>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    24
Bryan O'Sullivan <bos at serpentine.com>
756
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
    25
Vicent SeguĂ­ Pascual <vseguip at gmail.com>
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
    26
Sean Perry <shaleh at speakeasy.net>
594
0a2ffc5c906b Update CONTRIBUTORS
mpm@selenic.com
parents: 519
diff changeset
    27
Nguyen Anh Quynh <aquynh at gmail.com>
1310
7e8a55c9ee5c Updated CONTRIBUTORS.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1231
diff changeset
    28
Ollivier Robert <roberto at keltia.freenix.fr>
2120
c0994047c5ff Added my name to the contributors list.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1450
diff changeset
    29
Alexander Schremmer <alex at alexanderweb.de>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    30
Arun Sharma <arun at sharma-home.net>
1231
effff847870f CONTRIBUTORS update
mpm@selenic.com
parents: 1080
diff changeset
    31
Josef "Jeff" Sipek <jeffpc at optonline.net>
1310
7e8a55c9ee5c Updated CONTRIBUTORS.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1231
diff changeset
    32
Kevin Smith <yarcs at qualitycode.com>
1231
effff847870f CONTRIBUTORS update
mpm@selenic.com
parents: 1080
diff changeset
    33
TK Soh <teekaysoh at yahoo.com>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    34
Radoslaw Szkodzinski <astralstorm at gorzow.mm.pl>
851
73a432c8040a Added Samuel Tardieu to contributors list.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 760
diff changeset
    35
Samuel Tardieu <sam at rfc1149.net>
519
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    36
K Thananchayan <thananck at yahoo.com>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    37
Andrew Thompson <andrewkt at aktzero.com>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    38
Michael S. Tsirkin <mst at mellanox.co.il>
50768efaf6f2 Add a CONTRIBUTORS file
mpm@selenic.com
parents:
diff changeset
    39
Rafael Villar Burke <pachi at mmn-arquitectos.com>
855
a107c64c76be Added Tristan Wibberley to contributors.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 851
diff changeset
    40
Tristan Wibberley <tristan at wibberley.org>
756
5d79dfa5e98f Added new code contributors, fixed Vincent's name, added hint on encoding.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 594
diff changeset
    41
Mark Williamson <mark.williamson at cl.cam.ac.uk>