This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

setuphelpers

Helper functions for writing setup.py’s.

Helper functions

setuphelpers provides the following:

git_version

Use to supply your package’s version string from git. If the latest commit is tagged, the version will be that tag. If it is not tagged, it will be the last version + 1 minor/patch version .devN number of commits since last tag. If building off a branch other than master, the branch name is used as a local version identifier.

Examples: 0.0.1, 0.0.2.dev1, 0.0.2.dev1+featureX

from setuptools import setup
from setuphelpers import git_version

setup(name="my_thing", version=git_version())

Note that you cannot deploy a sdist package using git_version, due to needing access to .git. But please don’t start including .git’s in your packages. There is a pattern you can use to have git_version write out to a file to include, but I would argue that there’s not a need to do that, as it’s already included in the written package metadata anyway (wheels > *). But if you must:

import os
import io
from setuptools import setup
from setuphelpers import git_version
from setuphelpers import find_version

# VER_FILE should not exist in your checked in source
VER_FILE = os.path.join("my_thing", "__version__.py")
if os.path.isfile(VER_FILE):
    # this should only be run during rebuilding a sdist package
    VERSION = find_version(VER_FILE)
else:
    # this should be run only during the actual packaging
    VERSION = git_version()
    with io.open(VER_FILE, "w", encoding="utf-8") as openversion:
        openversion.write('__version__ = "{}"'.format(VERSION))

setup(name="my_thing", version=VERSION)

long_description

Use to fill in the long_description field with the contents of your README. If no README is found, will fallback to the docstring of your setup.py.

from setuptools import setup
from setuphelpers import long_description

setup(name="my_thing", version="1.0", long_description=long_description())

find_version

Used to find the value assigned to __version__ in the specified filepath.

from setuptools import setup
from setuphelpers import find_version

setup(name="my_thing", version=find_version("my_thing/__init__.py"))

test_command

Used to build a test command class for running unit tests with python setup.py test. Default support is for py.test, but nose and unittest are also both possible. The return from test_command can be passed to cmdclass.

Note that the tests_require dependancies still need to be provided, including coverage, if you’re using it (plus whatever else you need to test with).

from setuptools import setup
from setuphelpers import test_command

setup(
    name="my_thing",
    version="1.0",
    tests_require=["pytest", "pytest-cov"],
    cmdclass=test_command(cover="my_thing"),
)

A note on setup_requires

You can (and should) put setuphelpers in the setup_requires argument of your setup.py. But you also need to be careful to avoid dependency problems during build. To accomplish this, you can use this pattern (for each/any of the used functions):

from setuptools import setup
try:
    from setuphelpers import (
        find_version,  # not used, but for completeness
        git_version,
        long_description,
        test_command,
    )
except ImportError:
    find_version = lambda x: "0.0.0"
    git_version = lambda: "0.0.0"
    long_description = lambda: __doc__
    test_command = lambda **_: {}


setup(
    name="my_thing",
    version=git_version(),  # find_version("my_thing/__init__.py"),
    description=long_description(),
    tests_require=["pytest", "pytest-cov"],
    setup_requires=["setuphelpers"],
    cmdclass=test_command(cover="my_thing"),
)

Now python setup.py install should pull in setuphelpers if it’s missing, and re-exec itself to fill in the arguments as expected. You need to manually avoid both the ImportError and the NameError though, so mock callables need to be created in the case of missing setuphelpers.

Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.8

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.7

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
setuphelpers-0.1.0-py2.py3-none-any.whl (10.2 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Aug 9, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting