Skip to main content

Introduction

d2to1 (the ‘d’ is for ‘distutils’) allows using distutils2-like setup.cfg files for a package’s metadata with a distribute/setuptools setup.py script. It works by providing a distutils2-formatted setup.cfg file containing all of a package’s metadata, and a very minimal setup.py which will slurp its arguments from the setup.cfg.

Rationale

I’m currently in the progress of redoing the packaging of a sizeable number of projects. I wanted to use distutils2-like setup.cfg files for all these projects, as they will hopefully be the future, and I much prefer them overall to using an executable setup.py. So forward-support for distutils2 is appealing both as future-proofing, and simply the aesthetics of using a flat text file to describe a project’s metadata.

However, I did not want any of these projects to require distutils2 for installation yet–it is too unstable, and not widely installed. So projects should still be installable using the familiar ./setup.py install, for example. Furthermore, not all use cases required by some of the packages I support are fully supported by distutils2 yet. Hopefully they will be eventually, either through the distutils2 core or through extensions. But in the meantime d2to1 will try to keep up with the state of the art and “best practices” for distutils2 distributions, while adding support in areas that it’s lacking.

Usage

d2to1 requires a distribution to use distribute or setuptools. Your distribution must include a distutils2-like setup.cfg file, and a minimal setup.py script. For details on writing the setup.cfg, see the distutils2 documentation. A simple sample can be found in d2to1’s own setup.cfg (it uses its own machinery to install itself):

[metadata]
name = d2to1
version = 0.1.1
author = Erik M. Bray
author-email = embray at stsci.edu
summary = Allows using distutils2-like setup.cfg files for a package's metadata
 with a distribute/setuptools setup.py
description-file = README
license = BSD
requires-dist = setuptools
classifier =
    Development Status :: 4 - Beta
    Environment :: Plugins
    Framework :: Setuptools Plugin
    Intended Audience :: Developers
    License :: OSI Approved :: BSD License
    Operating System :: OS Independent
    Programming Language :: Python
    Topic :: Software Development :: Build Tools
    Topic :: Software Development :: Libraries :: Python Modules

[files]
packages = d2to1

The minimal setup.py should look something like this:

#!/usr/bin/env python

try:
    from setuptools import setup
except ImportError:
    from distribute_setup import use_setuptools
    use_setuptools()
    from setuptools import setup

setup(
    setup_requires=['d2to1'],
    d2to1=True
)

Note that it’s important to specify d2to1=True or else the d2to1 functionality will not be enabled. It is also possible to set d2to1=’some_file.cfg’ to specify the (relative) path of the setup.cfg file to use. But in general this functionality should not be necessary.

It should also work fine if additional arguments are passed to setup(), but it should be noted that they will be clobbered by any options in the setup.cfg file.

Caveats

  • The requires-dist option in setup.cfg is implemented through the distribute/setuptools install_requires option, rather than the broken “requires” keyword in normal distutils.

  • The version specifier scheme to be used with “requires-dist” is that used by distribute, and not the in the format expected by distutils2. For example, use “d2to1>=0.1” instead of “d2to1 (>0.1)”. This will be fixed in a future release.

Changes

0.1.3 (2011-04-20)

  • Adds zest.releaser entry points for updating the version number in a setup.cfg file; only useful if you use zest.releaser–otherwise harmless (might eventually move this functionality out into a separate product)

  • Though version 0.1.2 worked in Python3, use_2to3 wasn’t added to the setup.py so 2to3 had to be run manually

  • Fixed a crash on projects that don’t have a description-file option

0.1.2 (2011-04-13)

  • Fixed the self-installation–it did not work if a d2to1 version was not already installed, due to the use of pkg_resources.require()

  • Adds nominal Python3 support

  • Fixes the ‘classifier’ option in setup.cfg

0.1.1 (2011-04-12)

  • Fixed an unhelpful error message when a setup_hook fails to import

  • Made d2to1 able to use its own machinery to install itself

Release files for d2to1 0.1.3

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

Source distribution (sdist)

Source distribution for d2to1 0.1.3
File Size Uploaded
d2to1-0.1.3.tar.gz 7.7 kB Details

Release files / d2to1-0.1.3.tar.gz

Download URL d2to1-0.1.3.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1eccfc05bac27769812af74172545ce3791752bb7ca82240db94ef42c0b8cdab
BLAKE2b-256 checksum
How to use checksums
696f728d8532cbd343d90d13f13bd0624c673459cba9aed43c84bd468a3df7d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.2.12

1 release file

0.2.11

1 release file

0.2.10

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.1.5

1 release file

0.1.4

1 release file

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

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