Skip to main content

travis versions pypi

Introduction

pkutils is a Python library that simplifies python module packaging. It is intended to be used in your package’s setup.py file.

With pkutils, you can

  • Parse requirements files

  • Determine your project’s development status

  • Read text files

  • and much more…

Requirements

pkutils has been tested and is known to work on the following Python versions:

  • 2.7

  • 3.4

  • 3.5

  • pypy

Motivation

Python has a great packaging system, but to actually create and publish a package requires a lot of work to do well. I designed pkutils to provide many useful packaging use-cases out of the box. For example, to automatically include the contents of your requirements.txt file, simply add the following to setup.py:

import pkutils

...

requirements = list(pkutils.parse_requirements('requirements.txt'))
dev_requirements = list(pkutils.parse_requirements('dev-requirements.txt'))

setup(
    ...
    install_requires=requirements,
    tests_require=dev_requirements,
    ...)

Usage

pkutils is intended to be used directly as a Python library.

setup.py

import pkutils
import my_module

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

requirements = list(pkutils.parse_requirements('requirements.txt'))
dependencies = list(pkutils.parse_requirements('requirements.txt', True))
dev_requirements = list(pkutils.parse_requirements('dev-requirements.txt'))
readme = pkutils.read('README.rst')
version = my_module.__version__
project = my_module.__title__
user = 'reubano'

setup(
    long_description=readme,
    install_requires=requirements,
    tests_require=dev_requirements,
    dependency_links=dependencies,
    url=pkutils.get_url(project, user),
    download_url=pkutils.get_dl_url(project, user, version),
    classifiers=[
        pkutils.LICENSES['MIT'],
        pkutils.get_status(version),
        ...
    ],
    ...
)

This is then converted into something like the following:

...

setup(
    long_description='pkutils: a Python packaging library...',
    install_requires=['semver==2.2.1'],
    tests_require=['semver==2.2.1', 'wheel==0.24.0', 'flake8==2.5.1', ...],
    dependency_links=[],
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Development Status :: 3 - Alpha',
        ...
    ],
    ...
)

Installation

(You are using a virtualenv, right?) [1]

At the command line, install pkutils using either pip (recommended)

pip install pkutils

or easy_install

easy_install pkutils

Project structure

┌── CHANGES.rst
├── CONTRIBUTING.rst
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.md
├── dev-requirements.txt
├── helpers
│   ├── check-stage
│   ├── clean
│   ├── srcdist
│   ├── test
│   └── wheel
├── manage.py
├── pkutils.py
├── requirements.txt
├── setup.cfg
├── setup.py
├── tests
│   ├── __init__.py
│   └── standard.rc
└── tox.ini

Design Principles

  • minimize external dependencies

  • prefer functions over objects

  • keep the API as simple as possible

Scripts

pkutils comes with a built in task manager manage.py

Setup

pip install -r dev-requirements.txt

Examples

View available commands

manage

Show help for a given command

manage <command> -h

Run python linter and nose tests

manage lint
manage test

Or if make is more your speed…

make lint
make test

License

pkutils is distributed under the MIT License.

Contributing

Please mimic the coding style/conventions used in this repo. If you add new classes or functions, please add the appropriate doc blocks with examples. Also, make sure the python linter and nose tests pass.

Please see the contributing doc for more details.

Footnotes

If you have virtualenvwrapper installed, at the command line type:

mkvirtualenv pkutils
pip install pkutils

Or, if you only have virtualenv installed:

virtualenv ~/.venvs/pkutils
source ~/.venvs/pkutils/bin/activate
pip install pkutils

Otherwise, you can install globally:

pip install pkutils

Metadata

Release files for pkutils 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pkutils 0.11.0
File Size Uploaded
pkutils-0.11.0.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pkutils 0.11.0
File Interpreter ABI Platform
pkutils-0.11.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.0 kB

Release files / pkutils-0.11.0.tar.gz

Download URL pkutils-0.11.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a262bb7b750de36269ce4f0723433215aebbb528fecd3fe642faab7a6c5adddd
BLAKE2b-256 checksum
How to use checksums
c71055196582f2340e273d709338f6fc6f0dbcd8d618809b2f9be70d1d97f380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pkutils-0.11.0-py2.py3-none-any.whl

Download URL pkutils-0.11.0-py2.py3-none-any.whl
Size 8.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
734ea38cf9f942056c862bffd07c42769c974060d6d98ee6ca82418bfb870f73
BLAKE2b-256 checksum
How to use checksums
dc0d515225f4ffa798cb7d84f7c729a2471c4130b51b947932a60dc0204b5e14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.13.6

2 release files

0.13.5

2 release files

0.13.4

2 release files

0.13.3

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.4

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.0

2 release files

0.11.1

2 release files

This release

0.11.0 This release

2 release files

0.10.2

2 release files

0.10.0

2 release files

0.6.1

1 release file

0.6.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page