diff --git a/.gitignore b/.gitignore index 5a8edc0..6437af0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/icecream/__version__.py *~ .#* \#* diff --git a/icecream/__init__.py b/icecream/__init__.py index 0a9393d..3bbc378 100644 --- a/icecream/__init__.py +++ b/icecream/__init__.py @@ -13,8 +13,7 @@ from os.path import dirname, join as pjoin from .icecream import * # noqa +from .__version__ import __version__ from .builtins import install, uninstall -# Import all variables in __version__.py without explicit imports. -from . import __version__ -globals().update(dict((k, v) for k, v in __version__.__dict__.items())) +meta = {"__version__": __version__} diff --git a/icecream/__version__.py b/icecream/__version__.py deleted file mode 100644 index 56cc313..0000000 --- a/icecream/__version__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -# -# IceCream - Never use print() to debug again -# -# Ansgar Grunseid -# grunseid.com -# grunseid@gmail.com -# -# License: MIT -# - -__title__ = 'icecream' -__license__ = 'MIT' -__version__ = '2.1.2' -__author__ = 'Ansgar Grunseid' -__contact__ = 'grunseid@gmail.com' -__url__ = 'https://github.com/gruns/icecream' -__description__ = ( - 'Never use print() to debug again; inspect variables, expressions, and ' - 'program execution with a single, simple function call.') diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7f598a0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["setuptools>=61.2.0", "wheel", "setuptools_scm[toml]>=3.4.3"] +build-backend = "setuptools.build_meta" + +[project] +name = "icecream" +authors = [{name = "Ansgar Grunseid", email = "grunseid@gmail.com"}] +license = {text = "MIT"} +description = "Never use print() to debug again" # inspect variables, expressions, and program execution with a single, simple function call. +readme = "README.md" +classifiers = [ + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: Implementation :: CPython", +] +urls = {Homepage = "https://github.com/gruns/icecream"} +dependencies = [ + "colorama>=0.3.9", + "pygments>=2.2.0", + "executing>=0.3.1", + "asttokens>=2.0.1", +] +dynamic = ["version"] + +[tool.setuptools] +include-package-data = true +platforms = ["any"] +license-files = ["LICENSE.txt"] + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.distutils.bdist_wheel] +universal = 1 + +[tool.setuptools_scm] +write_to = "icecream/__version__.py" +write_to_template = "__version__ = '{version}'\n" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2e9053c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -universal = 1 - -[metadata] -license_file = LICENSE.txt diff --git a/setup.py b/setup.py index df3d31d..5252e77 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,11 @@ import os import sys from os.path import dirname, join as pjoin -from setuptools import setup, find_packages, Command +from glob import glob +from setuptools import Command, setup from setuptools.command.test import test as TestCommand - -meta = {} -with open(pjoin('icecream', '__version__.py')) as f: - exec(f.read(), meta) - +this_dir = dirname(__file__) class Publish(Command): """Publish to PyPI with twine.""" @@ -34,11 +31,10 @@ def finalize_options(self): pass def run(self): - os.system('python setup.py sdist bdist_wheel') - - sdist = 'dist/icecream-%s.tar.gz' % meta['__version__'] - wheel = 'dist/icecream-%s-py2.py3-none-any.whl' % meta['__version__'] - rc = os.system('twine upload "%s" "%s"' % (sdist, wheel)) + dist_dir = pjoin(this_dir, "dist") + os.system(sys.executable + " -m build -nwxs " + this_dir) + files = glob(pjoin(dist_dir, "*.whl")) + glob(pjoin(dist_dir, "*.tar.gz")) + rc = os.system(sys.executable + " -m twine upload " + " ".join(files)) sys.exit(rc) @@ -59,51 +55,13 @@ class RunTests(TestCommand): """ def run_tests(self): from unittest import TestLoader, TextTestRunner - tests_dir = pjoin(dirname(__file__), 'tests') + tests_dir = pjoin(this_dir, 'tests') suite = TestLoader().discover(tests_dir) result = TextTestRunner().run(suite) sys.exit(0 if result.wasSuccessful() else -1) setup( - name=meta['__title__'], - license=meta['__license__'], - version=meta['__version__'], - author=meta['__author__'], - author_email=meta['__contact__'], - url=meta['__url__'], - description=meta['__description__'], - long_description=( - 'Information and documentation can be found at ' - 'https://github.com/gruns/icecream.'), - platforms=['any'], - packages=find_packages(), - include_package_data=True, - classifiers=[ - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Libraries', - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python :: Implementation :: CPython', - ], - tests_require=[], - install_requires=[ - 'colorama>=0.3.9', - 'pygments>=2.2.0', - 'executing>=0.3.1', - 'asttokens>=2.0.1', - ], cmdclass={ 'test': RunTests, 'publish': Publish,