<commit_before>python-winbuilder
=================

Tool to setup a build environment on Windows for Python projects with compiled
extensions using <NAME>'s [MinGW static compiler toolchain](
https://bitbucket.org/carlkl/mingw-w64-for-python/downloads).

This project can be used in the following contexts:

- setting up a build environment under Windows for [AppVeyor CI](
  http://appveyor.com),
- setting up a build environment under Linux & Wine for [Travis CI](
  http://travis-ci.org),
- setting up a docker-based Linux + Wine local build and debug environment.


Operations
----------

Here is the sequence of operations that are automated by the `pywinbuilder`
tool:

1. Install Python using the official `.msi` installers of Python.org if needed,
2. Install pip using [get-pip.py](https://bootstrap.pypa.io/get-pip.py),
3. Download and extract the `mingw-w64-for-python` archive,
4. Generate the `libpythonXX.dll.a` and install it in the Python `libs` folder,
5. Copy `libmsvcr90.a` or `libmsvr100.a` into the Python `libs` folder,
6. Enable the correct `specs` file for `mingw` depending on the Python version,
7. Select `mingw` as the default compiler in `distutils.cfg`
8. Install a workaround for [issue 4709](https://bugs.python.org/issue4709)
   in `distutils.cfg` (Python 2.7 64 bit only).


Install
-------

As usual:

    pip install python-winbuilder

Alternatively you can just download the [pywinbuilder.py](pywinbuilder.py)
script and replace `python -m pywinbuilder` with `python pywinbuilder.py` in
the following usage examples.


Windows usage
-------------

    SET PYTHON_HOME=C:\Python34-x64
    SET PYTHON_VERSION=3.4.2
    SET ARCH=64
    SET MINGW_HOME=C:\mingw-static
    python -m pywinbuilder

Then you can activate the build environment matching this configuration by
changing the `PATH` environment variable and proceeding with building and
testing your own code as usual:

    set PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%MINGW_HOME%\\bin;%PATH%
    cd my-python-project
    python setup.py build_ext -i
    pip install nose
    nosetests .

See the [appveyor.yml](appveyor.yml) for a more complete example.


Linux usage
-----------

This requires wine 1.6+:

    export PYTHON_HOME="C:\\Python34-x64"
    export PYTHON_VERSION="3.4.2"
    export ARCH="64"
    export MINGW_HOME="C:\\mingw-static"
    python -m pywinbuilder

See the [.travis.yml](.travis.yml) for a more complete example.

It is also possible to pass a custom `WINEPREFIX` environment variable to
isolate several build environment for different versions of Python and
architectures on the same host.


Docker usage
------------

You can use [docker](http://www.docker.com) to run a Linux container with Wine
and mingw-based build environments for many versions of Python at once. Run a
new interactive session with:

    docker run -t -i -v ~/code:/code ogrisel/python-winbuilder bash

Note that this is mounting the `~/code` folder of your host operating system
into the `/code` folder of your container. This makes it possible to access
the source code of the project you want to build.

In that session you can use:
<commit_msg>typos<commit_after>python-winbuilder
=================

Tool to setup a build environment on Windows for Python projects with compiled
extensions using Carl Kleffner's [MinGW static compiler toolchain](
https://bitbucket.org/carlkl/mingw-w64-for-python/downloads).

This project can be used in the following contexts:

- setting up a build environment under Windows for [AppVeyor CI](
  http://appveyor.com),
- setting up a build environment under Linux & Wine for [Travis CI](
  http://travis-ci.org),
- setting up a docker-based Linux + Wine local build and debug environment.


Operations
----------

Here is the sequence of operations that are automated by the `pywinbuilder`
tool:

1. Install Python using the official `.msi` installers of Python.org if needed,
2. Install pip using [get-pip.py](https://bootstrap.pypa.io/get-pip.py),
3. Download and extract the `mingw-w64-for-python` archive,
4. Generate the `libpythonXX.dll.a` and install it in the Python `libs` folder,
5. Copy `libmsvcr90.a` or `libmsvr100.a` into the Python `libs` folder,
6. Enable the correct `specs` file for `mingw` depending on the Python version,
7. Select `mingw` as the default compiler in `distutils.cfg`
8. Install a workaround for [issue 4709](https://bugs.python.org/issue4709)
   in `distutils.cfg` (Python 2.7 64 bit only).


Install
-------

As usual:

    pip install python-winbuilder

Alternatively you can just download the [pywinbuilder.py](pywinbuilder.py)
script and replace `python -m pywinbuilder` with `python pywinbuilder.py` in
the following usage examples.


Windows usage
-------------

    SET PYTHON_HOME=C:\Python34-x64
    SET PYTHON_VERSION=3.4.2
    SET ARCH=64
    SET MINGW_HOME=C:\mingw-static
    python -m pywinbuilder

Then you can activate the build environment matching this configuration by
changing the `PATH` environment variable and proceeding with building and
testing your own code as usual:

    set PATH=%PYTHON_HOME%;%PYTHON_HOME%\\Scripts;%MINGW_HOME%\\bin;%PATH%
    cd my-python-project
    python setup.py build_ext -i
    pip install nose
    nosetests .

See the [appveyor.yml](appveyor.yml) file for a more complete example.


Linux usage
-----------

This requires wine 1.6+:

    export PYTHON_HOME="C:\\Python34-x64"
    export PYTHON_VERSION="3.4.2"
    export ARCH="64"
    export MINGW_HOME="C:\\mingw-static"
    python -m pywinbuilder

See the [.travis.yml](.travis.yml) file for a more complete example.

It is also possible to pass a custom `WINEPREFIX` environment variable to
isolate several build environment for different versions of Python and
architectures on the same host.


Docker usage
------------

You can use [docker](http://www.docker.com) to run a Linux container with Wine
and mingw-based build environments for many versions of Python at once. Run a
new interactive session with:

    docker run -t -i -v ~/code:/code ogrisel/python-winbuilder bash

Note that this is mounting the `~/code` folder of your host operating system
into the `/code` folder of your container. This makes it possible to access
the source code of the project you want to build.

In that session you can use:

{'fraction_non_alphanumeric': 0.10370606012406554, 'fraction_numerical': 0.015587720693494513, 'mean_word_length': 3.7065868263473054, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '275300', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1872, 'n_words': 763}