Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macos #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Macos #2

wants to merge 2 commits into from

Conversation

tobiasjewson
Copy link

A couple of minor changes to allow your fork to be built on macOS. I've not tested it extensively, but it builds, installs and imports ok using Blender 4.0.2, macOS Sonoma on an Apple M1 mbp.

Copy link

@tonfdd tonfdd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not work for me. M1 pro Sanoma, blender 4.0.2

@tobiasjewson
Copy link
Author

Hi @tonfdd

Would you be able to provide a bit more context. At which step does it fail?

  1. build
  2. install
  3. import .skp file

Please could you provide any terminal / blender console output to help track down the issue.

@tonfdd
Copy link

tonfdd commented Feb 19, 2024

Hi @tonfdd

Would you be able to provide a bit more context. At which step does it fail?

  1. build
  2. install
  3. import .skp file

Please could you provide any terminal / blender console output to help track down the issue.

Tks for support
After replacing the init.py file, you may need to build. Could you provide more details about the specific steps you’re unsure of in the build process?

@notoriusawh
Copy link

Hi^ The addon does not work on blender 4.0 with Sonoma 14.1.2.

After adding the addon to blender, I can’t check the box to enable it

@darishante
Copy link

darishante commented Feb 19, 2024

Grey for me in Blender 4.02, MacOS 12.7.2 (Monterey).

Built as follows: Downloaded python 3.12, did pip3 install setuptools (got 69.1.0), pip3 install Cython. Copied the .framework files from SketchUp SDK to the install dir.

Had to remove /usr/local/include due to some old crud causing " error: unknown type name 'uint64_t' "
After that, build script runs. Did the last two lines manually as instructed, replacing python version (312)

Copied the frameworks to sketchup_importer. Copied sketchup.cpython-312-darwin.so to sketchup_importer, renamed it to sketchup.so

Made a Zip of the sketchup_importer directory. Added that to add-ons in Blender Edit -> Preferencess. Extension appears, but is not selectable. Trying to select it causes error in Blender:

