samirelanduk / atomium

Python macromolecular parsing (with .pdb/.cif/.mmtf parsing and production)
https://atomium.bio
MIT License
102 stars 19 forks source link

Standalone version of atomium #41

Open BradyAJohnston opened 2 years ago

BradyAJohnston commented 2 years ago

I am having some trouble with people installing atomium from pip (It seems to be a Blender related issue) so I was hoping to try and bundle a version of atomium inside of the addon itself.

I know atomium requires a couple of other packages etc for fetching - would you have advice on how to go about doing this? Do you have the ability to build a standalone version of atomium that I could include, rather than having to install using pip? I'm still early on my python journey (die-hard R fan) so package management inside of python is still new territory for me.

samirelanduk commented 2 years ago

I have thought about Dockerising atomium, which would bundle it with all its dependencies, though probably wouldn't solve your problem. I don't use Windows much these days, but I do remember some of the libraries like Numpy and Scipy don't always install too well on there.

I read through the issue linked - I actually haven't tried atomium on Python 3.10 yet. Is it just atomium that seems to have problems installing in the right place? Are there other libraries that install fine?

BradyAJohnston commented 2 years ago

The strange part seemed to be that it was an error across windows mac and linux, but only for some portion of people? I myself couldn't replicate the error.

It seems like the error has now been solved by adding the following code before I try to call import atomium:

import sys
import os
import site

def verify_user_sitepackages():
    usersitepackagespath = site.getusersitepackages()

    if os.path.exists(usersitepackagespath) and usersitepackagespath not in sys.path:
        sys.path.append(usersitepackagespath)

verify_user_sitepackages()

import atomium

Which makes Blender's python aware of the user's local packages. Still unsure why pip was installing there instead of inside of Blender (and only for some users, and even when people were running with admin privileges), but at least this has solved the issue in the meantime.

I would still be interested in a self-contained atomium though. Reducing the number of steps required for installation of the addon, and reducing future potential problems with pip would be ideal.