mcfrith / tandem-genotypes

GNU General Public License v3.0
45 stars 7 forks source link

Request: Installation from PyPI/Conda #1

Closed wdecoster closed 6 years ago

wdecoster commented 6 years ago

Hi,

I'd love to test your tool in the near future, but it could be convenient if it was available from PyPI and/or (bio)conda. Would that be possible?

(I'd be happy to help with either of these - let me know)

Cheers, Wouter

mcfrith commented 6 years ago

Hi Wouter

many thanks for your interest. I don't have experience with PyPI or conda, hope you don't mind a few questions...

I feel it's an implementation detail that the code is Python. Maybe I'll rewrite it in C++ (probably not, but it's conceivable). This makes me wonder if PyPI is a good idea.

I see that conda is for any language: sounds good. tandem-genotypes has minimal dependencies, and it should work with Python >= 2.6 or Python 3. Since I lack experience, I'd be glad for any advice about conda.

Have a nice day, Martin

wdecoster commented 6 years ago

Hi Martin,

PyPI is indeed exclusively for python code. Perhaps with the option of rewriting it's indeed not optimal.

For submitting a tool to conda you need to create a yaml recipe and a build.sh script. You can read more about setting up and contributing to bioconda here. For example, I'll add the directory of a package I have on conda: NanoPlot.

You'll need a 'stable' download link for your package, for which you'll have to make a release on GitHub. An alternative is to use the link from PyPI.

You'll need to add a setup.py to install python packages. Information and further reading about adding this can be found here. You can find the example from NanoPlot here. Note that you would have to change how building is done when you change the language, but that's not too much trouble. The build.sh script simply executes the setup.py in this case.

Note that at this point almost everything to add your package to PyPI has been done.

The meta.yaml lists name, version, URL and sha256 of the download (wget -O- $URL | sha256sum) and dependencies. I see you haven't specified a version yet which I guess is always a good idea. A commonly used versioning scheme is semantic versioning. The meta.yaml also requires you to specify a test which would tell the continuous integration tool if everything installed fine.

I see you have named your scripts without .py extension (tandem-genotypes), but that's not necessary for both PyPI and conda. The setup.py allows you set a console_script. In this case, the executable 'NanoPlot' is linked to the nanoplot module/directory, the NanoPlot.py script and then the main() function

entry_points={'console_scripts': ['NanoPlot=nanoplot.NanoPlot:main',]}

Similar for the conda meta.yaml:

build:
  entry_points:
    - NanoPlot=nanoplot.NanoPlot:main

This only requires you to change the code and add a main() function (or any other name) which executes your code and other functions

 if __name__ == "__main__":
    main()

It's a bit of work to get this running but definitely pays off in the long run. Let me know if you get stuck.

Cheers,
Wouter

mcfrith commented 6 years ago

Many thanks for the comprehensive explanations. Now it's just a matter of time for me to learn it all. It'll be good for me, though.

wdecoster commented 6 years ago

Let me know if you get stuck, or open an issue in the bioconda recipes repo. They're very supportive.

mcfrith commented 6 years ago

Took me a month, but it's in bioconda! Many thanks for suggesting this.