##// END OF EJS Templates
wix: functionality to automate building WiX installers...
wix: functionality to automate building WiX installers Like we did for Inno Setup, we want to make it easier to produce WiX installers. This commit does that. We introduce a new hgpackaging.wix module for performing all the high-level tasks required to produce WiX installers. This required miscellaneous enhancements to existing code in hgpackaging, including support for signing binaries. A new build.py script for calling into the module APIs has been created. It behaves very similarly to the Inno Setup build.py script. Unlike Inno Setup, we didn't have code in the repo previously to generate WiX installers. It appears that all existing automation for building WiX installers lives in the https://bitbucket.org/tortoisehg/thg-winbuild repository - most notably in its setup.py file. My strategy for inventing the code in this commit was to step through the code in that repo's setup.py and observe what it was doing. Despite the length of setup.py in that repository, the actual amount of steps required to produce a WiX installer is actually quite low. It consists of a basic py2exe build plus invocations of candle.exe and light.exe to produce the MSI. One rabbit hole that gave me fits was locating the Visual Studio 9 C Runtime merge modules. These merge modules are only present on your system if you have a full Visual Studio 2008 installation. Fortunately, I have a copy of Visual Studio 2008 and was able to install all the required updates. I then uploaded these merge modules to a personal repository on GitHub. That is where the added code references them from. We probably don't need to ship the merge modules. But that is for another day. The installs from the MSIs produced with the new automation differ from the last official MSI in the following ways: * Our HTML manual pages have UNIX line endings instead of Windows. * We ship modules in the mercurial.pure package. It appears the upstream packaging code is not including this package due to omission (they supply an explicit list of packages that has drifted out of sync with our setup.py). * We do not ship various distutils.* modules. This is because virtualenvs have a custom distutils/__init__.py that automagically imports distutils from its original location and py2exe gets confused by this. We don't use distutils in core Mercurial and don't provide a usable python.exe, so this omission should be acceptable. * The version of the enum package is different and we ship an enum.pyc instead of an enum/__init__.py. * The version of the docutils package is different and we ship a different set of files. * The version of Sphinx is drastically newer and we ship a number of files the old version did not. (I'm not sure why we ship Sphinx - I think it is a side-effect of the way the THG code was installing dependencies.) * We ship the idna package (dependent of requests which is a dependency of newer versions of Sphinx). * The version of imagesize is different and we ship an imagesize.pyc instead of an imagesize/__init__.pyc. * The version of the jinja2 package is different and the sets of files differs. * We ship the packaging package, which is a dependency for Sphinx. * The version of the pygments package is different and the sets of files differs. * We ship the requests package, which is a dependency for Sphinx. * We ship the snowballstemmer package, which is a dependency for Sphinx. * We ship the urllib3 package, which is a dependency for requests, which is a dependency for Sphinx. * We ship a newer version of the futures package, which includes a handful of extra modules that match Python 3 module names. # no-check-commit because foo_bar naming Differential Revision: https://phab.mercurial-scm.org/D6097

File last commit:

r40157:73fef626 default
r42087:4371f543 default
Show More
python-zstandard.h
373 lines | 8.8 KiB | text/x-c | CLexer
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 /**
* Copyright (c) 2016-present, Gregory Szorc
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 #include "structmember.h"
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
#define ZSTD_STATIC_LINKING_ONLY
#define ZDICT_STATIC_LINKING_ONLY
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 #include <zstd.h>
#include <zdict.h>
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 /* Remember to change the string in zstandard/__init__ as well */
#define PYTHON_ZSTANDARD_VERSION "0.10.1"
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
typedef enum {
compressorobj_flush_finish,
compressorobj_flush_block,
} CompressorObj_Flush;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 Represents a ZstdCompressionParameters type.
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 This type holds all the low-level compression parameters that can be set.
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 ZSTD_CCtx_params* params;
unsigned format;
int compressionLevel;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 unsigned windowLog;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned hashLog;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 unsigned chainLog;
unsigned searchLog;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned minMatch;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 unsigned targetLength;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned compressionStrategy;
unsigned contentSizeFlag;
unsigned checksumFlag;
unsigned dictIDFlag;
unsigned threads;
unsigned jobSize;
unsigned overlapSizeLog;
unsigned forceMaxWindow;
unsigned enableLongDistanceMatching;
unsigned ldmHashLog;
unsigned ldmMinMatch;
unsigned ldmBucketSizeLog;
unsigned ldmHashEveryLog;
} ZstdCompressionParametersObject;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 extern PyTypeObject ZstdCompressionParametersType;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a FrameParameters type.
This type is basically a wrapper around ZSTD_frameParams.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 unsigned long long frameContentSize;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned long long windowSize;
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 unsigned dictID;
char checksumFlag;
} FrameParametersObject;
extern PyTypeObject FrameParametersType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a ZstdCompressionDict type.
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 Instances hold data used for a zstd compression dictionary.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Pointer to dictionary data. Owned by self. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 void* dictData;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Size of dictionary data. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 size_t dictSize;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 ZSTD_dictContentType_e dictType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* k parameter for cover dictionaries. Only populated by train_cover_dict(). */
unsigned k;
/* d parameter for cover dictionaries. Only populated by train_cover_dict(). */
unsigned d;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 /* Digested dictionary, suitable for reuse. */
ZSTD_CDict* cdict;
ZSTD_DDict* ddict;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionDict;
extern PyTypeObject ZstdCompressionDictType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a ZstdCompressor type.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Number of threads to use for operations. */
unsigned int threads;
/* Pointer to compression dictionary to use. NULL if not using dictionary
compression. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdCompressionDict* dict;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 /* Compression context to use. Populated during object construction. */
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 ZSTD_CCtx* cctx;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 /* Compression parameters in use. */
ZSTD_CCtx_params* params;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressor;
extern PyTypeObject ZstdCompressorType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
ZSTD_outBuffer output;
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 int finished;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionObj;
extern PyTypeObject ZstdCompressionObjType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* writer;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned long long sourceSize;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 size_t outSize;
int entered;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 unsigned long long bytesCompressed;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionWriter;
extern PyTypeObject ZstdCompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* reader;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 Py_buffer buffer;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 Py_ssize_t bufferOffset;
size_t inSize;
size_t outSize;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
int finishedOutput;
int finishedInput;
PyObject* readResult;
} ZstdCompressorIterator;
extern PyTypeObject ZstdCompressorIteratorType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 ZstdCompressor* compressor;
PyObject* reader;
Py_buffer buffer;
size_t readSize;
int entered;
int closed;
unsigned long long bytesCompressed;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
int finishedInput;
int finishedOutput;
PyObject* readResult;
} ZstdCompressionReader;
extern PyTypeObject ZstdCompressionReaderType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstandard: vendor python-zstandard 0.10.1...
r40157 ZstdCompressor* compressor;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
Py_buffer inBuffer;
int finished;
size_t chunkSize;
} ZstdCompressionChunker;
extern PyTypeObject ZstdCompressionChunkerType;
typedef enum {
compressionchunker_mode_normal,
compressionchunker_mode_flush,
compressionchunker_mode_finish,
} CompressionChunkerMode;
typedef struct {
PyObject_HEAD
ZstdCompressionChunker* chunker;
CompressionChunkerMode mode;
} ZstdCompressionChunkerIterator;
extern PyTypeObject ZstdCompressionChunkerIteratorType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 ZSTD_DCtx* dctx;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdCompressionDict* dict;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 size_t maxWindowSize;
ZSTD_format_e format;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdDecompressor;
extern PyTypeObject ZstdDecompressorType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 size_t outSize;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 int finished;
} ZstdDecompressionObj;
extern PyTypeObject ZstdDecompressionObjType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 /* Parent decompressor to which this object is associated. */
ZstdDecompressor* decompressor;
/* Object to read() from (if reading from a stream). */
PyObject* reader;
/* Size for read() operations on reader. */
size_t readSize;
/* Buffer to read from (if reading from a buffer). */
Py_buffer buffer;
/* Whether the context manager is active. */
int entered;
/* Whether we've closed the stream. */
int closed;
/* Number of bytes decompressed and returned to user. */
unsigned long long bytesDecompressed;
/* Tracks data going into decompressor. */
ZSTD_inBuffer input;
/* Holds output from read() operation on reader. */
PyObject* readResult;
/* Whether all input has been sent to the decompressor. */
int finishedInput;
/* Whether all output has been flushed from the decompressor. */
int finishedOutput;
} ZstdDecompressionReader;
extern PyTypeObject ZstdDecompressionReaderType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdDecompressor* decompressor;
PyObject* writer;
size_t outSize;
int entered;
} ZstdDecompressionWriter;
extern PyTypeObject ZstdDecompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
PyObject* reader;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 Py_buffer buffer;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 Py_ssize_t bufferOffset;
size_t inSize;
size_t outSize;
size_t skipBytes;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
Py_ssize_t readCount;
int finishedInput;
int finishedOutput;
} ZstdDecompressorIterator;
extern PyTypeObject ZstdDecompressorIteratorType;
typedef struct {
int errored;
PyObject* chunk;
} DecompressorIteratorResult;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 typedef struct {
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 /* The public API is that these are 64-bit unsigned integers. So these can't
* be size_t, even though values larger than SIZE_MAX or PY_SSIZE_T_MAX may
* be nonsensical for this platform. */
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 unsigned long long offset;
unsigned long long length;
} BufferSegment;
typedef struct {
PyObject_HEAD
PyObject* parent;
BufferSegment* segments;
Py_ssize_t segmentCount;
} ZstdBufferSegments;
extern PyTypeObject ZstdBufferSegmentsType;
typedef struct {
PyObject_HEAD
PyObject* parent;
void* data;
Py_ssize_t dataSize;
unsigned long long offset;
} ZstdBufferSegment;
extern PyTypeObject ZstdBufferSegmentType;
typedef struct {
PyObject_HEAD
Py_buffer parent;
void* data;
unsigned long long dataSize;
BufferSegment* segments;
Py_ssize_t segmentCount;
int useFree;
} ZstdBufferWithSegments;
extern PyTypeObject ZstdBufferWithSegmentsType;
/**
* An ordered collection of BufferWithSegments exposed as a squashed collection.
*
* This type provides a virtual view spanning multiple BufferWithSegments
* instances. It allows multiple instances to be "chained" together and
* exposed as a single collection. e.g. if there are 2 buffers holding
* 10 segments each, then o[14] will access the 5th segment in the 2nd buffer.
*/
typedef struct {
PyObject_HEAD
/* An array of buffers that should be exposed through this instance. */
ZstdBufferWithSegments** buffers;
/* Number of elements in buffers array. */
Py_ssize_t bufferCount;
/* Array of first offset in each buffer instance. 0th entry corresponds
to number of elements in the 0th buffer. 1st entry corresponds to the
sum of elements in 0th and 1st buffers. */
Py_ssize_t* firstElements;
} ZstdBufferWithSegmentsCollection;
extern PyTypeObject ZstdBufferWithSegmentsCollectionType;
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 int set_parameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value);
int set_parameters(ZSTD_CCtx_params* params, ZstdCompressionParametersObject* obj);
FrameParametersObject* get_frame_parameters(PyObject* self, PyObject* args, PyObject* kwargs);
int ensure_ddict(ZstdCompressionDict* dict);
int ensure_dctx(ZstdDecompressor* decompressor, int loadDict);
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdCompressionDict* train_dictionary(PyObject* self, PyObject* args, PyObject* kwargs);
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 ZstdBufferWithSegments* BufferWithSegments_FromMemory(void* data, unsigned long long dataSize, BufferSegment* segments, Py_ssize_t segmentsSize);
Py_ssize_t BufferWithSegmentsCollection_length(ZstdBufferWithSegmentsCollection*);
int cpu_count(void);
size_t roundpow2(size_t);
Gregory Szorc
zstandard: vendor python-zstandard 0.9.0...
r37513 int safe_pybytes_resize(PyObject** obj, Py_ssize_t size);