peterspackman / chmpy

Spherical harmonic shape descriptors, promolecule densities, isosurfaces and Hirshfeld surfaces in python
Other
18 stars 2 forks source link

Regarding the installation #2

Closed qzhu2017 closed 2 years ago

qzhu2017 commented 2 years ago

@peterspackman It is a nice tool. I am in the middle of learning how to use it. However, I came into several issues as follows,

1, I firstly met the following complaints,

>>> from chmpy import Crystal, Molecule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/qiangzhu/Desktop/github/chmpy/chmpy/__init__.py", line 1, in <module>
    from .crystal import Crystal, SpaceGroup, UnitCell
  File "/Users/qiangzhu/Desktop/github/chmpy/chmpy/crystal/__init__.py", line 9, in <module>
    from .crystal import Crystal
  File "/Users/qiangzhu/Desktop/github/chmpy/chmpy/crystal/crystal.py", line 15, in <module>
    from trimesh import Trimesh
ModuleNotFoundError: No module named 'trimesh'

This can be trivially solved by pip install trimesh. However, I am curious if you have a mechanism to list all required package during the installation. This will make life easier.

2, I tried to get the Hirschfield surface.

>>> from chmpy import Crystal, Molecule
>>> c = Crystal.load("tests/test_files/acetic_acid.cif")
>>> surfaces = c.hirshfeld_surfaces()
>>> from chmpy.util.mesh import save_mesh
>>> save_mesh(surfaces[0], "acetic_acid.ply")

How can I visualize it?

image
robertwerner67 commented 2 years ago

Addressing the first point, I observe an installation with pip may install the application you are interested in including its dependencies with a register about other modules beyond the scope of Python standard library. It looks like the standard name for this ASCII file is requirements.txt.[1] I'm not sure if chempy as provided here (peterspackman/chmpy) is the same as other GitHub repositories e.g. chempy on PyPi (https://pypi.org/project/chempy/) or likeChempy on https://github.com/jan-rybizki/Chempy -- the later however includes such a list in tune of "when installing this, ensure the presence of numpy, matplotlib, etc."

[1] a reference: https://datagy.io/python-requirements-txt/

qzhu2017 commented 2 years ago

Yes, you can follow what I did with PyXtal (https://github.com/qzhu2017/PyXtal)

There we have the explicit setup.py and requirement.txt to specify the package dependence. You may also be interested in adding some GitHub workflow to run automated test.

peterspackman commented 2 years ago

You may have noticed I just started migrating the packaging/build to using poetry/pyproject.toml (as seems to be the current best practices way to do things). I am in the process of upgrading/updating the documentation, and will automate the package to be distributed in pypi while I'm at it.

I've you have the repository locally (and have poetry installed) you should be able to run poetry build in the source directory, which will build a wheel, and that can just be installed using pip install and that ought to install the required dependencies!

Apologies for that, just a work in progress. Up til now it's basically been just me using it, so I've been a bit lax on updating documentation/tidying up the install process.

I have no association with chempy, perhaps I should change/rename to avoid a name collision...

As for visualizing the surfaces, any program which can read .ply files should work e.g. blender, meshlab and many others. The reason the .ply format is recommended over others is that the support for most software reading vertex colors from those files seems to be better than for example wavefront .obj files, but trimesh can write many formats.

There already is a github workflow to automate the tests!

peterspackman commented 2 years ago

Packages are now uploaded to PyPI, going to close this issue as I think it's been sorted out!