Skip to content

Commit fad8ad6

Browse files
author
Sylvain MARIE
committed
packaging improvements: set the universal flag to 1, and cleaned up the setup.py. Added py.typed file. In particular removed dependency to six for setup. Fixes #8
1 parent e9d0741 commit fad8ad6

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

getversion/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: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
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 = ['stdlib_list', 'setuptools_scm', 'functools32;python_version<"3.2"',
@@ -21,35 +23,22 @@
2123
]
2224
EXTRAS_REQUIRE = {}
2325

24-
# simple check
25-
try:
26-
from setuptools_scm import get_version
27-
except Exception as e:
28-
raise_from(Exception('Required packages for setup not found. Please install `setuptools_scm`'), e)
29-
3026
# ************** ID card *****************
3127
DISTNAME = 'getversion'
3228
DESCRIPTION = 'Get the version number of any python module or package, reliably.'
3329
MAINTAINER = 'Sylvain MARIE'
3430
MAINTAINER_EMAIL = '[email protected]'
3531
URL = 'https://github.com/smarie/python-getversion'
32+
DOWNLOAD_URL = URL + '/tarball/' + get_version()
3633
LICENSE = 'BSD 3-Clause'
3734
LICENSE_LONG = 'License :: OSI Approved :: BSD License'
38-
39-
version_for_download_url = get_version()
40-
DOWNLOAD_URL = URL + '/tarball/' + version_for_download_url
41-
4235
KEYWORDS = 'module version source binary package library PEP345 PEP396 PEP427 pkg_resources setuptools wheel egg ' \
4336
'egg-info scm git svn'
4437

38+
here = path.abspath(path.dirname(__file__))
4539
with open(path.join(here, 'docs', 'long_description.md')) as f:
4640
LONG_DESCRIPTION = f.read()
4741

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

5544
setup(
@@ -105,7 +94,7 @@
10594

10695
# You can just specify the packages manually here if your project is
10796
# simple. Or you can use find_packages().
108-
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
97+
packages=find_packages(exclude=['contrib', 'docs', '*tests*']),
10998

11099
# Alternatively, if you want to distribute just a my_module.py, uncomment
111100
# this:
@@ -138,9 +127,11 @@
138127
# If there are data files included in your packages that need to be
139128
# installed, specify them here. If using Python 2.6 or less, then these
140129
# have to be included in MANIFEST.in as well.
141-
# package_data={
142-
# 'sample': ['package_data.dat'],
143-
# },
130+
# Note: we use the empty string so that this also works with submodules
131+
package_data={"": ['py.typed', '*.pyi']},
132+
# IMPORTANT: DO NOT set the `include_package_data` flag !! It triggers inclusion of all git-versioned files
133+
# see https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
134+
# include_package_data=True,
144135

145136
# Although 'package_data' is the preferred approach, in some case you may
146137
# need to place data files outside of your packages. See:

0 commit comments

Comments
 (0)