Skip to content

Commit 32cb65b

Browse files
committed
Write custom sdist command for basemap
We need to do this because we are using `data_files` to inject the DLL when building the wheels for Windows, but this DLL should never be included in a source distribution.
1 parent e562a38 commit 32cb65b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/basemap/setup.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import warnings
1111
from setuptools import setup
1212
from setuptools import find_packages
13+
from setuptools.command.sdist import sdist
1314
from setuptools.dist import Distribution
1415
from setuptools.extension import Extension
1516

@@ -42,6 +43,18 @@ def checkversion(directory):
4243
return version
4344

4445

46+
class basemap_sdist(sdist):
47+
"""Custom `sdist` so that it will not pack DLLs on Windows if present."""
48+
49+
def finalize_options(self):
50+
"""Call `finalize_options` after cleaning `data_files` and reset."""
51+
52+
orig_data_files = self.distribution.data_files
53+
self.distribution.data_files = []
54+
sdist.finalize_options(self)
55+
self.distribution.data_files = orig_data_files
56+
57+
4558
# Initialise include and library dirs.
4659
include_dirs = []
4760
library_dirs = []
@@ -98,7 +111,7 @@ def checkversion(directory):
98111
if os.name == "nt":
99112
# On Windows:
100113
# - DLLs get installed under `bin`.
101-
# - We need to inject the DLL in the wheel using `data_files`.
114+
# - We need to inject later the DLL in the wheel using `data_files`.
102115
# - We do not use `runtime_library_dirs` as workaround for a
103116
# `distutils` bug (http://bugs.python.org/issue2437).
104117
library_dirs.append(os.path.join(geos_installdir, "bin"))
@@ -218,6 +231,9 @@ def checkversion(directory):
218231
"doc":
219232
doc_requires,
220233
},
234+
"cmdclass": {
235+
"sdist": basemap_sdist,
236+
},
221237
"project_urls": {
222238
"Bug Tracker":
223239
"https://github.com/matplotlib/basemap/issues",

0 commit comments

Comments
 (0)