Welcome to pkgsetcomp’s documentation!

Contents:

pkgsetcomp

GitHub | PyPi | Warehouse | ReadTheDocs | Travis-CI

https://badge.fury.io/py/pkgsetcomp.png https://travis-ci.org/westurner/pkgsetcomp.png?branch=master https://pypip.in/d/pkgsetcomp/badge.png

pkgsetcomp: compare and generate manifest / installed package reports

Features

Installing

Install from PyPi:

pip install pkgsetcomp

Install from GitHub as editable (add a pkgsetcomp.pth in site-packages):

pip install -e git+https://github.com/westurner/pkgsetcomp#egg=pkgsetcomp

Usage

Print help:

pkgsetcomp --help

Generate reports in the current directory:

pkgsetcomp

Generate a report comparing .manifest packages with installed packages:

MANIFEST="http://releases.ubuntu.com/14.04/ubuntu-14.04-desktop-amd64.manifest"
pkgsetcomp --manifest="$MANIFEST"

Installation

At the command line:

$ easy_install pkgsetcomp

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv pkgsetcomp
$ pip install pkgsetcomp

Usage

To use pkgsetcomp in a project:

import pkgsetcomp

To use pkgsetcomp as a shell command:

System Message: ERROR/3 (/var/build/user_builds/pkgsetcomp/checkouts/latest/docs/usage.rst, line 11)

Command u’pkgsetcomp –help’ failed: [Errno 2] No such file or directory

pkgsetcomp package

Submodules

pkgsetcomp.pkgsetcomp module

class pkgsetcomp.pkgsetcomp.PkgComparison[source]

Bases: pkgsetcomp.pkgsetcomp.PkgComparison

A package set comparison namedtuple with serializers

print_string()[source]

Print the minimal, also_installed, and uninstalled lists

write_package_scripts(output_dir)[source]

Generate boilerplate apt-get command scripts for minimal, also_installed, and uninstalled

Parameters:output_dir (str) – directory in which to write scripts
pkgsetcomp.pkgsetcomp.compare_package_lists(manifest, installed)[source]

Compare two sets (manifest, installed) of package names.

Parameters:
  • default (iterable) – names of packages listed in a given MANIFEST
  • installed (iterable) – names of packages installed locally
Returns:

set comparison outputs

Return type:

PkgComparison

pkgsetcomp.pkgsetcomp.ensure_file(command, filename, overwrite=False, shell=False)[source]

Run a command if a file doesn’t exist

Parameters:
  • command (str) – shell command to subprocess.call
  • filename (str) – path to os.path.exists
  • overwrite (bool) – if true, overwrite existing file
  • shell (bool) – subprocess command parsing
Returns:

None

pkgsetcomp.pkgsetcomp.get_installed_packages(cache=False, output_dir='.', output_filename='installed.pkgs.txt')[source]

Get a list of the packages in a manifest

Parameters:manifest_url (str) – path or URL of a debian/ubuntu .manifest file

Returns:

pkgsetcomp.pkgsetcomp.get_manifest_packages(cache=False, manifest_url=None, output_dir='.', output_filename='manifest.pkgs.txt')[source]

Get a list of the packages in a manifest

Parameters:manifest_url (str) – path or URL of a debian/ubuntu .manifest file

Returns:

pkgsetcomp.pkgsetcomp.get_package_lists(manifest_url='/var/build/user_builds/pkgsetcomp/checkouts/latest/pkgsetcomp/../tests/testdata/ubuntu-12.04.4-desktop-i386.manifest', cache=False, output_dir=None)[source]

Get list of installed packages and manifest packages

Generate:
installed.pkgs.txt manifest.pkgs.txt
Parameters:cache (bool) – whether to cache
Returns:tuple of lists: (installed, manifest)
pkgsetcomp.pkgsetcomp.import_apt()[source]

import apt

Returns:apt module
Return type:module
pkgsetcomp.pkgsetcomp.main()[source]

pksetcomp main method (CLI)

pkgsetcomp.pkgsetcomp.pkgsetcomp_packages_with_manifest(manifest_url, output_dir)[source]

Compare installed packages with manifest packages

Parameters:
  • manifest_url (str) – URL (or local path) to a debian/ubuntu .manifest
  • output_dir (str) – directory in which to write .pkg.sh and pkg.txt files
Returns:

output of compare_package_lists

Return type:

PkgComparison

pkgsetcomp.pkgsetcomp.read_lines(filename)[source]

Read and format lines of a file

Parameters:filename (str) – path to file to open as read-only
Returns:generator of lines

Note

this method is not unicode compatible

pkgsetcomp.pyrpo module

Module contents

pkgsetcomp module

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/westurner/pkgsetcomp/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.

Write Documentation

pkgsetcomp could always use more documentation, whether as part of the official pkgsetcomp docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/westurner/pkgsetcomp/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up pkgsetcomp for local development.

  1. Fork the pkgsetcomp repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/pkgsetcomp.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv pkgsetcomp
    $ cd pkgsetcomp/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 pkgsetcomp tests
    $ python setup.py test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, and 3.3, and for PyPy. Check https://travis-ci.org/westurner/pkgsetcomp/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_pkgsetcomp

Credits

History

0.1.4 (Unreleased)

0.1.3 (2014-05-21)

  • BLD,TST,ENH,DOC: add py.test passthrough options to ‘setup.py test’
  • DOC: add pykg setcomp api docs to index
  • DOC: docs/license.rst include LICENSE
  • DOC: README.rst :: directive

0.1.2 (2014-05-21)

  • BUG: VERSION.txt os.path.basename
  • DOC: API docs: docs/modules.rst docs/pkgsetcomp.rst
  • DOC: Release summaries in HISTORY.txt

0.1.1 (2014-05-21)

  • ENH: Read version number from VERSION.txt

0.1.0 (2014-05-21)

License

Copyright (c) 2014, Wes Turner All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of pkgsetcomp nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Indices and tables