Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit a9419ba

Browse files
authored
Do not pre-cythonize for sdist and update build scripts (#182)
* do not pre-cythonize when calling sdist * continue
1 parent 924f25c commit a9419ba

File tree

4 files changed

+32
-68
lines changed

4 files changed

+32
-68
lines changed

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ include MANIFEST.in
22
include README.rst
33
include Makefile
44
include requirements*.txt
5-
recursive-include lightning *.c *.h *.cpp *.pyx *.pxd
5+
recursive-include lightning *.c *.h *.pyx *.pxd

lightning/_build_utils.py

-59
This file was deleted.

lightning/setup.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1+
import sys
2+
13
from numpy.distutils.core import setup
24
from numpy.distutils.misc_util import Configuration
35

4-
from lightning._build_utils import maybe_cythonize_extensions
6+
7+
def cythonize_extensions(top_path, config):
8+
try:
9+
from Cython.Build import cythonize
10+
except ModuleNotFoundError as e:
11+
raise ModuleNotFoundError(
12+
'Please install Cython in order to build a lightning from source.') from e
13+
14+
config.ext_modules = cythonize(config.ext_modules,
15+
compiler_directives={'language_level': 3})
516

617

718
def configuration(parent_package='', top_path=None):
819
config = Configuration('lightning', parent_package, top_path)
920

1021
config.add_subpackage('impl')
1122

12-
maybe_cythonize_extensions(top_path, config)
23+
# Skip cythonization as we do not want to include the generated
24+
# C/C++ files in the release tarballs as they are not necessarily
25+
# forward compatible with future versions of Python for instance.
26+
if 'sdist' not in sys.argv:
27+
cythonize_extensions(top_path, config)
1328

1429
return config
1530

setup.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
import re
66
import sys
77
import os
8-
from distutils.command.sdist import sdist
98
import setuptools
9+
10+
from distutils.command.sdist import sdist
11+
1012
from numpy.distutils.core import setup
13+
from numpy.distutils.misc_util import Configuration
1114

1215

1316
DISTNAME = 'sklearn-contrib-lightning'
@@ -19,7 +22,6 @@
1922
MAINTAINER_EMAIL = 'mathieu@mblondel.org'
2023
URL = 'https://github.com/scikit-learn-contrib/lightning'
2124
LICENSE = 'new BSD'
22-
DOWNLOAD_URL = URL
2325
with open(os.path.join('lightning', '__init__.py'), encoding='utf-8') as f:
2426
match = re.search(r'__version__[ ]*=[ ]*[\"\'](?P<version>.+)[\"\']',
2527
f.read())
@@ -37,9 +39,15 @@ def configuration(parent_package='', top_path=None):
3739
if os.path.exists('MANIFEST'):
3840
os.remove('MANIFEST')
3941

40-
from numpy.distutils.misc_util import Configuration
4142
config = Configuration(None, parent_package, top_path)
4243

44+
# Avoid non-useful msg:
45+
# "Ignoring attempt to set 'name' (from ... "
46+
config.set_options(ignore_setup_xxx_py=True,
47+
assume_default_configuration=True,
48+
delegate_options_to_subpackages=True,
49+
quiet=True)
50+
4351
config.add_subpackage('lightning')
4452

4553
return config
@@ -55,7 +63,7 @@ def configuration(parent_package='', top_path=None):
5563
setup(configuration=configuration,
5664
name=DISTNAME,
5765
maintainer=MAINTAINER,
58-
python_requires='>={}'.format(MIN_PYTHON_VERSION),
66+
python_requires=f'>={MIN_PYTHON_VERSION}',
5967
install_requires=REQUIREMENTS,
6068
include_package_data=True,
6169
scripts=["bin/lightning_train",
@@ -65,7 +73,7 @@ def configuration(parent_package='', top_path=None):
6573
license=LICENSE,
6674
url=URL,
6775
version=VERSION,
68-
download_url=DOWNLOAD_URL,
76+
download_url=URL,
6977
long_description=LONG_DESCRIPTION,
7078
zip_safe=False, # the package can run out of an .egg file
7179
cmdclass={"sdist": sdist},
@@ -74,7 +82,7 @@ def configuration(parent_package='', top_path=None):
7482
'Intended Audience :: Developers',
7583
'License :: OSI Approved',
7684
'Programming Language :: C',
77-
'Programming Language :: Python',
85+
'Programming Language :: Python :: 3',
7886
'Topic :: Software Development',
7987
'Topic :: Scientific/Engineering',
8088
'Operating System :: Microsoft :: Windows',

0 commit comments

Comments
 (0)