annotate setup.py @ 582:0467b3ae34ea

setup.py: Put the official projectname into a variable and re-use
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 09 Jan 2022 12:47:56 +0100
parents 3ad416265652
children 4e61df27b4e1
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
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
4 import re
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
5 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
6 import platform
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
7 import sys
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
8 try:
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
9 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
10 except ImportError:
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
11 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
12
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
13
582
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
14 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
15
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
16
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
17 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
18 ((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
19 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
20
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
21 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
22
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
23 _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
24 re.MULTILINE)
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
25
5
dc058099a4cb Renamed the project from "MixConfig" to "ConfigMix"
Franz Glasner <hg@dom66.de>
parents: 4
diff changeset
26 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
27 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
28
71
80dcb41928a7 Rename README to README.txt to be more consistent with LICENSE.txt
Franz Glasner <hg@dom66.de>
parents: 70
diff changeset
29 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
30 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
31
282
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
32 aws_requirements = [
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
33 "requests",
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
34 ]
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
35
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
36 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
37 "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
38 ]
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
39
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
40 toml_requirements = [
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
41 "toml>=0.10",
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
42 ]
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
43
184
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
44 all_requirements = []
282
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
45 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
46 all_requirements.extend(yaml_requirements)
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
47 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
48
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
49
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
50 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
51 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
52 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
53
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 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
55
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
56 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
57 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
58 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
59 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
60 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
61 del sys.argv[wcp_idx]
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
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
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 if wcp_idx is 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
65
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
66 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
67 # Otherwise some cached package_data would be used.
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
68 # But our package data differs between "standard" builds and
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
69 # builds with "--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
70 #
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
582
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
72 if os.path.isdir(PROJECT_NAME + ".egg-info"):
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
73 raise RuntimeError(
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
74 "please remove %s.egg-info before" % (PROJECT_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
75
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
76 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
77 # Handle the optinal C-extension for Python3.7+ and CPython only.
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
78 # PyPy does not need this.
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
79 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
80
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 # The C-extension uses multi-phase module initialization (PEP 489, PY 3.5+)
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
82 if (platform.python_implementation() == "CPython"
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
83 and (sys.version_info[0] > 3
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
84 or (sys.version_info[0] == 3 and sys.version_info[1] >= 5))):
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
85
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
86 # The stable API for Python 3.7+ is used
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
87 if sys.version_info[0] == 3 and sys.version_info[1] < 7:
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
88 py_limited_api = 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
89 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
90 py_limited_api = True
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
91
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
92 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
93 define_macros = [("Py_LIMITED_API", "0x03070000")]
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
94 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
95 define_macros = []
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
96
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
97 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
98 from setuptools import Extension
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
99 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
100 from distutils.core import Extension
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
101
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
102 ext_modules = [
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
103 Extension(
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
104 name="configmix._speedups",
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
105 sources=["configmix/_speedups.c"],
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
106 define_macros=define_macros,
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
107 py_limited_api=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
108 optional=True
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 ),
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
110 ]
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
111
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
112 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
113 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
114 # 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
115 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
116 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
117 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
118 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
119 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
120 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
121 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
122 def finalize_options(self):
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
123 # Synchronize this with 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
124 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
125 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
126
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
127 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
128 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
129
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
130 if not os.path.isfile("configmix/_speedups.pyd"):
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
131 raise RuntimeError("no _speedups.pyd found")
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
132
582
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
133 if os.path.isdir(PROJECT_NAME + ".egg-info"):
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
134 raise RuntimeError(
0467b3ae34ea setup.py: Put the official projectname into a variable and re-use
Franz Glasner <fzglas.hg@dom66.de>
parents: 577
diff changeset
135 "please remove %s.egg-info before" % (PROJECT_NAME,))
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
136
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
137 setup_extra_kwds["package_data"] = {
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
138 "configmix": ["*.pyd"]
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
139 }
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
140
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
141 ext_modules = []
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
142
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
143 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
144
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
145 if py_limited_api:
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
146 #
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
147 # Build a wheel that is properly named using the stable API
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 #
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
149 try:
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
150 import wheel.bdist_wheel
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
151 except ImportError:
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
152 pass
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
153 else:
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
154 class BDistWheel(wheel.bdist_wheel.bdist_wheel):
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
155 def finalize_options(self):
577
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
156 #
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
157 # Synchronize this with Py_LIMITED_API and with the
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
158 # external build of _speedups.pyd.
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
159 # Also use the --plat-name (-p) for tagging the Wheel
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
160 # properly (e.g. -p win_amd64).
3ad416265652 Comment
Franz Glasner <fzglas.hg@dom66.de>
parents: 575
diff changeset
161 #
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
162 self.py_limited_api = 'cp37'
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
163 super().finalize_options()
f71d34dda19f Add an optional C-implementation for configmix.config.unquote and configmix.config.pathstr2path.
Franz Glasner <fzglas.hg@dom66.de>
parents: 296
diff changeset
164
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
165 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
166
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 from setuptools.dist import Distribution
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 #
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 # Force a binary package. An empty ext_modules does not do this always.
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
171 # Tested with wheel v0.29.0
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 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
173 class BinaryDistribution(Distribution):
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
174 """Distribution which always forces a binary package with
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
175
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
176 platform name
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
177
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
178 """
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
179 def has_ext_modules(foo):
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
180 return True
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
181
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
182 setup_extra_kwds["distclass"] = BinaryDistribution
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
183
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
184
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 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
186 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
187 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
188 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
189 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
190 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
191 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
192
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
193 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
194 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
195 version=version,
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
196 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
197 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
198 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
199 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
200 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
201 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
202 packages=["configmix",
da1596034954 Implemented an "AWS" namespace to retrieve some AWS-specific metadata
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
203 "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
204 #
9ce13f753c04 Allow execution of setup.py by packaging a cross-built Windows _speedups.pyd.
Franz Glasner <fzglas.hg@dom66.de>
parents: 569
diff changeset
205 # 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
206 # (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
207 #
0
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
208 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
209 platforms="any",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
210 classifiers=[
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
211 "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
212 "Environment :: Console",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
213 "Intended Audience :: Developers",
4
f76d85ccc5b9 Switch to the "New BSD License"
Franz Glasner <f.glasner@feldmann-mg.com>
parents: 0
diff changeset
214 "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
215 "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
216 "Programming Language :: Python",
53ea2bc254e7 Begin a package to abstract some of the important configuration handling stuff.
Franz Glasner <hg@dom66.de>
parents:
diff changeset
217 "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
218 "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
219 "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
220 "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
221 ],
185
5c27e52c3483 Declare requirements on the Python version formally also
Franz Glasner <fzglas.hg@dom66.de>
parents: 184
diff changeset
222 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
223 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
224 "aws": aws_requirements, # noqa: E241
195
28e6c1413947 Added support for TOML style configuration files
Franz Glasner <fzglas.hg@dom66.de>
parents: 185
diff changeset
225 "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
226 "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
227 "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
228 },
781b8dc1883f Use the pip "extras" feature to install optional features (e.g. PyYAML)
Franz Glasner <fzglas.hg@dom66.de>
parents: 80
diff changeset
229 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
230 **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
231 )