Skip to content

Commit 9d75ea7

Browse files
author
Sylvain MARIE
committed
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. Fixes #78
1 parent 9983c76 commit 9d75ea7

File tree

3 files changed

+22
-25
lines changed

3 files changed

+22
-25
lines changed

pytest_cases/py.typed

Whitespace-only changes.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# This flag says that the code is written to work on both Python 2 and Python
88
# 3. If at all possible, it is good practice to do this. If you cannot, you
99
# will need to generate wheels for each Python version that you support.
10-
universal=0
10+
universal=1
1111

1212
[metadata]
1313
description-file = README.md

setup.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,38 @@
33
https://packaging.python.org/en/latest/distributing.html
44
https://github.com/pypa/sampleproject
55
"""
6-
from six import raise_from
76
from os import path
8-
7+
import pkg_resources
98
from setuptools import setup, find_packages
109

11-
here = path.abspath(path.dirname(__file__))
10+
pkg_resources.require("setuptools>=39.2")
11+
pkg_resources.require("setuptools_scm")
12+
13+
from setuptools_scm import get_version # noqa: E402
1214

1315
# *************** Dependencies *********
1416
INSTALL_REQUIRES = ['wrapt', 'decopatch', 'makefun>=1.7', 'functools32;python_version<"3.2"',
1517
'funcsigs;python_version<"3.3"', 'enum34;python_version<"3.4"', 'six']
1618
DEPENDENCY_LINKS = []
17-
SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'six']
19+
SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm']
1820
TESTS_REQUIRE = ['pytest', 'pytest-logging', 'pytest-steps', 'pytest-harvest']
1921
EXTRAS_REQUIRE = {}
2022

21-
# simple check
22-
try:
23-
from setuptools_scm import get_version
24-
except Exception as e:
25-
raise_from(Exception('Required packages for setup not found. Please install `setuptools_scm`'), e)
26-
2723
# ************** ID card *****************
2824
DISTNAME = 'pytest-cases'
2925
DESCRIPTION = 'Separate test code from test cases in pytest.'
3026
MAINTAINER = 'Sylvain MARIE'
3127
MAINTAINER_EMAIL = '[email protected]'
3228
URL = 'https://github.com/smarie/python-pytest-cases'
29+
DOWNLOAD_URL = URL + '/tarball/' + get_version()
3330
LICENSE = 'BSD 3-Clause'
3431
LICENSE_LONG = 'License :: OSI Approved :: BSD License'
35-
36-
version_for_download_url = get_version()
37-
DOWNLOAD_URL = URL + '/tarball/' + version_for_download_url
38-
3932
KEYWORDS = 'pytest test case testcase test-case decorator parametrize parameter data dataset file separate concerns'
4033

34+
here = path.abspath(path.dirname(__file__))
4135
with open(path.join(here, 'docs', 'long_description.md')) as f:
4236
LONG_DESCRIPTION = f.read()
4337

44-
# ************* VERSION **************
45-
# --Get the Version number from VERSION file, see https://packaging.python.org/single_source_version/ option 4.
46-
# THIS IS DEPRECATED AS WE NOW USE GIT TO MANAGE VERSION
47-
# with open(path.join(here, 'VERSION')) as version_file:
48-
# VERSION = version_file.read().strip()
4938
# OBSOLETES = []
5039

5140
setup(
@@ -101,7 +90,7 @@
10190

10291
# You can just specify the packages manually here if your project is
10392
# simple. Or you can use find_packages().
104-
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
93+
packages=find_packages(exclude=['contrib', 'docs', '*tests*']),
10594

10695
# Alternatively, if you want to distribute just a my_module.py, uncomment
10796
# this:
@@ -115,7 +104,7 @@
115104
dependency_links=DEPENDENCY_LINKS,
116105

117106
# we're using git
118-
use_scm_version={'write_to': 'pytest_cases/_version.py'}, # this provides the version + adds the date if local non-commited changes.
107+
use_scm_version={'write_to': '%s/_version.py' % DISTNAME}, # this provides the version + adds the date if local non-commited changes.
119108
# use_scm_version={'local_scheme':'dirty-tag'}, # this provides the version + adds '+dirty' if local non-commited changes.
120109
setup_requires=SETUP_REQUIRES,
121110

@@ -134,9 +123,11 @@
134123
# If there are data files included in your packages that need to be
135124
# installed, specify them here. If using Python 2.6 or less, then these
136125
# have to be included in MANIFEST.in as well.
137-
# package_data={
138-
# 'sample': ['package_data.dat'],
139-
# },
126+
# Note: we use the empty string so that this also works with submodules
127+
package_data={"": ['py.typed', '*.pyi']},
128+
# IMPORTANT: DO NOT set the `include_package_data` flag !! It triggers inclusion of all git-versioned files
129+
# see https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
130+
# include_package_data=True,
140131

141132
# Although 'package_data' is the preferred approach, in some case you may
142133
# need to place data files outside of your packages. See:
@@ -155,4 +146,10 @@
155146

156147
# the following makes a plugin available to pytest
157148
entry_points={"pytest11": ["cases = pytest_cases.plugin"]},
149+
150+
# explicitly setting the flag to avoid `ply` being downloaded
151+
# see https://github.com/smarie/python-getversion/pull/5
152+
# and to make mypy happy
153+
# see https://mypy.readthedocs.io/en/latest/installed_packages.html
154+
zip_safe=False,
158155
)

0 commit comments

Comments
 (0)