Using a shared python library in Visual Studio

261 views Asked by At

We have a python library that needs to be shared among many projects and we're trying to find a way to organize and link the shared library to the specific projects that want to use it.

It also needs to work without visual studio, meaning that if the whole project is moved to some different machine, it will still work and use the "shared library", which means that the linked library needs to be placed statically in every project that use it (and of course each time it's updated, the library directory will be updated in each project)

Is there anyway it can be done?

The directory structure looks like this:

Project1
    main.py <--- (One of the projects that uses the library)
...
Libs
    PyLib <--- (This is the shared library)
       __init__.py
       ps_lib.py
       another.py
    CWinLib
    CNixLib

Some ways that I've tested are:

  • Working with linked files - The problem is that it doesn't copy the whole package to the project (which means that it doesn't work outside of visual studio)

  • Adding a search path - The same problem as before, doesn't work outside of visual studio

  • Using sys.path.append - It means that we'll need to copy the exact directory structure that's in place and that is something I want to avoid

Is there another way to solve this?

0

There are 0 answers