fgrunewald / Martini_PolyPly

Tool for generating MARTINI Polymer itps and structures
GNU General Public License v3.0
14 stars 3 forks source link

Make PolyPly installable with pip #13

Closed jbarnoud closed 6 years ago

jbarnoud commented 6 years ago

To do so I had to change a bit the organization of the repository. I moved the python module in the new "polyply" directory, but I let the metadata files (README, etc) at the top level of the repository for github to find them.

I moved polyply.py in the new "bin" directory. I renamed the script "polyply" instead of "polyply.py" as it was referred at under the former name in the README, and because it was causing conflicts with the module being called polyply.

Initially by mistake, but also for aesthetic reasons, I renamed the module polyply. Importing the module is therefore done with

import polyply

instead of

import Martini_PolyPly

With this commit, PolyPly can be installed using pip by calling

pip install <directory where setup.py is>

More easily, when in the Martini_PolyPly directory, the module can be installed with

pip install ./

The development version can be installed directly from github with

pip install git+https://github.com/fgrunewald/Martini_PolyPly.git#polyply

The polyply module then becomes available for import with

import polyply

The polyply script is made accessible in the research PATH, and can be called from anywhere.

The path to the distributed data was making wrong assumptions regarding the location of the polyply script relative to the data. This PR creates a polyply.DATA_PATH variable that should always point toward the right place. Update the variable is the data are moved.

Also, this PR replaces path concatenation (using + on strings) by os.path.join. The latter method makes it more robust to join path. It, for instance, avoids to make assumption on the presence or not of a / at the end of the path elements.

This PR adapts test.sh to called polyply with the installed version. It also remove the direct calls to "python3.5" in the same file.

Calling a specific version of python can make things break when the user uses a different version of python, or when using virtual/conda environment.

Also, calling "python polyply" will break as it circumvent the research PATH, and therefore does not know where to look for the script.

jbarnoud commented 6 years ago

Note: for development purpose, I recommend installing the package with the '-e' option of pip. Then, pip creates a link to the package instead of copying the files. It means that changes made to the code in the repository are directly accessible without having to reinstall.