You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pip install klayout doesn't seem to work on M1 MacBookPro #1040
First of all thanks for making this software, you're all fantastic and I appreciate your patience. This is the first issue I've ever made, so I hope I get the situation right. Running MacBook Pro (14-inch, 2021) version 12.3 (21E230).
Using pyenv I have python 3.10.2 installed with the latest version of pip.
I want to use the klayout module, but I can't install it with pip install klayout. I've also tried to download the source distribution, went to that folder, and ran pip install . with no difference.
It seems like pip tries to make a wheel, fails, runs setup.py, and fails there too. What's clear to me is that there are some missing files and many clang errors. The terminal output is incredibly long and exceeds the maximum character limit for github's issues. Please see attached for the output: Full Terminal Ouput.txt
I'm sure you've looked into it, but if you have homebrew perhaps try brew install wheel and try to install it again. If failed we might have the same issue and it's more generic than I thought.
src/db/db/dbCompoundOperation.cc:756:17: error: type 'db::CompoundRegionGeometricalBoolOperationNode::GeometricalOp' cannot be used prior to '::' because it has no members
if (m_op == GeometricalOp::And || m_op == GeometricalOp::Not) {
^
I used to build PyPI packages myself but Travis stopped their generous MacOS support. I don't have hardware to do these builds. Apple seems to adopt new clang versions much faster than my Ubuntu's clang.
In that particular case, the compiler accepts C++11 partially even if not explicitly instructed to use C++11. But then it rejects the qualified enums.
You can try adding "-std=c++11" by patching setup.py. I'd try to remove the "Darwin" branch of "if" in lines 276 and 277:
# elif platform.system() == "Darwin":
# return []
else:
return ["-Wno-strict-aliasing", # Avoids many "type-punned pointer" warnings
"-std=c++11", # because we use unordered_map/unordered_set
]
Let me know if this works, I'll patch the source package accordingly.
src/db/db/dbCompoundOperation.cc:756:17: error: type 'db::CompoundRegionGeometricalBoolOperationNode::GeometricalOp' cannot be used prior to '::' because it has no members
if (m_op == GeometricalOp::And || m_op == GeometricalOp::Not) {
^
I used to build PyPI packages myself but Travis stopped their generous MacOS support. I don't have hardware to do these builds. Apple seems to adopt new clang versions much faster than my Ubuntu's clang.
In that particular case, the compiler accepts C++11 partially even if not explicitly instructed to use C++11. But then it rejects the qualified enums.
You can try adding "-std=c++11" by patching setup.py. I'd try to remove the "Darwin" branch of "if" in lines 276 and 277:
# elif platform.system() == "Darwin":
# return []
else:
return ["-Wno-strict-aliasing", # Avoids many "type-punned pointer" warnings
"-std=c++11", # because we use unordered_map/unordered_set
]
Let me know if this works, I'll patch the source package accordingly.
Matthias
You hit the nail on its head! It worked:
~/Dow/klayout-0.27.8 > pip install .
Processing /Users/me/Downloads/klayout-0.27.8
Preparing metadata (setup.py) ... done
Building wheels for collected packages: klayout
Building wheel for klayout (setup.py) ... done
Created wheel for klayout: filename=klayout-0.27.8-cp310-cp310-macosx_12_0_arm64.whl size=11607025 sha256=f04b556c9bd0b6e3128b9eadcb7e85f91c34d6f8214906fcc7a7254c02675721
Stored in directory: /Users/me/Library/Caches/pip/wheels/8f/58/fc/18431eb5d45eb05d5faf94d91c74763691c8472953c2a8a705
Successfully built klayout
Installing collected packages: klayout
Successfully installed klayout-0.27.8
(base) MacBookPro2{kazzz-s}(1)$ pwd
/Users/kazzz-s/temp
(base) MacBookPro2{kazzz-s}(2)$ python
Python 3.8.2 (default, Mar 26 2020, 10:43:30)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pya
>>>
(base) MacBookPro2{kazzz-s}(3)$ ll
:
-rw-r--r-- 1 kazzz-s staff 1125 3 25 18:43 sample.py
(base) MacBookPro2{kazzz-s}(4)$ python sample.py
(base) MacBookPro2{kazzz-s}(5)$ ll
:
-rw-r--r-- 1 kazzz-s staff 6316 3 25 18:46 basic.gds
-rw-r--r-- 1 kazzz-s staff 1125 3 25 18:43 sample.py
#
# "sample.py" from https://www.klayout.org/klayout-pypi/
#
import klayout.db as db
ly = db.Layout()
# sets the database unit to 1 nm
ly.dbu = 0.001
# adds a single top cell
top_cell = ly.create_cell("SAMPLE")
# creates a new layer (layer number 1, datatype 0)
layer1 = ly.layer(1, 0)
pattern = """
.#...#.#......###..#...#..###..#...#.#####
.#..#..#.....#...#.#...#.#...#.#...#...#..
.#.#...#.....#...#.#...#.#...#.#...#...#..
.##....#.....#####..#.# .#...#.#...#...#..
.#.#...#.....#...#...#. .#...#.#...#...#..
.#..#..#.....#...#...#. .#...#.#...#...#..
.#...#.#####.#...#...#. ..###...###....#..
"""
# produces pixels from the bitmap as 0.5x0.5 µm
# boxes on a 1x1 µm grid:
y = 8.0
for line in pattern.split("\n"):
x = 0.0
for bit in line:
if bit == "#":
# creates a rectangle for the "on" pixel
rect = db.DBox(0, 0, 0.5, 0.5).moved(x, y)
top_cell.shapes(layer1).insert(rect)
x += 1.0
y -= 1.0
# adds an envelope box on layer 2/0
layer2 = ly.layer(2, 0)
envelope = top_cell.dbbox().enlarged(1.0, 1.0)
top_cell.shapes(layer2).insert(envelope)
# writes the layout to GDS
ly.write("basic.gds")
[Added on 2022-03-26]
To build and use a pymod wheel package
OS: macOS Big Sur (11.6)
Python Environment: Anaconda3
(base) BigSur2{kazzz-s} site-packages (4)% pwd
/Applications/anaconda3/lib/python3.8/site-packages
(base) BigSur2{kazzz-s} site-packages (5)% ll -rt
drwxr-xr-x 19 kazzz-s wheel 608 3 26 22:38 klayout
drwxr-xr-x 4 kazzz-s wheel 128 3 26 22:38 pya
drwxr-xr-x 10 kazzz-s wheel 320 3 26 22:38 klayout-0.27.8.dist-info
(base) BigSur2{kazzz-s} temp (6)% python
Python 3.8.2 (default, Mar 26 2020, 10:43:30)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pya
>>> help(pya)
=====================
Help on package pya:
NAME
pya
DESCRIPTION
# import all packages from klayout, such as klayout.db and klayout.tl
# WARNING: doing it manually until it becomes impractical
# TODO: We need a specification document explaining what should go into pya
PACKAGE CONTENTS
FILE
/Applications/anaconda3/lib/python3.8/site-packages/pya/__init__.py
(END)
=====================
I just encountered this using my non-M1 Mac (it's been a while for me). This seems to have helped me. However, on the #1045 branch, it still failed because the extensions tlcore, dbcore etc did not have the extra compilation flags in setup.py. I have added them to the pull request. Hope you don't mind.
Activity
Crostiphex commentedon Mar 24, 2022
I'm sure you've looked into it, but if you have homebrew perhaps try
brew install wheeland try to install it again. If failed we might have the same issue and it's more generic than I thought.klayoutmatthias commentedon Mar 24, 2022
Looks like yet another compiler issue:
I used to build PyPI packages myself but Travis stopped their generous MacOS support. I don't have hardware to do these builds. Apple seems to adopt new clang versions much faster than my Ubuntu's clang.
In that particular case, the compiler accepts C++11 partially even if not explicitly instructed to use C++11. But then it rejects the qualified enums.
You can try adding "-std=c++11" by patching setup.py. I'd try to remove the "Darwin" branch of "if" in lines 276 and 277:
Let me know if this works, I'll patch the source package accordingly.
Matthias
Crostiphex commentedon Mar 24, 2022
You hit the nail on its head! It worked:
Kazzz-S commentedon Mar 25, 2022
Dear @klayoutmatthias,
Thank you very much for the patch idea.
I have tried on macOS Catalina (10.15.7) with Anaconda3, as shown below.
Regards,
Kazzz-S
[Added on 2022-03-26]
To build and use a pymod wheel package
OS: macOS Big Sur (11.6)
Python Environment: Anaconda3
<< Build Steps >>
<< Installation >>
<< Check >>
klayoutmatthias commentedon Mar 25, 2022
Very good! And I see the PyPI package documentation got discovered :)
I'll establish this patch permanently for master and 0.27 branch. Thanks for you feedback!
Matthias
Applied patch as discussed in #1040
Adding extra compilation flags to extensions #1040
thomaslima commentedon Mar 30, 2022
Hi @klayoutmatthias
I just encountered this using my non-M1 Mac (it's been a while for me). This seems to have helped me. However, on the #1045 branch, it still failed because the extensions tlcore, dbcore etc did not have the extra compilation flags in setup.py. I have added them to the pull request. Hope you don't mind.
Thanks!
Thomas
Applied patch as discussed in #1040 (#1045)
Applied patch as discussed in #1040 (#1045)
klayoutmatthias commentedon Apr 24, 2022
Released with 0.27.9