Skip to main content

A Python library which wraps Windows functions using CFFI

Project description

Python Windows Wrapper Using CFFI

build status build status (pylint and pep8) code coverage documentation badge

pywincffi is a wrapper around some Windows API functions using Python and the cffi library. This project was originally created to assist the Twisted project in moving away from its dependency on pywin32. Contributions to expand on the APIs which pywincffi offers are always welcome however.

The core objectives and design principles behind this project are:

  • It should be easier to to use Windows API functions both in terms of implementation and distribution.

  • Python 2.6, 2.7 and 3.x should be supported from a single code base and not require a consumer of pywincffi to worry about how they use the library.

  • Type conversion, error checking and other ‘C like’ code should be the responsibility of the library where possible.

  • APIs provided by pywincffi should mirror their Windows counterparts as closely as possible so the MSDN documentation can be more easily used as reference.

  • Documentation and error messages should be descriptive, consistent, complete and accessible. Examples should be provided for more complex use cases.

  • For contributors, it should be possible to develop and test regardless of what platform the contributor is coming from.

Development

This section gives a basic overview of the development process including the major goals. This is not comprehensive but should be a good introduction before submitting a pull request.

Support and Documentation

Besides this readme there are two other locations you can go to receive some help:

Python Version Support

This project supports Python 2.6 and up including Python 3.x. PRs, patches, tests etc that don’t include support for both 2.x and 3.x will not be merged. The aim is also the support both major versions of Python within the same code base rather than rely on tools such as 2to3, six or other libraries for the most part.

Documentation

The documentation for this this library is hosted on Read The Docs. It’s generated directly from this library using sphinx:

virtualenv env
env/bin/activate
pip install -r dev_requirements.txt
pip install -e .
cd docs
make html

The build process also builds the documentation to ensure there are not any obvious problems (including broken links).

Function Documentation

Windows API Functions are typically documented in the following format:

def DuplicateHandle(arg1, kwarg1=None):
    """
    A brief message about this function.

    .. seealso::

        <url to the MSDN API documentation for this function>

    :param type arg1:
        Brief information about this argument

    :keyword type kwarg1:
        Brief information about this keyword include it's default
        and how it's handled within the function.

    :raises SomeException:
        Some information on when this exception will be raised

    :rtype: type
    :return:
        Information about the data that's returned
    """

It’s important to note that the docs contain a seealso stanza. This is typically used to reference the MSDN documentation but may also be used to reference examples, white papers or other reference which may be useful in describing the function.

Adding new functions is covered in greater detail here

Testing

Nosetests

Tests are located in the tests/ directory. The tests themselves are run using nosetests either manually or using the setup.py file:

virtualenv env
env/bin/activate
pip install -r dev_requirements.txt
pip install -e .
nosetests tests

Continuous Integration

To consistently ensure the highest quality code, the following services are utilized to test or analyze every commit and pull request:

  • AppVeyor - Runs the unittests, builds wheel files, MSIs and other output artifacts which can be published in a release.

  • Travis - Runs the pep8 and pylint command line tools on the code base and tests. This also builds the docs so documentation problems are easily spotted.

  • Codecov - Analyses and displays code coverage results after tests have run on AppVeyor. Results are posted back to pull requests.

  • ReadTheDocs. - The official location where documentation is built and posted. This is generally for merges into the master branch however.

Vagrant

The continuous integration services above negate most of the need to setup your local workstation to handle development for pywincffi, even if you’re not running Windows. In some cases however it can be faster or easiear to work on your local machine.

If you’re not running Windows or you don’t have the tools necessary to develop pywincffi on your machine you can use Vagrant to build a Windows machine and start developing. There’s a more in depth explanation of this process located here:

https://pywincffi.readthedocs.org/en/latest/dev/vagrant.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywincffi-0.2.0.zip (44.6 kB view hashes)

Uploaded Source

Built Distributions

pywincffi-0.2.0-cp34-cp34m-win_amd64.whl (51.4 kB view hashes)

Uploaded CPython 3.4m Windows x86-64

pywincffi-0.2.0-cp34-cp34m-win32.whl (50.4 kB view hashes)

Uploaded CPython 3.4m Windows x86

pywincffi-0.2.0-cp33-cp33m-win_amd64.whl (51.4 kB view hashes)

Uploaded CPython 3.3m Windows x86-64

pywincffi-0.2.0-cp33-cp33m-win32.whl (50.4 kB view hashes)

Uploaded CPython 3.3m Windows x86

pywincffi-0.2.0-cp27-cp27m-win_amd64.whl (51.6 kB view hashes)

Uploaded CPython 2.7m Windows x86-64

pywincffi-0.2.0-cp27-cp27m-win32.whl (50.5 kB view hashes)

Uploaded CPython 2.7m Windows x86

pywincffi-0.2.0-cp26-cp26m-win_amd64.whl (51.8 kB view hashes)

Uploaded CPython 2.6m Windows x86-64

pywincffi-0.2.0-cp26-cp26m-win32.whl (50.8 kB view hashes)

Uploaded CPython 2.6m Windows x86

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page