Sketchup_Importer icon indicating copy to clipboard operation
Sketchup_Importer copied to clipboard

Macos

Open tobiasjewson opened this issue 1 year ago • 25 comments

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.

tobiasjewson avatar Feb 04 '24 19:02 tobiasjewson

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.

tobiasjewson avatar Feb 18 '24 10:02 tobiasjewson

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?

tonfdd avatar Feb 19 '24 00:02 tonfdd

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

notoriusawh avatar Feb 19 '24 08:02 notoriusawh

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)

darishante avatar Feb 19 '24 11:02 darishante

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

tobiasjewson avatar Feb 25 '24 09:02 tobiasjewson

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

balarayen avatar Mar 01 '24 06:03 balarayen

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

tobiasjewson avatar Mar 03 '24 11:03 tobiasjewson

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

balarayen avatar Mar 03 '24 12:03 balarayen

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!

darishante avatar Mar 08 '24 12:03 darishante

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

odil24 avatar Mar 12 '24 23:03 odil24

@balarayen +1 for the Mac version please.

KevJames avatar Apr 02 '24 20:04 KevJames

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

balarayen avatar Apr 04 '24 11:04 balarayen

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

Ghezwo avatar Apr 07 '24 08:04 Ghezwo

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 avatar Jun 25 '24 21:06 donaldguy

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 avatar Jun 25 '24 22:06 donaldguy

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@840457c45c86b1d6b497dee96314b01d0672aeee

(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 avatar Jun 25 '24 22:06 donaldguy

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 avatar Jun 25 '24 23:06 donaldguy

there is logic in the build system to avoid this:

https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/cmake/harvest.cmake

https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/darwin/set_rpath.py

but something isn't working right

EDIT: There is also some logic perhaps specifically about sanitizing the python install but its guarded to Windows only (and works with .dlls): https://projects.blender.org/blender/blender/src/commit/983b0b61826794b1c372b4bc13e8754df379bc9b/build_files/build_environment/cmake/package_python.cmake

donaldguy avatar Jun 25 '24 23:06 donaldguy

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 parts[^1] 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)

[^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 avatar Jun 26 '24 02:06 donaldguy

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

but the concern is probably pretty niche

donaldguy avatar Jun 26 '24 03:06 donaldguy

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

image

BGagne02 avatar Jun 30 '24 14:06 BGagne02

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.

fuzenco avatar Jul 13 '24 20:07 fuzenco

I use pc on windows10

Le sam. 13 juill. 2024 à 16:05, Fuzen Co. @.***> a écrit :

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.

— Reply to this email directly, view it on GitHub https://github.com/RedHaloStudio/Sketchup_Importer/pull/2#issuecomment-2227090616, or unsubscribe https://github.com/notifications/unsubscribe-auth/BJRP3EJ2XVIHWKPYHPIQIFTZMGB7DAVCNFSM6AAAAABCZCYUNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRXGA4TANRRGY . You are receiving this because you commented.Message ID: @.***>

BGagne02 avatar Jul 14 '24 14:07 BGagne02

I wonder why this hasn't been merged yet?

Treata11 avatar Aug 07 '24 07:08 Treata11

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?

1080ptrooper avatar Aug 07 '24 18:08 1080ptrooper