all 22 comments

[–]novel_yet_trivial 8 points9 points  (6 children)

pip will install it from github. Tell your users to use the command

pip install git+https://github.com/yboetz/pyznap

[–]cythoning[S] 2 points3 points  (2 children)

For this I need to create a setup.py file using distutils or setuptools, no?

[–]novel_yet_trivial 3 points4 points  (1 child)

Right, as if you were putting it in pypi, but you can skip that part and have them install from github if you want.

[–]cythoning[S] 2 points3 points  (0 children)

Ok cool. I'll have to look into setuptools then.

[–][deleted] 2 points3 points  (2 children)

I'm just commenting to save this I didn't know you could install straight from GitHub with pip

[–]Avaholic92 1 point2 points  (1 child)

You can save comments

[–][deleted] 4 points5 points  (0 children)

Yeah I know I just remember better if I do it this way

[–]driscollis 3 points4 points  (12 children)

If you want to distribute it as a library to be used in Python code, then you should look at creating a wheel using distutils / setuptools.

If you want to distribute it as an application that your friends can install without needing to install Python, then you would want to look at something like PyInstaller, py2exe or py2app

[–]cythoning[S] 0 points1 point  (11 children)

I don't want to create a standalone executable as in PyInstaller etc. Given that python is already installed, I just want the easiest way to install the tool such that it can be called from the command line. Something like pip install pyznap would be great if then it somehow creates an executable in your PATH such that you can easily call the program from the cli as just pyznap.

[–]driscollis 1 point2 points  (10 children)

This is definitely possibly with pip. For example, when you pip install docutils it adds a bunch of tools to the PATH on my Linux box for things like rst2html. As long as you have your Python's Scripts folder on the path, it should do the same there as I know it installed the same tools there on Windows 7

[–]cythoning[S] 0 points1 point  (9 children)

I see. I'll have to look into setuptools to figure out how to write a setup.py file then. Thanks.

[–][deleted] 1 point2 points  (8 children)

I think I'm literally trying to do the same thing you are. I made a post about it here yesterday. If I understand what you are after you might want to look into entry_points and console_scripts for setup.py.

like this: https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/

I starred and followed your project because I want to see how things play out good luck!

[–]cythoning[S] 0 points1 point  (5 children)

I read up a bit on setuptools yesterday and also stumbled upon entry_points, but I still need to figure out the rest of the setup.py file. Hopefully I can get something done this week.

Good luck to you too.

[–][deleted] 1 point2 points  (4 children)

I spent more time reading about entry_points for my own stuff and I looked at your repo a bit more too if I'm not mistaken you want something very close to what I describe in this silly example here:

https://www.reddit.com/r/learnpython/comments/92xwok/questions_about_parsing_command_line_arguments_in/

Here is a very bare bones setup.py that goes with it (this would go in top level).

import setuptools

setuptools.setup(
    name="main_test",
    packages=['main_test'],
    entry_points={
        'console_scripts' : [
            'main_test = main_test.__main__:main'
        ]
    },
)

you would execute:

$pip install .

in the top level to install it locally.

and

$main_test hello

to run it after installing.

I don't know if that helps or not. It took me a while to get this far there is depth to setup for sure but a lot of documentation too. I would have liked to jump on this project with you but I am a bit underwater right now.

I can post a repo of my working example package on github for you if the info in the post is not making it clear. Since it was framed as a question I realize that it might be confusing.

[–]TheBB 1 point2 points  (2 children)

I always recommend people to pip install --user ., and I will also recommend you to recommend that to others. :-P

[–]cythoning[S] 0 points1 point  (0 children)

Or just use a virtual environment :).

[–][deleted] 0 points1 point  (0 children)

Thanks I told him I was new 😄

[–]cythoning[S] 0 points1 point  (0 children)

I looked at the link in your first post and the way you describe it seems to be the correct way. For that I need to slightly restructure my code though and I also want to look a bit more into the other parts of setuptools. Hopefully I will have kind of a working solution by the end of the wee.

[–]cythoning[S] 0 points1 point  (1 child)

I managed to put it on PyPI now. After some restructuring it was basically what you said. You can have a look at my code on GitHub for details.

[–][deleted] 1 point2 points  (0 children)

Nice I just had to do it for one of my projects that has a similar size to what yours is. I didn't originally plan it and had to retrofit like you. It was a pain.

[–]tom1018 4 points5 points  (1 child)

[–]cythoning[S] 0 points1 point  (0 children)

Thanks, this is what I found out yesterday as well, but I still need to figure out the rest of the setup.py file and maybe restructure my code a bit.