66from pathlib import Path
77
88from setuptools import Extension
9- from setuptools import find_packages
9+ from setuptools import find_namespace_packages
1010from setuptools import setup
1111from setuptools .command .build import build
1212from setuptools .command .build_ext import build_ext
2323 Cython = None
2424
2525# Enable code coverage for C code: we cannot use CFLAGS=-coverage in tox.ini, since that may mess with compiling
26- # dependencies (e.g. numpy). Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
26+ # dependencies (e.g. numpy). Therefore, we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
2727# deps have been safely installed).
2828if 'TOX_ENV_NAME' in os .environ and os .environ .get ('SETUPPY_EXT_COVERAGE' ) == 'yes' :
2929 CFLAGS = os .environ ['CFLAGS' ] = '-DCYTHON_TRACE=1'
3030 LFLAGS = os .environ ['LFLAGS' ] = ''
3131else :
3232 CFLAGS = ''
3333 LFLAGS = ''
34+
35+ allow_extensions = True
36+ if '__pypy__' in sys .builtin_module_names :
37+ print ('NOTICE: C extensions disabled on PyPy (would be broken)!' )
38+ allow_extensions = False
39+ if os .environ .get ('SETUPPY_FORCE_PURE' ):
40+ print ('NOTICE: C extensions disabled (SETUPPY_FORCE_PURE)!' )
41+ allow_extensions = False
42+
3443pth_file = str (Path (__file__ ).parent .joinpath ('src' , 'hunter.pth' ))
3544
3645
@@ -70,8 +79,6 @@ class OptionalBuildExt(build_ext):
7079
7180 def run (self ):
7281 try :
73- if os .environ .get ('SETUPPY_FORCE_PURE' ):
74- raise Exception ('C extensions disabled (SETUPPY_FORCE_PURE)!' )
7582 super ().run ()
7683 except Exception as e :
7784 self ._unavailable (e )
@@ -121,29 +128,30 @@ def read(*names, **kwargs):
121128 re .compile ('^.. start-badges.*^.. end-badges' , re .M | re .S ).sub ('' , read ('README.rst' )),
122129 re .sub (':[a-z]+:`~?(.*?)`' , r'``\1``' , read ('CHANGELOG.rst' )),
123130 ),
131+ long_description_content_type = 'text/x-rst' ,
124132 author = 'Ionel Cristian Mărieș' ,
125133 author_email = 'contact@ionelmc.ro' ,
126134 url = 'https://github.com/ionelmc/python-hunter' ,
127- packages = find_packages ('src' ),
135+ packages = find_namespace_packages ('src' ),
128136 package_dir = {'' : 'src' },
129137 py_modules = [path .stem for path in Path ('src' ).glob ('*.py' )],
138+ include_package_data = True ,
130139 zip_safe = False ,
131140 classifiers = [
132141 # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
133142 'Development Status :: 5 - Production/Stable' ,
134143 'Intended Audience :: Developers' ,
135- 'License :: OSI Approved :: BSD License' ,
136144 'Operating System :: Unix' ,
137145 'Operating System :: POSIX' ,
138146 'Operating System :: Microsoft :: Windows' ,
139147 'Programming Language :: Python' ,
140148 'Programming Language :: Python :: 3' ,
141149 'Programming Language :: Python :: 3 :: Only' ,
142- 'Programming Language :: Python :: 3.8' ,
143150 'Programming Language :: Python :: 3.9' ,
144151 'Programming Language :: Python :: 3.10' ,
145152 'Programming Language :: Python :: 3.11' ,
146153 'Programming Language :: Python :: 3.12' ,
154+ 'Programming Language :: Python :: 3.13' ,
147155 'Programming Language :: Python :: Implementation :: CPython' ,
148156 'Programming Language :: Python :: Implementation :: PyPy' ,
149157 'Topic :: Utilities' ,
@@ -163,7 +171,7 @@ def read(*names, **kwargs):
163171 'code' ,
164172 'source' ,
165173 ],
166- python_requires = '>=3.8 ' ,
174+ python_requires = '>=3.9 ' ,
167175 install_requires = [],
168176 extras_require = {
169177 ':platform_system != "Windows"' : ['manhole >= 1.5' ],
@@ -190,19 +198,17 @@ def read(*names, **kwargs):
190198 'develop' : DevelopWithPTH ,
191199 'build_ext' : OptionalBuildExt ,
192200 },
193- ext_modules = (
194- []
195- if hasattr (sys , 'pypy_version_info' )
196- else [
197- Extension (
198- str (path .relative_to ('src' ).with_suffix ('' )).replace (os .sep , '.' ),
199- sources = [str (path )],
200- extra_compile_args = CFLAGS .split (),
201- extra_link_args = LFLAGS .split (),
202- include_dirs = [str (path .parent )],
203- )
204- for path in Path ('src' ).glob ('**/*.pyx' if Cython else '**/*.c' )
205- ]
206- ),
207- distclass = BinaryDistribution ,
201+ ext_modules = [
202+ Extension (
203+ str (path .relative_to ('src' ).with_suffix ('' )).replace (os .sep , '.' ),
204+ sources = [str (path )],
205+ extra_compile_args = CFLAGS .split (),
206+ extra_link_args = LFLAGS .split (),
207+ include_dirs = [str (path .parent )],
208+ )
209+ for path in Path ('src' ).glob ('**/*.pyx' if Cython else '**/*.c' )
210+ ]
211+ if allow_extensions
212+ else [],
213+ distclass = BinaryDistribution if allow_extensions else None ,
208214)
0 commit comments