Skip to main content
pkutils: a Python packaging library
===================================

|travis| |versions| |pypi|

Index
-----
- `Introduction`_
- `Motivation`_
- `Usage`_
- `Installation`_
- `Project structure`_
- `Design Principles`_
- `Scripts`_
- `Contributing`_
- `License`_

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 v4.0
- pypy3 v2.4

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``:

.. code-block:: python

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,
...)

.. _library:

Usage
-----

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

``setup.py``

.. code-block:: python

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:

.. code-block:: python

...

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=[],
url='https://github.com/reubano/pkutils',
download_url='https://github.com/reubano/pkutils/archive/v0.11.0.tar.gz',
classifiers=[
'License :: OSI Approved :: MIT License',
'Development Status :: 4 - Beta',
...
],
...
)

Installation
------------

(You are using a `virtualenv`_, right?) [#]_

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

.. code-block:: bash

pip install pkutils

or ``easy_install``

.. code-block:: bash

easy_install pkutils

Please see the `installation doc`_ for more details.

Project structure
-----------------

.. code-block:: bash

┌── 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
~~~~~

.. code-block:: bash

pip install -r dev-requirements.txt

Examples
~~~~~~~~

*View available commands*

.. code-block:: bash

manage

*Show help for a given command*

.. code-block:: bash

manage <command> -h

*Run python linter and nose tests*

.. code-block:: bash

manage lint
manage test

Or if ``make`` is more your speed...

.. code-block:: bash

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.

.. |travis| image:: https://img.shields.io/travis/reubano/pkutils.svg
:target: https://travis-ci.org/reubano/pkutils

.. |versions| image:: https://img.shields.io/pypi/pyversions/pkutils.svg
:target: https://pypi.python.org/pypi/pkutils

.. |pypi| image:: https://img.shields.io/pypi/v/pkutils.svg
:target: https://pypi.python.org/pypi/pkutils

.. _MIT License: http://opensource.org/licenses/MIT
.. _virtualenv: http://www.virtualenv.org/en/latest/index.html
.. _Python versions: http://www.python.org/download
.. _contributing doc: https://github.com/reubano/pkutils/blob/master/CONTRIBUTING.rst

Download files

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

Source Distribution

pkutils-0.12.4.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkutils-0.12.4-py2.py3-none-any.whl (8.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pkutils-0.12.4.tar.gz.

File metadata

  • Download URL: pkutils-0.12.4.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pkutils-0.12.4.tar.gz
Algorithm Hash digest
SHA256 f9ef8ce1d8ca98b6ea4b1239e0217c0e68128eb31d0ce735013de610ae082e25
MD5 884f07827eb76e322e08e1c7bf779fee
BLAKE2b-256 5cbe35ebc1cb1c0d6a808947cb14ebd3e785f9ad8ac0f9fbcca34dccbc8cf19f

See more details on using hashes here.

File details

Details for the file pkutils-0.12.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pkutils-0.12.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 46ea98df435d333850f5016d622b2b5aa4df6bd27d1e6f60d244c4fc41e19c1e
MD5 310180c53d2462629d47644d84d24055
BLAKE2b-256 36a5f3f0bbc3e784406e55e3cea1b4b8d91e406155cab8551bbe5b9b355a9295

See more details on using hashes here.

Release history Release notifications | RSS feed

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.13.6

2 files

0.13.5

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

This release

0.12.4 This release

2 files

0.12.3

2 files

0.12.2

2 files

0.12.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.2

2 files

0.10.0

2 files

0.6.1

1 file

0.6.0

1 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