JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
580 stars 75 forks source link

Fix #168: avoid creating duplicate link for addon #172

Closed Mateusz-Grzelinski closed 3 months ago

Mateusz-Grzelinski commented 4 months ago

In this PR:

Squash merge when ready. Please squash merge after https://github.com/JacquesLucke/blender_vscode/pull/174 - it fixes one more issue with 2.80 compability

About tests:

I could not figure out how to run tests with VS code UI. Works fine with pycharm UI when you mark include directory as source directory.

todo:

Corner cases (for documentation):

Mateusz-Grzelinski commented 3 months ago

The change should be working now. I tried adding some basic tests, but I did something wrong, because

Note: I have basic experience with tests.

pip install pytest
cd pythonFile
$env:PYTHONPATH="./include" # powershell
pytest -s .\tests\blender_vscode\test_load_addons.py::TestIsInAnyAddonDirectory::test_is_in_any_addon_directory # ok
pytest -s .\tests  # 1 ok 5 fail
Mateusz-Grzelinski commented 3 months ago

I think I fixed the tests, but i need to sleep on it.

Those tests are just prototypes that helped me find 2 more errors in my code. I am not sure if this is the right way to test (very complicated test for little code)

The tests are prepared to run outside of blender, and without fake-bpy-module

Mateusz-Grzelinski commented 3 months ago

Ehh, enother long evening.

Mateusz-Grzelinski commented 3 months ago

I am pretty sure this patch works as expected. Final test was done by adding addon and extension to both

as seen on screeshot, all looks ok. image

The policy violation was fixed in https://github.com/JacquesLucke/blender_vscode/pull/172/commits/445778f950fcc2e33bd62310e98a31d9c8bdc539

I verified that tests work even if fake-bpy-module is installed.

Mateusz-Grzelinski commented 3 months ago

ugh, breaks older blender. Totally forgot about that. I need to fight the persmission denied error when pip installing and check with blender 2.8 - i think this is the oldest one we support.

Hey, but I am developing this PR on windows, tests should work... Oh, I named the path in Linux style. It does not matter, it works on windows

Mateusz-Grzelinski commented 3 months ago

fixed compability with bledner 2.80. Please squash merge after #174 - it fixes one more issue with 2.80 compability

Mateusz-Grzelinski commented 3 months ago

updated to newest master, ready to merge as 174 was completed.

Mateusz-Grzelinski commented 3 months ago

Covered one more edge case

  1. You are developing extension in addons directory
  2. extension has legacy bl_info defined (supportes both legacy and new addon systems)
  3. then do not create a link (it will be duplicate)

Agr, last changes from other PRs broke the tests...

Mateusz-Grzelinski commented 3 months ago

the tests are fixed. but I just thought about yet another corner case:

Mateusz-Grzelinski commented 3 months ago

there are problems with python 3.7 and dealing with junctions in windows. They are not recognized correctly and give different errors than python 3.12

Mateusz-Grzelinski commented 3 months ago

This became very involving change, hopefully this is last iteration and I will merge it on the weekend. Before release Linux needs some testing.

Mateusz-Grzelinski commented 3 months ago

tested on ubuntu 22.04 snap installed blender 4.2. Works fine. Merging.