Skip to content

Commit 6be3405

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, as well as set the zip_safe flag to False. Removed tests folder from package. Fixes #10
1 parent 4724400 commit 6be3405

3 files changed

Lines changed: 22 additions & 23 deletions

File tree

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 & 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 = ['pyyaml']
@@ -17,34 +19,21 @@
1719
TESTS_REQUIRE = ['pytest', 'pytest-logging']
1820
EXTRAS_REQUIRE = {}
1921

20-
# simple check
21-
try:
22-
from setuptools_scm import get_version
23-
except Exception as e:
24-
raise_from(Exception('Required packages for setup not found. Please install `setuptools_scm`'), e)
25-
2622
# ************** ID card *****************
2723
DISTNAME = 'yamlable'
2824
DESCRIPTION = 'A thin wrapper of PyYaml to convert Python objects to YAML and back.'
2925
MAINTAINER = 'Sylvain Marié'
3026
MAINTAINER_EMAIL = 'sylvain.marie@schneider-electric.com'
3127
URL = 'https://github.com/smarie/python-yamlable'
28+
DOWNLOAD_URL = URL + '/tarball/' + get_version()
3229
LICENSE = 'BSD 3-Clause'
3330
LICENSE_LONG = 'License :: OSI Approved :: BSD License'
34-
35-
version_for_download_url = get_version()
36-
DOWNLOAD_URL = URL + '/tarball/' + version_for_download_url
37-
3831
KEYWORDS = 'yaml file parsing parse load dump read write object oo oriented codec format plugin pyYaml'
3932

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

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

5039
setup(
@@ -91,14 +80,16 @@
9180
'Programming Language :: Python :: 3.5',
9281
'Programming Language :: Python :: 3.6',
9382
'Programming Language :: Python :: 3.7',
83+
84+
# 'Framework :: Pytest'
9485
],
9586

9687
# What does your project relate to?
9788
keywords=KEYWORDS,
9889

9990
# You can just specify the packages manually here if your project is
10091
# simple. Or you can use find_packages().
101-
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
92+
packages=find_packages(exclude=['contrib', 'docs', '*tests*']),
10293

10394
# Alternatively, if you want to distribute just a my_module.py, uncomment
10495
# this:
@@ -131,9 +122,11 @@
131122
# If there are data files included in your packages that need to be
132123
# installed, specify them here. If using Python 2.6 or less, then these
133124
# have to be included in MANIFEST.in as well.
134-
# package_data={
135-
# 'sample': ['package_data.dat'],
136-
# },
125+
# Note: we use the empty string so that this also works with submodules
126+
package_data={"": ['py.typed', '*.pyi']},
127+
# IMPORTANT: DO NOT set the `include_package_data` flag !! It triggers inclusion of all git-versioned files
128+
# see https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
129+
# include_package_data=True,
137130

138131
# Although 'package_data' is the preferred approach, in some case you may
139132
# need to place data files outside of your packages. See:
@@ -149,4 +142,10 @@
149142
# 'sample=sample:main',
150143
# ],
151144
# },
145+
146+
# explicitly setting the flag to avoid `ply` being downloaded
147+
# see https://github.com/smarie/python-getversion/pull/5
148+
# and to make mypy happy
149+
# see https://mypy.readthedocs.io/en/latest/installed_packages.html
150+
zip_safe=False,
152151
)

yamlable/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)