Traceback (most recent call last): File "/Applications/Blender.app/Contents/Resources/4.0/scripts/modules/addon_utils.py", line 364, in enable mod = importlib.import_module(module_name) File "/Applications/Blender.app/Contents/Resources/4.0/python/lib/python3.10/importlib/_init_.py", line 126, in import_module return _bootstrap._gcd_import(namef[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in __gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/Users/dare/Library/Application Support/Blender/4.0/scripts/addons/sketchup_importer/_init_.py", line 35, in <module> from . import sketchup ImportError: dlopen(/Users/dare/Library/Application Support/Blender/4.0/scripts/addons/sketchup_importer/sketchup.so, 0x0002): symbol not found in flat namespace (_Py_Version)

(edit: gah several mistakes in my report, hope I got most of them, that's what I get for doing this while sick)

@tobiasjewson
Copy link
Author

Hi @darishante,

I think the issue comes from building the plugin with Python 3.12 when Blender 4.0.2 uses Python 3.10.

Here are the steps I took to build a working version with 3.10. Hopefully, it works for you too.

  1. Install Python 3.10
brew install [email protected]
  1. Copy SketchUpAPI.framework (I use the 2023 version of the SDK) to the repo folder.
  2. Working in the repo folder, remove some of the Windows build cruft inherited from the main branch.
rm ./sketchup_importer/sketchup.cp37-win_amd64.pyd ./sketchup_importer/sketchup.cp39-win_amd64.pyd ./sketchup_importer/sketchup.cp310-win_amd64.pyd ./sketchup_importer/sketchup.cp311-win_amd64.pyd ./sketchup_importer/SketchUpAPI.dll ./sketchup_importer/SketchUpCommonPreferences.dll ./sketchup_importer/bak.py
  1. Setup a clean python build environment. Note, I'm using the explicitly versioned instances of python and pip.
python3.10 -m venv env
source env/bin/activate
pip3.10 install Cython
  1. Build the plugin.
python3.10 setup.py build_ext --inplace
mv sketchup.cpython-310-darwin.so ./sketchup_importer/sketchup.so
install_name_tool -change "@rpath/SketchUpAPI.framework/Versions/A/SketchUpAPI" "@loader_path/SketchUpAPI.framework/Versions/A/SketchUpAPI" ./sketchup_importer/sketchup.so
install_name_tool -change "@rpath/SketchUpAPI.framework/Versions/Current/SketchUpAPI" "@loader_path/SketchUpAPI.framework/Versions/Current/SketchUpAPI" ./sketchup_importer/sketchup.so
  1. Package up the plug-in.
mv SketchUpAPI.framework ./sketchup_importer/SketchUpAPI.framework
zip -r sketchup_importer.zip sketchup_importer

@balarayen
Copy link

Hi @tobiasjewson
Followed these steps to rebuild plugin using python 3.11 which Blender 4.1 also is built on.
I can successfully build and enabled the plugin in Blender 4.1.
I could import a .skp file but it throws AttributeError: 'Object' object has no attribute 'layers'.

Any suggestions please?

Screenshot 2024-03-01 at 11 59 50 AM

@tobiasjewson
Copy link
Author

Hi @balarayen,

Since the plugin builds and loads, I'm going to say that the issue is not with this specific branch but with the plugin more generally. Try to strip down the .skp file to the simplest possible version that still fails and submit an issue against the main repo.

Tobias

@balarayen
Copy link

Another simpler .skp file imports well in Blender. Thanks for your response and suggestions @tobiasjewson !

@darishante
Copy link

Hi @darishante,

I think the issue comes from building the plugin with Python 3.12 when Blender 4.0.2 uses Python 3.10.

Here are the steps I took to build a working version with 3.10. Hopefully, it works for you too.

It did! I could add the extension and import simple and complicated models! Thank you so much!

@odil24
Copy link

odil24 commented Mar 12, 2024

@tobiasjewson @balarayen @darishante Please, can you upload here MacOS Blender 4.1 version? Really appriciated!

@KevJames
Copy link

KevJames commented Apr 2, 2024

@balarayen +1 for the Mac version please.

@balarayen
Copy link

@odil24 @KevJames Please see if this helps:
Blender4p1_Addon_sketchup_Importer.zip

@Ghezwo
Copy link

Ghezwo commented Apr 7, 2024

@balarayen Tried it with Blender 4.1 on an M2 MacBook running Sonoma and unfortunately it didn't work

@donaldguy
Copy link

donaldguy commented Jun 25, 2024

to get `python3 setup.py build_ext --inplace` to work per [how I read the] instructions…:

Copy LayOutAPI.framework and SketchUpAPI.framework from SDK directory to pyslapi
but there is no pyslapi so I assumed it meant slapi

... but maybe it just meant repo dir since this repo was forked from one named slapi,


…I had to add -F ./slapi to the flags:

diff --git a/setup.py b/setup.py
index c5eae9d..72f78fe 100644
--- a/setup.py
+++ b/setup.py
@@ -16,10 +16,10 @@ if platform.system() == 'Linux':
 
 elif platform.system() == 'Darwin':  # OS X
     libraries = []
-    extra_compile_args = ['-mmacosx-version-min=10.9', '-F.']
+    extra_compile_args = ['-mmacosx-version-min=10.9', '-F.', '-F./slapi']
     extra_link_args = ['-mmacosx-version-min=10.9',
                        '-F',
-                       '.',
+                       './slapi',
                        '-framework',
                        'SketchUpAPI']
 

@donaldguy
Copy link

donaldguy commented Jun 25, 2024

well, when that didn't work, I tried to cut out the middle man and build using /Applications/Blender.app/Contents/Resources/4.1/python/bin/python3.11 directly

but it turns out this python (in the blender.org download which is also what brew installs):

A. doesn't include libpython (its statically linked into the bin?) or any of its headers (there is a Blender.app/Contents/Resources/4.1/python/include/python3.11/pyconfig.h, which I imagine is insufficient, but also it ain't gonna find it ...)
B. has a pretty bad case of "hardcoded to the person who built its computer" (Prefix: /Users/brecht/dev/build_darwin/deps_arm64/Release/python)

so that certainly can't help with anything

I'mma try building my own blender bin I guess ... but that seems pretty daunting when the git clone has been running for 11 min to get to 96%

EDIT: for the record the 4.2 daily's python has the same properties, modulo that its /Users/raulito/… instead of /Users/brecht/…

@donaldguy
Copy link

donaldguy commented Jun 25, 2024

its a particularly in some ways silly and in some ways opportune time to be attempting this build given that the 4.2 release branch merged to main 5 hours ago blender/blender@840457c

(its also very silly that they have a GitHub mirror of that repo but don't actually have mirrors of the 5 target specific lib, datafiles, or test submodules )

I probably should have (discovered and) gone for: https://download.blender.org/source/blender-with-libraries-4.1.0.tar.xz

maybe it'll slow down or cmake output has me fooled but its looking very possible that actual build time is slower than clone and submodules and lfs download time

@donaldguy
Copy link

annnnd building yourself still uses a pre-compiled python (https://projects.blender.org/blender/lib-macos_arm64/src/branch/main/python ) which in turn has bad hardcoded links to other libs (like openssl)

and they only hung an all or nothing make deps on the blender makefile (though if I were better at CMake I might be able to figure out how to narrow scope)

@donaldguy
Copy link

donaldguy commented Jun 25, 2024

@donaldguy
Copy link

Well the "good" news is that after:

  1. doing a clone and make update per https://developer.blender.org/docs/handbook/building_blender/mac/

  2. starting and then canceling a make deps after it had finished downloading source tarballs (maybe just should have let it run)

  3. going into ../build_darwin/deps_arm64/ (from the blender repo), effectively doing rm -rf build/*/src/* ; doing make external_ssl external_bzip2 external_lmza external_sqlite external_ffi external_zlib external_python external_python_site_packages

  4. editing the Makefile to remove the all dependency on preinstall and editing down the cmake_install.cmake to just the python parts1 and running make install
    (this probs could have just been rsync -a Release/python ../../blender/lib/macos_arm64/python)

  5. doing cd ../../blender/lib/macos_arm64/ && git diff --name-status python | grep '^D' | awk '{print $2}' | xargs git checkout HEAD -- to restore packages I'd deleted but not rebuilt (with an rm -rf lib/macos_arm64/python before any of this; so ymmv)

  6. doing cd ../../ (back to the blender repo) && make && rm -rf /Application/Blender.app && mv ../build_darwin/bin/Blender.app /Applications/Blender.app

    all of which is probably just to make there be resolvable-on-disk values in /Applications/Blender.app/Contents/Resources/4.3/python/lib/python3.11/config-3.11-darwin/{Makefile,python-config.py}

    (and might actually have been in practice mostly to resolve the silent presumably accidental inclusion of a dep from this python on homebrew libb2 (v0.98.1) for computing blake2 ciphers)


  7. Still also doing cp -r lib/macos_arm64/python/include/* /Applications/Blender.app/Contents/Resources/4.3/python/include

  8. following directions but doing /Applications/Blender.app/Contents/Resources/4.3/python/bin/python3.11 setup.py build_ext --inplace

    • after cp ~/Downloads/SDK_Mac_2024-*/*.framework . and
    • before doing
    install_name_tool -change @rpath/SketchUpAPI.framework/Versions/A/SketchUpAPI \
    @loader_path/SketchUpAPI.framework/Versions/Current/SketchUpAPI \
    sketchup.cpython-*.so && \
    mv sketchup.cpython-*.so sketchup_importer/sketchup.so && \
    mv *.framework sketchup_importer
  9. installing manually as

    mkdir -p ~/Library/Application\ Support/Blender/4.3/scripts/addons && \
    cp -r sketchup_importer ~/Library/Application\ Support/Blender/4.3/scripts/addons/

  10. Opening Blender.app and doing (Edit > Preferences; Add-ons tab) [v] -> "Refresh Local", and checking the box for "SketchUp Importer"

I was succesfully able to import an skp from 3D Warehouse into Blender 4.3 Alpha (blender/blender@983b0b618267)

Footnotes

  1. (20 of the 100-some blocks in which they irritatingly aren't actually using the concept of CMAKE_INSTALL_COMPONENT at all; also several in which they ostensibly are fixing rpaths of .so's in the site-packages dir)

@donaldguy
Copy link

did open a blender issue https://projects.blender.org/blender/blender/issues/123764

but the concern is probably pretty niche

@BGagne02
Copy link

Hello, I cannot import my file. Can anyone help me?

image

@fuzenco
Copy link

fuzenco commented Jul 13, 2024

Unfortunately, I can’t enable the plugin in Blender 4.1.1 on macOS 14.5. Imports fine, with no errors. But the checkbox isn’t able to be toggled to the On state. Bummer.

@BGagne02
Copy link

BGagne02 commented Jul 14, 2024 via email

@Treata11
Copy link

Treata11 commented Aug 7, 2024

I wonder why this hasn't been merged yet?

@1080ptrooper
Copy link

I dont have any knowledge in python or coding but can anyone give instructions as to how i can build it to get it working for blender 4.2 on macos ventura?

@Treata11
Copy link

Treata11 commented Dec 6, 2024

Isn't this going to be merged?
@martijnberger

@videopilot
Copy link

Hi @tonfdd
Would you be able to provide a bit more context. At which step does it fail?

  1. install

I seem to have built this, and upon trying to install, it was looking for the API folders in Blender.app/Contents/resources/lib. I move them there for now, and then ended up with...

image

No idea where to go from there. Any chance an installable zip could be uploaded for testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.