setuppy-generator

setup.py generator


Keywords
setup, py, generator, cli, python, setuptools
License
Unlicense
Install
pip install setuppy-generator==2020.12.2

Documentation

Installation

$ [sudo] pip install setuppy-generator

Pros

  • setup.py generator
  • create multiple setup.py files - dev/prod, github/pypi, etc
  • python classes/cli

Features

key file/environment variable
name current directory basename or $SETUP_NAME
version $SETUP_VERSION
url $SETUP_URL
classifiers classifiers.txt, $SETUP_CLASSIFIERS
description $SETUP_DESCRIPTION
keywords $SETUP_KEYWORDS
long_description README.md/README.rst, $SETUP_LONG_DESCRIPTION
long_description_content_type text/markdown if long_description is .md file
install_requires requirements.txt, $SETUP_INSTALL_REQUIRES
packages setuptools.find_packages(), $SETUP_PACKAGES
py_modules python files in a current directory, $SETUP_PY_MODULES
scripts scripts/* files, $SETUP_SCRIPTS

Examples

project-name.py/
├── classifiers.txt
├── module.py
├── package
|   └── __init__.py
├── README.md
├── requirements.txt
└── scripts
    └── script
$ cd path/to/project-name.py
$ export SETUP_VERSION="1.0.0"
$ python -m setuppy_generator > setup.py
setup(
    name='project-name',
    version='1.0.0',
    classifiers = [...],
    long_description=open('README.md').read(),
    long_description_content_type='text/markdown',
    install_requires=['req1','req2'],
    packages=['pkgname'],
    py_modules=['module'],
    scripts=['scripts/script']
)

example #2 - environment variables

$ export SETUP_URL="https://github.com/owner/repo"
$ export SETUP_CLASSIFIERS="classifiers.txt"
$ export SETUP_DESCRIPTION="description ..."
$ export SETUP_KEYWORDS="key1 key2"
$ export SETUP_LONG_DESCRIPTION="README.md"
$ export SETUP_INSTALL_REQUIRES="requirements.txt"
$ export SETUP_PACKAGES="package1 package2"
$ export SETUP_PY_MODULES="module1 module2"
$ export SETUP_SCRIPTS="scripts/script1 scripts/script2"
$ python -m setuppy_generator > setup.py
setup(
    name='project-name',
    version='1.0.0',
    url='https://github.com/owner/repo',
    classifiers = [...],
    description='description ...',
    long_description=open('README.md').read(),
    long_description_content_type='text/markdown',
    keywords='key1 key2',
    install_requires=['req1','req2'],
    packages=['package1','package2'],
    py_modules=['module1','module2'],
    scripts=['scripts/script1','scripts/script2']
)

open(path).read() function:

$ export SETUP_VERSION="open('.config/version.txt').read().split()"
$ export SETUP_DESCRIPTION="open('.config/description.txt').read().split()"
$ export SETUP_KEYWORDS="open('.config/keywords.txt').read().split(' ')"
$ python -m setuppy_generator > setup.py
setup(
    ...
    version=open('.config/version.txt').read().split(),
    description=open('.config/description.txt').read().split(),
    keywords=open('.config/keywords.txt').read().split(' '),
    ...
)

example #3 - minimal setup.py

$ export SETUP_CLASSIFIERS=""
$ export SETUP_DESCRIPTION=""
$ export SETUP_KEYWORDS=""
$ export SETUP_LONG_DESCRIPTION=""
$ export SETUP_URL=""
$ python -m setuppy_generator > setup.py
setup(
    name='project-name',
    version='1.0.0',
    install_requires=['req1','req2'],
    packages=['pkgname'],
    py_modules=['module'],
    scripts=['scripts/script']
)

Related

readme42.com