Skip to content

Commit 1f10240

Browse files
committed
Fix custom sdist command
1 parent 7808aa5 commit 1f10240

File tree

4 files changed

+34
-14
lines changed

4 files changed

+34
-14
lines changed

.github/workflows/basemap-for-windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
$env:GEOS_DIR = "extern"
148148
$env:NUMPY_INCLUDE_PATH = "extern/include"
149149
pip install -r requirements-setup.txt
150-
python setup.py bdist_wheel
150+
python setup.py sdist bdist_wheel
151151
-
152152
name: Upload build artifacts
153153
uses: actions/upload-artifact@v1
@@ -205,6 +205,7 @@ jobs:
205205
TWINE_REPOSITORY_URL: "${{ secrets.PYPI_REPOSITORY_URL }}"
206206
run: |
207207
python -m twine check `
208+
${{ env.PKGDIR }}/dist/*.zip `
208209
${{ env.PKGDIR }}/dist/*-win*.whl
209210
python -m twine upload --skip-existing `
210211
${{ env.PKGDIR }}/dist/*-win*.whl

packages/basemap/setup.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,28 @@ def get_geos_install_prefix():
6464
class basemap_sdist(sdist):
6565
"""Custom `sdist` so that it will not pack DLLs on Windows if present."""
6666

67-
def finalize_options(self):
68-
"""Call `finalize_options` after cleaning `data_files` and reset."""
69-
70-
self.formats = ["zip"]
67+
def run(self):
68+
"""Custom `run` command."""
7169

70+
# Replace DLL data files and add GEOS build script.
7271
orig_data_files = self.distribution.data_files
73-
self.distribution.data_files = []
74-
sdist.finalize_options(self)
75-
self.distribution.data_files = orig_data_files
72+
self.distribution.data_files = [
73+
(".", glob.glob(os.path.join("utils", "*.py")))]
74+
75+
# Run the original `run` method and leave `data_files` as it was found.
76+
try:
77+
sdist.run(self)
78+
finally:
79+
self.distribution.data_files = orig_data_files
80+
81+
def initialize_options(self):
82+
"""Call `initialize_options` and then set zip as default format."""
83+
84+
sdist.initialize_options(self)
85+
self._default_to_zip()
86+
87+
def _default_to_zip(self):
88+
self.formats = ["zip"]
7689

7790

7891
# Initialise include and library dirs.

packages/basemap_data/setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ def get_content(name, splitlines=False):
2626
class basemap_data_sdist(sdist):
2727
"""Custom `sdist` so that it will force to save in zip format."""
2828

29-
def finalize_options(self):
30-
"""Enforce zip format before calling `finalize_options`."""
29+
def initialize_options(self):
30+
"""Call `initialize_options` and then set zip as default format."""
3131

32+
sdist.initialize_options(self)
33+
self._default_to_zip()
34+
35+
def _default_to_zip(self):
3236
self.formats = ["zip"]
33-
sdist.finalize_options(self)
3437

3538

3639
# Define some helper lists.

packages/basemap_data_hires/setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ def get_content(name, splitlines=False):
2626
class basemap_data_hires_sdist(sdist):
2727
"""Custom `sdist` so that it will force to save in zip format."""
2828

29-
def finalize_options(self):
30-
"""Enforce zip format before calling `finalize_options`."""
29+
def initialize_options(self):
30+
"""Call `initialize_options` and then set zip as default format."""
3131

32+
sdist.initialize_options(self)
33+
self._default_to_zip()
34+
35+
def _default_to_zip(self):
3236
self.formats = ["zip"]
33-
sdist.finalize_options(self)
3437

3538

3639
# Define some helper lists.

0 commit comments

Comments
 (0)