Creating a repo for your completed scripts

A place where you can post Python-related tutorials you made yourself, or links to tutorials made by others.

Creating a repo for your completed scripts

Postby metulburr » Tue Jul 30, 2013 1:42 am

If you dont know, there are sites that you can upload your code to where people can look, upload fixes, comment on, and download your code. It makes it easier for everyone. Using weird, unknown, or massive spammy/advertisement sites to house your code turns people off from downloading it altogether. However if your code is housed in a place like github, for example, people are more apt to look/download it.

There are 3 main sites that do pretty much the same thing, the choice is up to you which you prefer:
I cant say much for Google Code as i havent used it at all. BitBucket I know has free private repos if you dont want people to have access to it. And then there is Github, which is what i normally use.

Either way its a learning curve, but its worth it if you plan to upload a lot of code. You have to google questions, and how-to's. This will help teach some basics with git and github. The benefits however are awesome. You can upload your code for the ease of working with other programmers. Large amounts of people can work together. Others may make a comment on how to better your code, along with the code that they suggest. If you jump between numerous computers a lot, you can easily transfer project/files to and from any of them via your repos. Any change is saved in history, so if 6 months later you decide you want to use that one code you had, but you deleted that file, you can go back and still see the file contents and retrieve it.

Assuming you created an account at github, here is a quick tutorial on uploading your first repo. I still sometimes refer to a command sheet i wrote out as a helper, because i cant remember the series of commands if i dont upload in awhile.
1) first we need code to upload, which could be your code, or could be something as simple a text file with nothing in it.
Code: Select all
metulburr@ubuntu:~/repos/test$ touch test.txt
metulburr@ubuntu:~/repos/test$ ls
test.txt
metulburr@ubuntu:~/repos/test$

ok now we have a file called test.txt. It doesnt have anything on it, but that doesnt matter.
2) now we need to initialize git because this is a new directory that never had a .git in it before.
Code: Select all
metulburr@ubuntu:~/repos/test$ git init
Initialized empty Git repository in /home/metulburr/repos/test/.git/
metulburr@ubuntu:~/repos/test$

3) now we need to connect this directory with a git repo on github. Go onto the github.com, and click new repo, make a repo name (can be anything), now click create repo. It will list off a series of commands you need to make too. You will see a second url bar containing something like the address https://github.com/metulburr/test.git in it where my name of repo was "test", copy it to your clipboard. now go back to your terminal
3) in the terminal, input:
Code: Select all
git remote add origin https://github.com/metulburr/test.git

and replace url path with whatever yours is. Now this directory is connected to your git on the site.
4) now we add the files to upload
Code: Select all
metulburr@ubuntu:~/repos/test$ git add test.txt
metulburr@ubuntu:~/repos/test$

5) now we comment (which must be done)
Code: Select all
metulburr@ubuntu:~/repos/test$ git commit -m "first commit"
[master (root-commit) 5f2c638] first commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
metulburr@ubuntu:~/repos/test$

6) now we finally upload the file to the repo on the site:
Code: Select all
metulburr@ubuntu:~/repos/test$ git push origin master

Depending on how you set up git or created a .netrc file with authentication in it, etc. You may also at this point have to insert your username and password that is associated with your github account.
and there you should see the test.txt file in your new repo.

This was very cut and dry. There are a ton of things you can do, and i only named off the requirements to upload, there is more if you want to change the code you already put up, etc. etc.

For those that want to ease the method of converting to github, if your on windows, there is a GUI tool to help push/pull repos:
http://windows.github.com/

https://asciinema.org/a/8425
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1366
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Creating a repo for your completed scripts

Postby Mekire » Tue Jul 30, 2013 1:51 am

The only appeal of Google Code was, it gave you a nice clean binary download page that kept track of the number of downloads and didn't intimidate less tech-savvy users. This feature has now been deprecated/removed. Google does support git repos but the functionality is nothing compared to github or bitbucket. Now I personally like the interface of Github more than Bitbucket. The plus for Bitbucket however, is that it still has a downloads section that you can point users to, who might otherwise be intimidated by a git repo. Also, yes you can make private repos, though I wouldn't encourage this unless you are working on a commercial project.

-Mek
User avatar
Mekire
 
Posts: 986
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Creating a repo for your completed scripts

Postby metulburr » Tue Jul 30, 2013 1:59 am

i am not sure what you mean downloads section? If i was wanted someone to download our plants vs zombies game, that had no idea of what github was, i would give them the direct download link, https://github.com/metulburr/Plants-VS- ... master.zip, instead of the repo. I would assume if that person knew more than i thought they did, they would strip off url of the download link to its base to get to the repo.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1366
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Creating a repo for your completed scripts

Postby Mekire » Tue Jul 30, 2013 2:14 am

Technically you are not supposed to upload binaries to Github. So if I wanted to prepackage our program as an exe for non-python-using windows users, Github wouldn't appreciate it (though you could probably still add it to the repo). This is why you can't actually download individual files from a repo without cloning or downloading the whole thing. It isn't encouraged. With Google code and Bitbucket though, they have pages like these:
http://code.google.com/p/double-cross/downloads/list
https://bitbucket.org/Mekire/gltut-python-pygame-pyopengl/downloads
(however as I said Google Code no longer has this functionality for new projects)

Git repos of course are fine for coders targeting coders. It is when you are targeting people who perhaps don't have python (or have never heard of python), that you have issues. The average user is not going to install python, and then install pygame, and then install numpy, just to run a game.

-Mek
User avatar
Mekire
 
Posts: 986
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Creating a repo for your completed scripts

Postby Mekire » Fri May 09, 2014 2:53 pm

Found this interactive git tutorial. Pretty basic but I think it is a great way to get started with the (sometimes daunting) task of learning git.
https://try.github.io/

-Mek
User avatar
Mekire
 
Posts: 986
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests