Patchwork [2,of,8] setup: compile zstd C extension

mail settings
Submitter Gregory Szorc
Date Nov. 11, 2016, 9:23 a.m.
Message ID <32c2b8ca42a574f83426.1478856214@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17469/
State Accepted
Headers show


Gregory Szorc - Nov. 11, 2016, 9:23 a.m.
# HG changeset patch
# User Gregory Szorc <>
# Date 1478845595 28800
#      Thu Nov 10 22:26:35 2016 -0800
# Node ID 32c2b8ca42a574f83426eaa19c89a8ff51c0e6de
# Parent  55a915a256129ce6f8b6e496e0829efce86775af
setup: compile zstd C extension

Now that zstd and python-zstandard are vendored, we can start compiling
them as part of the install.

python-zstandard provides a self-contained Python function that returns
a distutils.extension.Extension, so it is really easy to add zstd
to our without having to worry about defining source files,
include paths, etc. The function even allows specifying the module
name the extension should be compiled as. This conveniently allows us
to compile the module into the "mercurial" package so "our" version
won't collide with a version installed under the canonical "zstd"
module name.


diff --git a/ b/
--- a/
+++ b/
@@ -581,6 +581,10 @@  extmodules = [
+sys.path.insert(0, 'contrib/python-zstandard')
+import setup_zstd
     from distutils import cygwinccompiler