Skip to main content

Simplify your setup.py

Project description

Simplify your setup.py

Version on pypi Travis CI codecov Python versions tested (link to github project) Downloads

Writing a setup.py typically involves lots of boilerplate and copy-pasting from project to project.

This package aims to simplify that and bring some DRY principle to python packaging. Here’s what your (complete, and ready to ship to pypi) setup.py could look like with setupmeta:

from setuptools import setup

setup(
    name="myproject",
    versioning="distance",          # Optional, would activate tag-based versioning
    setup_requires="setupmeta"      # This is where setupmeta comes in
)

And that should be it - setupmeta will take it from there, extracting everything else from the rest of your project (following typical conventions commonly used).

You can use the explain command (see commands) to see what setupmeta deduced from your project, for the above it would look something like this (you can see which file and which line each setting came from, note that a lot of info is typically extracted from your project, if you follow usual conventions):

~/myproject: python setup.py explain

          author: (auto-adjust     ) Your Name
              \_: (myproject.py:7  ) Your Name<your@email.com>
    author_email: (auto-adjust     ) your@email.com
     classifiers: (classifiers.txt ) 6 items: ["Development Status :: ...
     description: (README.rst:1    ) First line of your README
    entry_points: (entry_points.ini) [console_scripts] ...
install_requires: (requirements.txt) ["click", ...
         license: (auto-fill       ) MIT
long_description: (README.rst      ) Long description would be your inlined README
            name: (explicit        ) myproject
      py_modules: (auto-fill       ) ["myproject"]
  setup_requires: (explicit        ) ["setupmeta"]
         version: (git             ) 1.2.3.post2
      versioning: (explicit        ) distance

See examples for more.

Note: setupmeta’s versioning is based on:

git describe --dirty --tags --long --match *.* --first-parent

you will need git version >= 1.8.4 if you wish to use setupmeta’s versioning capabilities.

Goal

The goal of this project is to:

  • Allow to write very short (yet complete) setup.py-s, without boilerplate, and encourage good common packaging practices

  • Point out missing important info (example: version) in setup.py explain

  • Support tag-based versioning (like setuptools_scm, but with super simple configuration/defaults and automated bump capability)

  • Provide useful Commands to see the metadata (explain), version (including support for bumping versions), cleanall, twine, etc

How it works?

  • Everything that you explicitly provide in your original setuptools.setup() call is taken as-is (never changed), and internally labelled as explicit. So if you don’t like something that setupmeta deduces, you can always explicitly state it.

  • name is auto-filled from your setup.py’s __title__ (if there is one, sometimes having a constant is quite handy…)

  • packages and package_dir is auto-filled accordingly if you have a <name>/__init__.py or src/<name>/__init__.py file

  • py_modules is auto-filled if you have a <name>.py file

  • classifiers is auto-filled from file classifiers.txt (one classification per line, ignoring empty lines and python style comments)

  • entry_points is auto-filled from file entry_points.ini (bonus: tools like PyCharm have a nice syntax highlighter for those)

  • install_requires is auto-filled if you have a requirements.txt (or pinned.txt) file, pinning is abstracted away by default as per community recommendation, see requirements for more info.

  • tests_require is auto-filled if you have a tests/requirements.txt, or requirements-dev.txt, or dev-requirements.txt, or test-requirements.txt file

  • description will be the 1st line of your README (unless that 1st line is too short, or is just the project’s name), or the 1st line of the first docstring found in the scanned files (see list below)

  • long_description is auto-filled from your README file (looking for README.rst, README.md, then README*, first one found wins). Special tokens can be used (notation aimed at them easily being rst comments):

    • .. [[end long_description]] as end marker, so you don’t have to use the entire file as long description

    • .. [[include <relative-path>]] if you want another file included as well (for example, people like to add HISTORY.txt as well)

    • these tokens must appear either at beginning/end of line, or be after/before at least one space character

  • version can be stated explicitly, or be computed from git tags using versioning=... (see versioning for more info):

    • With versioning="distance", your git tags will be of the form v{major}.{minor}.0, the number of commits since latest version tag will be used to auto-fill the “patch” part of the version:

      • tag “v1.0.0”, no commits since tag -> version is “1.0.0”

      • tag “v1.0.0”, 5 commits since tag -> version is “1.0.5”

      • if checkout is dirty, a marker is added -> version would be “1.0.5.post5.dirty”

    • With versioning="post", your git tags will be of the form v{major}.{minor}.{patch}, a “post” addendum will be present if there are commits since latest version tag:

      • tag “v1.0.0”, no commits since tag -> version is “1.0.0”

      • tag “v1.0.0”, 5 commits since tag -> version is “1.0.0.post5”

      • if checkout is dirty, a marker is added -> version would be “1.0.0.post5.dirty”

    • With versioning="build-id", your git tags will be of the form v{major}.{minor}.0, the number of commits since latest version tag will be used to auto-fill the “patch” part of the version:

      • tag “v1.0.0”, no commits since tag, BUILD_ID=12 -> version is “1.0.0+h12.g123”

      • tag “v1.0.0”, no commits since tag, BUILD_ID not defined -> version is “1.0.0+hlocal.g123”

      • tag “v1.0.0”, 5 commits since tag, BUILD_ID=12 -> version is “1.0.5+h12.g456”

      • tag “v1.0.0”, 5 commits since tag, BUILD_ID not defined -> version is “1.0.5+hlocal.g456”

      • if checkout is dirty, a marker is added -> version would be “1.0.5+hlocal.g456.dirty”

    • Use the bump command (see commands) to easily bump (ie: increment major, minor or patch + apply git tag)

    • Version format can be customized, see versioning for more info

  • version, versioning, url, download_url, bugtrack_url, license, keywords, author, contact, maintainer, and platforms will be auto-filled from:

    • Lines of the form __key__ = "value" in your modules (simple constants only, expressions are ignored - the modules are not imported but scanned using regexes)

    • Lines of the form key: value in your docstring

    • Files are examined in this order (first find wins):

      • setup.py

      • <package>.py (mccabe for example)

      • <package>/__about__.py (cryptography for example)

      • <package>/__version__.py (requests for example)

      • <package>/__init__.py (changes, arrow for example)

      • src/ is also examined (for those who like to have their packages under src)

    • URLs can be simplified:

      • if url points to your general github repo (like: https://github.com/zsimic), the name of your project is auto-appended to it

      • relative urls are auto-filled by prefixing them with url

      • urls may use {name} and/or {version} markers, it will be expanded appropriately

    • author, maintainer and contact names and emails can be combined into one line (setupmeta will figure out the email part and auto-fill it properly)

      • i.e.: author: Bob D bob@d.com will yield the proper author and author_email settings

This should hopefully work nicely for the vast majority of python projects out there. If you need advanced stuff, you can still leverage setupmeta for all the usual stuff above, and go explicit wherever needed.

Download files

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

Source Distribution

setupmeta-2.6.13.tar.gz (39.2 kB view details)

Uploaded Source

Built Distributions

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

setupmeta-2.6.13-py3.8.egg (82.0 kB view details)

Uploaded Egg

setupmeta-2.6.13-py3.7.egg (82.0 kB view details)

Uploaded Egg

setupmeta-2.6.13-py3.6.egg (81.9 kB view details)

Uploaded Egg

setupmeta-2.6.13-py3.5.egg (83.3 kB view details)

Uploaded Egg

setupmeta-2.6.13-py3.4.egg (83.7 kB view details)

Uploaded Egg

setupmeta-2.6.13-py2.py3-none-any.whl (37.7 kB view details)

Uploaded Python 2Python 3

setupmeta-2.6.13-py2.7.egg (82.3 kB view details)

Uploaded Egg

File details

Details for the file setupmeta-2.6.13.tar.gz.

File metadata

  • Download URL: setupmeta-2.6.13.tar.gz
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for setupmeta-2.6.13.tar.gz
Algorithm Hash digest
SHA256 26ce0f7ee98c83410e03a0dcf514c998569eba77f36dd5e3dfa8c6999e239c08
MD5 6644b2dcf834ea8fde4313c55ef64b21
BLAKE2b-256 cc5c53a648c75a24e3d219c1c3f856eb0866486b2ce5c1cb8131abfd9c9a1d73

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py3.8.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py3.8.egg
  • Upload date:
  • Size: 82.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for setupmeta-2.6.13-py3.8.egg
Algorithm Hash digest
SHA256 0d61f9efb27cde153cc78210895ed7f3e61caf98c66a007df13f77561aef25a8
MD5 537f7402b85b256a05ed9f999dd84d20
BLAKE2b-256 0ce08aa5e1bb47e7dab3bab580f6633f5f81551a32227d31cd82ebdf90920be5

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py3.7.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py3.7.egg
  • Upload date:
  • Size: 82.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

File hashes

Hashes for setupmeta-2.6.13-py3.7.egg
Algorithm Hash digest
SHA256 59d95321b5bdd28bb816cd5059a1a26c1eb9cf5ef8b3f20ddb5b9f1dc084d60e
MD5 09a01f2daca00b4b07b7adf17d443cf2
BLAKE2b-256 88ef86e9ada69853573c63fc52ae617f275f9a0ee215fcf27b2d97eee7e1bcc5

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py3.6.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py3.6.egg
  • Upload date:
  • Size: 81.9 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.7

File hashes

Hashes for setupmeta-2.6.13-py3.6.egg
Algorithm Hash digest
SHA256 f853790a2989de66ea5d43290f1e281cf974837ac51f258e8b8c31b18adaa66b
MD5 20fe873a87e2ff7dc9555312bc8b2cd6
BLAKE2b-256 091d68c1254828addf916e1c9e11bf59456d4ae21abdbc25b92c57d6c95ffb58

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py3.5.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py3.5.egg
  • Upload date:
  • Size: 83.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.5.6

File hashes

Hashes for setupmeta-2.6.13-py3.5.egg
Algorithm Hash digest
SHA256 aea30652d3b7594aaca466a9d385d322810880c1569dac6a46c9812e251d4c7a
MD5 9a349678c3df682f6fea800a0b6a358f
BLAKE2b-256 2d82f920f3c6a260f9d5d456fc33a1c567e8f038b12d659e0c2cb8c69b17914f

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py3.4.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py3.4.egg
  • Upload date:
  • Size: 83.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/43.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.4.8

File hashes

Hashes for setupmeta-2.6.13-py3.4.egg
Algorithm Hash digest
SHA256 07093fed198c258798be1a6920e474aa50d5d028f68efb3fe915ba4b950aa64b
MD5 b3464dfd68c769edd5ec7bec83fd38df
BLAKE2b-256 7e23fbbcab286a3b729a4770967bc2f382ace29f386c5e85452cb62489e891d0

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py2.py3-none-any.whl.

File metadata

  • Download URL: setupmeta-2.6.13-py2.py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for setupmeta-2.6.13-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d07adf654c92f0bf20140a2001dec666a40e4bdf31cea9115601e41e3c306390
MD5 c52a35888087ad99df4c0fbd5bd15e98
BLAKE2b-256 aa51e12acbc47ef4ab78eb0c9732b676eefac6c836f8572909282cc2f0f24769

See more details on using hashes here.

File details

Details for the file setupmeta-2.6.13-py2.7.egg.

File metadata

  • Download URL: setupmeta-2.6.13-py2.7.egg
  • Upload date:
  • Size: 82.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.15

File hashes

Hashes for setupmeta-2.6.13-py2.7.egg
Algorithm Hash digest
SHA256 fe028330a7ae785ca8394678c2d76ef14037bd90ae4f6985d16be6a966bf9ba3
MD5 d84f9d9a59ed3e3fb361b9e8abe95ec9
BLAKE2b-256 72b76a97e8aaa078e4200813623cf846fd3ecaf8927f3653f028eb73316a8db7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page