From 9c61d5acc182b0fc84308e233b4e68072234ebcc Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Sat, 25 Apr 2020 15:55:14 +0200 Subject: [PATCH] packaging improvements: set the "universal wheel" flag to 1, and cleaned up the `setup.py`. In particular removed dependency to `six` for setup and added `py.typed` file, as well as set the `zip_safe` flag to False. Removed tests folder from package. Fixes #39 --- pytest_steps/py.typed | 0 setup.cfg | 2 +- setup.py | 45 ++++++++++++++++++++----------------------- 3 files changed, 22 insertions(+), 25 deletions(-) create mode 100644 pytest_steps/py.typed diff --git a/pytest_steps/py.typed b/pytest_steps/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.cfg b/setup.cfg index 4bf57cc..c8d0fdb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ # This flag says that the code is written to work on both Python 2 and Python # 3. If at all possible, it is good practice to do this. If you cannot, you # will need to generate wheels for each Python version that you support. -universal=0 +universal=1 [metadata] description-file = README.md diff --git a/setup.py b/setup.py index ee92e62..2130aac 100644 --- a/setup.py +++ b/setup.py @@ -3,48 +3,37 @@ https://packaging.python.org/en/latest/distributing.html https://github.com/pypa/sampleproject """ -from six import raise_from from os import path - +import pkg_resources from setuptools import setup, find_packages -here = path.abspath(path.dirname(__file__)) +pkg_resources.require("setuptools>=39.2") +pkg_resources.require("setuptools_scm") + +from setuptools_scm import get_version # noqa: E402 # *************** Dependencies ********* INSTALL_REQUIRES = ['makefun>=1.5', 'wrapt', 'functools32;python_version<"3.2"', 'funcsigs;python_version<"3.3"', 'six'] DEPENDENCY_LINKS = [] -SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'six'] +SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm'] TESTS_REQUIRE = ['pytest', 'pytest-logging', 'pytest-harvest>=1.4.0', 'pytest-cases'] EXTRAS_REQUIRE = {} -# simple check -try: - from setuptools_scm import get_version -except Exception as e: - raise_from(Exception('Required packages for setup not found. Please install `setuptools_scm`'), e) - # ************** ID card ***************** DISTNAME = 'pytest-steps' DESCRIPTION = 'Create step-wise / incremental tests in pytest.' MAINTAINER = 'Sylvain MARIE' MAINTAINER_EMAIL = 'sylvain.marie@schneider-electric.com' URL = 'https://github.com/smarie/python-pytest-steps' +DOWNLOAD_URL = URL + '/tarball/' + get_version() LICENSE = 'BSD 3-Clause' LICENSE_LONG = 'License :: OSI Approved :: BSD License' - -version_for_download_url = get_version() -DOWNLOAD_URL = URL + '/tarball/' + version_for_download_url - KEYWORDS = 'pytest test step incremental decorator parametrize parameter state share result modular' +here = path.abspath(path.dirname(__file__)) with open(path.join(here, 'docs', 'long_description.md')) as f: LONG_DESCRIPTION = f.read() -# ************* VERSION ************** -# --Get the Version number from VERSION file, see https://packaging.python.org/single_source_version/ option 4. -# THIS IS DEPRECATED AS WE NOW USE GIT TO MANAGE VERSION -# with open(path.join(here, 'VERSION')) as version_file: -# VERSION = version_file.read().strip() # OBSOLETES = [] setup( @@ -100,7 +89,7 @@ # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - packages=find_packages(exclude=['contrib', 'docs', 'tests']), + packages=find_packages(exclude=['contrib', 'docs', '*tests*']), # Alternatively, if you want to distribute just a my_module.py, uncomment # this: @@ -114,7 +103,7 @@ dependency_links=DEPENDENCY_LINKS, # we're using git - use_scm_version={'write_to': 'pytest_steps/_version.py'}, # this provides the version + adds the date if local non-commited changes. + use_scm_version={'write_to': '%s/_version.py' % DISTNAME.replace('-', '_')}, # this provides the version + adds the date if local non-commited changes. # use_scm_version={'local_scheme':'dirty-tag'}, # this provides the version + adds '+dirty' if local non-commited changes. setup_requires=SETUP_REQUIRES, @@ -133,9 +122,11 @@ # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these # have to be included in MANIFEST.in as well. - # package_data={ - # 'sample': ['package_data.dat'], - # }, + # Note: we use the empty string so that this also works with submodules + package_data={"": ['py.typed', '*.pyi']}, + # IMPORTANT: DO NOT set the `include_package_data` flag !! It triggers inclusion of all git-versioned files + # see https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286 + # include_package_data=True, # Although 'package_data' is the preferred approach, in some case you may # need to place data files outside of your packages. See: @@ -154,4 +145,10 @@ # the following makes a plugin available to pytest entry_points={"pytest11": ["steps = pytest_steps.plugin"]}, + + # explicitly setting the flag to avoid `ply` being downloaded + # see https://github.com/smarie/python-getversion/pull/5 + # and to make mypy happy + # see https://mypy.readthedocs.io/en/latest/installed_packages.html + zip_safe=False, )