annotate setup.py @ 586:d68e8204f7c3

Allow to build a distribution without C-extensions by using --only-pure
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 09 Jan 2022 13:46:57 +0100
parents 233bd8bbda28
children eac8e2d3933c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
1 #!/usr/bin/env python
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
3
585
233bd8bbda28 Automatically remove ConfigMix.egg-info
Franz Glasner <fzglas.hg@dom66.de>
parents: 583
diff changeset
4 from __future__ import print_function, absolute_import
233bd8bbda28 Automatically remove ConfigMix.egg-info
Franz Glasner <fzglas.hg@dom66.de>
parents: 583
diff changeset
5
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
6 import re
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
7 import os
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
8 import platform
585
233bd8bbda28 Automatically remove ConfigMix.egg-info
Franz Glasner <fzglas.hg@dom66.de>
parents: 583
diff changeset
9 import shutil
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
10 import sys
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
11 try:
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
12 from setuptools import setup
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
13 except ImportError:
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
14 from distutils.core import setup
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
15
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
16
582
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
17 PROJECT_NAME = "ConfigMix"
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
18
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
19
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
20 if (sys.version_info[0] < 2) or \
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
21 ((sys.version_info[0] == 2) and (sys.version_info[1] < 6)):
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
22 raise ValueError("Need at least Python 2.6")
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
23
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
24 pkg_root = os.path.dirname(__file__)
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
25
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
26 _version_re = re.compile(br"^\s*__version__\s*=\s*(\"|')(.*)\1\s*(#.*)?$",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
27 re.MULTILINE)
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
28
5
dc058099a4cb Renamed the project from "MixConfig" to "ConfigMix"
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
29 with open(os.path.join(pkg_root, "configmix", "__init__.py"), "rb") as vf:
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
30 version = _version_re.search(vf.read()).group(2).decode("utf-8")
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
31
71
80dcb41928a7 Rename README to README.txt to be more consistent with LICENSE.txt
Franz Glasner <hg@dom66.de>
parents: 70
diff changeset
32 with open(os.path.join(pkg_root, "README.txt"), "rt") as rf:
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
33 long_description = rf.read()
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
34
282
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
35 aws_requirements = [
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
36 "requests",
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
37 ]
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
38
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
39 yaml_requirements = [
235
a8b2346e2330 Tested up to PyYAML 5.3.1: so (with semantic versioning): adjust requirements to "<6"
Franz Glasner <fzglas.hg@dom66.de>
parents: 199
diff changeset
40 "PyYAML>=3.0,<6",
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
41 ]
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
42
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
43 toml_requirements = [
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
44 "toml>=0.10",
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
45 ]
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
46
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
47 all_requirements = []
282
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
48 all_requirements.extend(aws_requirements)
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
49 all_requirements.extend(yaml_requirements)
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
50 all_requirements.extend(toml_requirements)
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
51
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
52
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
53 cmdclass = {}
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
54 ext_modules = None
567
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
55 setup_extra_kwds = {}
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
56
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
57 windows_cross_pack = False
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
58
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
59 try:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
60 wcp_idx = sys.argv.index("--windows-cross-pack")
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
61 except ValueError:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
62 wcp_idx = None
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
63 else:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
64 del sys.argv[wcp_idx]
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
65 try:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
66 pure_only_idx = sys.argv.index("--pure-only")
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
67 except ValueError:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
68 pure_only_idx = None
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
69 else:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
70 del sys.argv[pure_only_idx]
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
71
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
72
583
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
73 #
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
74 # Otherwise some cached package_data would be used.
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
75 # But our package data differs between "standard" builds and
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
76 # builds with "--windows-cross-pack".
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
77 #
4e61df27b4e1 Put the ".egg-info" check into a common location
Franz Glasner <fzglas.hg@dom66.de>
parents: 582
diff changeset
78 if os.path.isdir(PROJECT_NAME + ".egg-info"):
585
233bd8bbda28 Automatically remove ConfigMix.egg-info
Franz Glasner <fzglas.hg@dom66.de>
parents: 583
diff changeset
79 print("removing `%s.egg-info'" % (PROJECT_NAME,))
233bd8bbda28 Automatically remove ConfigMix.egg-info
Franz Glasner <fzglas.hg@dom66.de>
parents: 583
diff changeset
80 shutil.rmtree(PROJECT_NAME + ".egg-info")
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
81
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
82 if pure_only_idx is None:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
83 if wcp_idx is None:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
84 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
85 # Handle the optinal C-extension for Python3.7+ and CPython only.
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
86 # PyPy does not need this.
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
87 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
88
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
89 # The C-extension uses multi-phase module initialization (PEP 489, PY 3.5+)
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
90 if (platform.python_implementation() == "CPython"
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
91 and (sys.version_info[0] > 3
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
92 or (sys.version_info[0] == 3 and sys.version_info[1] >= 5))):
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
93
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
94 # The stable API for Python 3.7+ is used
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
95 if sys.version_info[0] == 3 and sys.version_info[1] < 7:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
96 py_limited_api = False
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
97 else:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
98 py_limited_api = True
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
99
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
100 if py_limited_api:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
101 define_macros = [("Py_LIMITED_API", "0x03070000")]
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
102 else:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
103 define_macros = []
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
104
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
105 try:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
106 from setuptools import Extension
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
107 except ImportError:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
108 from distutils.core import Extension
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
109
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
110 ext_modules = [
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
111 Extension(
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
112 name="configmix._speedups",
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
113 sources=["configmix/_speedups.c"],
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
114 define_macros=define_macros,
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
115 py_limited_api=py_limited_api,
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
116 optional=True
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
117 ),
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
118 ]
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
119
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
120 if py_limited_api:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
121 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
122 # Build a wheel that is properly named using the stable API
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
123 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
124 try:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
125 import wheel.bdist_wheel
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
126 except ImportError:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
127 pass
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
128 else:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
129 class BDistWheel(wheel.bdist_wheel.bdist_wheel):
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
130 def finalize_options(self):
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
131 # Synchronize this with Py_LIMITED_API
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
132 self.py_limited_api = 'cp37'
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
133 super().finalize_options()
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
134
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
135 cmdclass["bdist_wheel"] = BDistWheel
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
136 else:
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
137
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
138 if not os.path.isfile("configmix/_speedups.pyd"):
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
139 raise RuntimeError("no _speedups.pyd found")
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
140
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
141 setup_extra_kwds["package_data"] = {
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
142 "configmix": ["*.pyd"]
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
143 }
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
144
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
145 ext_modules = []
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
146
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
147 py_limited_api = True
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
148
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
149 if py_limited_api:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
150 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
151 # Build a wheel that is properly named using the stable API
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
152 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
153 try:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
154 import wheel.bdist_wheel
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
155 except ImportError:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
156 pass
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
157 else:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
158 class BDistWheel(wheel.bdist_wheel.bdist_wheel):
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
159 def finalize_options(self):
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
160 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
161 # Synchronize this with Py_LIMITED_API and with the
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
162 # external build of _speedups.pyd.
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
163 # Also use the --plat-name (-p) for tagging the Wheel
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
164 # properly (e.g. -p win_amd64).
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
165 #
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
166 self.py_limited_api = 'cp37'
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
167 super().finalize_options()
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
168
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
169 cmdclass["bdist_wheel"] = BDistWheel
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
170
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
171 from setuptools.dist import Distribution
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
172
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
173 #
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
174 # Force a binary package. An empty ext_modules does not do this always.
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
175 # Tested with wheel v0.29.0
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
176 #
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
177 class BinaryDistribution(Distribution):
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
178 """Distribution which always forces a binary package with
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
179
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
180 platform name
542
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
181
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
182 """
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
183 def has_ext_modules(foo):
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
184 return True
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
185
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
186 setup_extra_kwds["distclass"] = BinaryDistribution
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
187 else:
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
188 #
586
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
189 # pure
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
190 #
d68e8204f7c3 Allow to build a distribution without C-extensions by using --only-pure
Franz Glasner <fzglas.hg@dom66.de>
parents: 585
diff changeset
191 pass
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
192
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
193
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
194 if ext_modules is not None:
567
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
195 setup_extra_kwds["ext_modules"] = ext_modules
569
1bdf88437555 FIX: zip_safe: make zip_safe False if extensions are to be built
Franz Glasner <fzglas.hg@dom66.de>
parents: 568
diff changeset
196 setup_extra_kwds["zip_safe"] = False
1bdf88437555 FIX: zip_safe: make zip_safe False if extensions are to be built
Franz Glasner <fzglas.hg@dom66.de>
parents: 568
diff changeset
197 else:
1bdf88437555 FIX: zip_safe: make zip_safe False if extensions are to be built
Franz Glasner <fzglas.hg@dom66.de>
parents: 568
diff changeset
198 setup_extra_kwds["zip_safe"] = True
567
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
199 if cmdclass:
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
200 setup_extra_kwds["cmdclass"] = cmdclass
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
201
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
202 setup(
582
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
203 name=PROJECT_NAME,
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
204 version=version,
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
205 author="Franz Glasner",
296
eed16a1ec8f3 Use SPDX license identifiers (either full or short) all over the package
Franz Glasner <fzglas.hg@dom66.de>
parents: 282
diff changeset
206 license='BSD 3-Clause "New" or "Revised" License',
5
dc058099a4cb Renamed the project from "MixConfig" to "ConfigMix"
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
207 url="https://pypi.dom66.de/simple/configmix/",
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
208 description="Library for extended configuration files",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
209 long_description=long_description,
568
ed1f0fdcda65 Provide the content-type for the long package description: text/x-rst
Franz Glasner <fzglas.hg@dom66.de>
parents: 567
diff changeset
210 long_description_content_type="text/x-rst",
282
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
211 packages=["configmix",
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
212 "configmix.extras"],
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
213 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
214 # Use non-automatic explicit package_data instead
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
215 # (or MANIFEST.in for sdist)
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
216 #
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
217 include_package_data=False,
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
218 platforms="any",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
219 classifiers=[
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
220 "Development Status :: 5 - Production/Stable",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
221 "Environment :: Console",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
222 "Intended Audience :: Developers",
4
f76d85ccc5b9 Switch to the "New BSD License"
Franz Glasner <f.glasner@feldmann-mg.com>
parents: 0
diff changeset
223 "License :: OSI Approved :: BSD License",
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
224 "Operating System :: OS Independent",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
225 "Programming Language :: Python",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
226 "Programming Language :: Python :: 2.6",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
227 "Programming Language :: Python :: 2.7",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
228 "Programming Language :: Python :: 3",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
229 "Topic :: Software Development :: Libraries :: Python Modules"
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
230 ],
185
5c27e52c3483 Declare requirements on the Python version formally also
Franz Glasner <fzglas.hg@dom66.de>
parents: 184
diff changeset
231 python_requires=">=2.6",
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
232 extras_require={
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
233 "aws": aws_requirements, # noqa: E241
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
234 "toml": toml_requirements,
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
235 "yaml": yaml_requirements,
575
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
236 "all": all_requirements, # noqa: E241
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
237 },
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
238 tests_require=all_requirements,
567
059260191371 Tweak setup.py to build packages with pure-Python tags if the extension is not expected to be built (Python 3.4-)
Franz Glasner <fzglas.hg@dom66.de>
parents: 546
diff changeset
239 **setup_extra_kwds
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
240 )