Skip to content

Commit

Permalink
Flag handling was brittle, change.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwallerb committed Jun 24, 2024
1 parent 522f081 commit 81e4fc7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os: [ubuntu-latest, windows-2019, macOS-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Conda
uses: s-weigand/setup-conda@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
numpy-version: auto
python-version: 3.9
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Build distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Examine system
run: pip freeze --all
Expand Down
30 changes: 23 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,29 @@ def update_flags(exec, update):
# First, let us clean up the mess of compiler options a little bit: Move
# flags out into a dictionary, thereby removing the myriad of duplicates
print("FLAGS", exec)
cc_so, *cflags_so = exec
def _splitflag(arg):
arg = arg.split("=", 1)
if len(arg) == 1:
arg = arg + [None]
return arg
cflags_so = {k: v for (k,v) in map(_splitflag, cflags_so)}
cc_so, *cflags_so_list = exec

cflags_curr = None
cflags_so = {}
for arg in cflags_so_list:
if arg.startswith("-"):
if cflags_curr is not None:
cflags_so[cflags_curr] = None
cflags_curr = None
arg = arg.split("=", 1)
if len(arg) == 1:
cflags_curr, = arg
else:
k, v = arg
cflags_so[k] = v
else:
if cflags_curr is None:
raise ValueError("expected flag" + str(exec))
cflags_so[cflags_curr] = arg
if cflags_curr is not None:
cflags_so[cflags_curr] = None

print("FLAGS_DICT", cflags_so)

# Now update the flags
cflags_so.update(update)
Expand Down

0 comments on commit 81e4fc7

Please sign in to comment.