Skip to content

Commit 3ecaec6

Browse files
committed
Add Python script for cibuildwheel before_all block
1 parent b82fb80 commit 3ecaec6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/run_before_all.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#! /usr/bin/env python
2+
"""Helper script to be run by `cibuildwheel` as `before_all` step."""
3+
4+
importos
5+
importsys
6+
7+
HERE=os.path.abspath(__file__)
8+
ROOT=os.path.dirname(os.path.dirname(os.path.dirname(HERE)))
9+
sys.path.insert(0, os.path.join(ROOT, "packages", "basemap"))
10+
importutils# noqa: E402 # pylint: disable=imports
11+
12+
13+
defmain():
14+
"""Build the GEOS library based on parsed environment variables."""
15+
16+
geos_version=os.environ.get("GEOS_VERSION", None)
17+
ifgeos_versionisNone:
18+
raiseValueError("Undefined environment variable GEOS_VERSION")
19+
20+
geos_dir=os.environ.get("GEOS_DIR", None)
21+
ifgeos_dirisNone:
22+
raiseValueError("Undefined environment variable GEOS_DIR")
23+
24+
geos_njobs=int(os.environ.get("GEOS_NJOBS", 1))
25+
26+
# pylint: disable=consider-using-f-string
27+
print("Running before_all script with the following settings:")
28+
print("GEOS_DIR: {0}".format(geos_dir))
29+
print("GEOS_VERSION: {0}".format(geos_version))
30+
print("GEOS_NJOBS: {0}".format(geos_njobs))
31+
32+
utils.GeosLibrary(geos_version).build(geos_dir, njobs=geos_njobs)
33+
return0
34+
35+
36+
if__name__=="__main__":
37+
sys.exit(main())

0 commit comments

Comments
 (0)
close