|
3 | 3 | https://packaging.python.org/en/latest/distributing.html |
4 | 4 | https://github.com/pypa/sampleproject |
5 | 5 | """ |
6 | | -from six import raise_from |
7 | 6 | from os import path |
8 | | - |
| 7 | +import pkg_resources |
9 | 8 | from setuptools import setup, find_packages |
10 | 9 |
|
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 |
12 | 14 |
|
13 | 15 | # *************** Dependencies ********* |
14 | 16 | INSTALL_REQUIRES = ['wrapt', 'decopatch', 'makefun>=1.7', 'functools32;python_version<"3.2"', |
15 | 17 | 'funcsigs;python_version<"3.3"', 'enum34;python_version<"3.4"', 'six'] |
16 | 18 | DEPENDENCY_LINKS = [] |
17 | | -SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'six'] |
| 19 | +SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm'] |
18 | 20 | TESTS_REQUIRE = ['pytest', 'pytest-logging', 'pytest-steps', 'pytest-harvest'] |
19 | 21 | EXTRAS_REQUIRE = {} |
20 | 22 |
|
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 | | - |
27 | 23 | # ************** ID card ***************** |
28 | 24 | DISTNAME = 'pytest-cases' |
29 | 25 | DESCRIPTION = 'Separate test code from test cases in pytest.' |
30 | 26 | MAINTAINER = 'Sylvain MARIE' |
31 | 27 | MAINTAINER_EMAIL = '[email protected]' |
32 | 28 | URL = 'https://github.com/smarie/python-pytest-cases' |
| 29 | +DOWNLOAD_URL = URL + '/tarball/' + get_version() |
33 | 30 | LICENSE = 'BSD 3-Clause' |
34 | 31 | 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 | | - |
39 | 32 | KEYWORDS = 'pytest test case testcase test-case decorator parametrize parameter data dataset file separate concerns' |
40 | 33 |
|
| 34 | +here = path.abspath(path.dirname(__file__)) |
41 | 35 | with open(path.join(here, 'docs', 'long_description.md')) as f: |
42 | 36 | LONG_DESCRIPTION = f.read() |
43 | 37 |
|
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() |
49 | 38 | # OBSOLETES = [] |
50 | 39 |
|
51 | 40 | setup( |
|
101 | 90 |
|
102 | 91 | # You can just specify the packages manually here if your project is |
103 | 92 | # simple. Or you can use find_packages(). |
104 | | - packages=find_packages(exclude=['contrib', 'docs', 'tests']), |
| 93 | + packages=find_packages(exclude=['contrib', 'docs', '*tests*']), |
105 | 94 |
|
106 | 95 | # Alternatively, if you want to distribute just a my_module.py, uncomment |
107 | 96 | # this: |
|
115 | 104 | dependency_links=DEPENDENCY_LINKS, |
116 | 105 |
|
117 | 106 | # 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. |
119 | 108 | # use_scm_version={'local_scheme':'dirty-tag'}, # this provides the version + adds '+dirty' if local non-commited changes. |
120 | 109 | setup_requires=SETUP_REQUIRES, |
121 | 110 |
|
|
134 | 123 | # If there are data files included in your packages that need to be |
135 | 124 | # installed, specify them here. If using Python 2.6 or less, then these |
136 | 125 | # 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, |
140 | 131 |
|
141 | 132 | # Although 'package_data' is the preferred approach, in some case you may |
142 | 133 | # need to place data files outside of your packages. See: |
|
155 | 146 |
|
156 | 147 | # the following makes a plugin available to pytest |
157 | 148 | 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, |
158 | 155 | ) |
0 commit comments