Skip to content

Commit

Permalink
packaging: Move setup.py over to setup.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarrois committed Apr 29, 2021
1 parent f040044 commit a5e93bb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 71 deletions.
60 changes: 60 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[metadata]
name = xworkflows
version = 1.1.0.dev0
description = A library implementing workflows (or state machines) for Python projects.
long_description = file: README.rst
# https://docutils.sourceforge.io/FAQ.html#what-s-the-official-mime-type-for-restructuredtext-data
long_description_content_type = text/x-rst
author = Raphaël Barrois
author_email = [email protected]
url = https://github.com/rbarrois/xworkflows
keywords = workflow, state machine, automaton
license = BSD
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Topic :: Software Development :: Libraries :: Python Modules
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
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

[options]
zip_safe = false
package_dir =
=src
packages = find:
python_requires = >=2.7
install_requires =

[options.packages.find]
where = src

[options.extras_require]
dev =
# Testing
check_manifest
flake8
tox
# Packaging
zest.releaser[recommended]
doc =
Sphinx
sphinx_rtd_theme

[bdist_wheel]
universal = 1

[zest.releaser]
; semver-style versions
version-levels = 3

[distutils]
index-servers = pypi
71 changes: 1 addition & 70 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,6 @@
# Copyright (c) The xworkflows project
# This code is distributed under the two-clause BSD License.

import codecs
import os
import re
import sys

from setuptools import find_packages, setup

root_dir = os.path.abspath(os.path.dirname(__file__))


def get_version():
version_re = re.compile(r"^__version__ = [\"']([\w_.-]+)[\"']$")
roots = [root_dir, os.path.join(root_dir, 'src')]
for root in roots:
version_path = os.path.join(root_dir, PACKAGE, 'version.py')
if not os.path.exists(version_path):
continue
with codecs.open(version_path, 'r', 'utf-8') as f:
for line in f:
match = version_re.match(line[:-1])
if match:
return match.groups()[0]
return '0.1.0'


def clean_readme(fname):
"""Cleanup README.rst for proper PyPI formatting."""
with codecs.open(fname, 'r', 'utf-8') as f:
return ''.join(
re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
for line in f
if not (line.startswith('.. currentmodule') or line.startswith('.. toctree'))
)


PACKAGE = 'xworkflows'


setup(
name=PACKAGE,
version=get_version(),
author="Raphaël Barrois",
author_email='raphael.barrois_%[email protected]' % PACKAGE,
description="A library implementing workflows (or state machines) for Python projects.",
long_description=clean_readme('README.rst'),
license='BSD',
keywords=['workflow', 'state machine', 'automaton'],
url='https://github.com/rbarrois/%s' % PACKAGE,
install_requires=[
],
setup_requires=[
'setuptools>=1',
],
packages=find_packages('src'),
package_dir={'': 'src'},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"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",
],
)
setup()
10 changes: 9 additions & 1 deletion src/xworkflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@

from . import base

__version__ = '1.0.4'
__author__ = 'Raphaël Barrois <[email protected]>'
try:
# Python 3.8+
from importlib.metadata import version

__version__ = version("xworkflows")
except ImportError:
import pkg_resources

__version__ = pkg_resources.get_distribution("xworkflows").version

# Errors
AbortTransition = base.AbortTransition
Expand Down

0 comments on commit a5e93bb

Please sign in to comment.