Python - Including external libraries in version control - python

We are a small team trying to work on a python project using eclipse + pydev.
For our version control we use cloudforge SVN and the subclipse plugin.
I am trying to figure out what is the right way to include external libs which are normally installed
locally to the python in Lib/site-packages.
I tried several ways but some of them made some complications.
I am looking for the best-practice method for this matter.
Thanks in advance!

Use svn:externals. Example:
svn propset svn:externals 'akismet http://plugins.svn.wordpress.org/akismet/trunk'
svn commit
Your next update is going to incorporate the external source from http://plugins.svn.wordpress.org/akismet/trunk in the akismet directory. Hope that helps...

Related

Python programming with Eclipse+Pydev code assistant without sources

I'm using Eclipse+pydev plugin to develop python applications using a proprietary python framework. How can i set up a code assistant in this IDE without having framework sources available? Is there any open source tool so generate a documentation stub from sources files and then make it readable by pydev plugin without the need of having these sorces in my project? Do you have any ideas?
Thank you,
Alessandro
Well, if you're developing against it, you should have at least the .pyc/.pyd files, so, just make sure that you add the proper folder containing those to the PYTHONPATH and add the needed entries to the forced builtins (http://www.pydev.org/manual_101_interpreter.html has instructions).
If that's not enough (i.e.: PyDev can't discover the needed info by introspection from a live interpreter), you can create a file to provide "Predefined Completions" to it (again, http://www.pydev.org/manual_101_interpreter.html has instructions for that).

How do I download a 3rd party python module and integrate it with my python

I would like to be able to use the services that the Blockcypher module provides for my programme, however i have (at least i think) downloaded the correct module package but cant get it to integrate with my Python on my Computer. I am fairly new to python so I have no idea on where to even start tackling this problem.
Modules, regardless of where you've got hold of them, will be searched for in the sys.path. If nothing is found there, they will be looked up in the current directory.
When you download some code directly it will be a good first guess to place it in the directory of the script from where you are using the download. If it's just a .py-file, place it there. If it's an archive with a directory, then place the directory there (not the files).
Generally, you should prefer installing modules via a package manager such as pip or conda. Such package managers take care of placing modules properly for usage with your Python installation from wherever you will write your script. They also provide support for updating these modules to newer versions later.
Update: If you cannot make anything from this remarks, you should first read the section on modules in the Python tutorial, or even work thru the full tutorial or thru a good book (or any other ;) to get a smooth entry into the friendly world of Python programming.
Update (2023): The Dive Into Python link above is outdated, so here is the updated link to this great resource:
https://diveintopython3.problemsolving.io
I think it's still the best beginner's resource, but, well, here are many more:
https://wiki.python.org/moin/IntroductoryBooks

best version control system for personal/home use when developing with eclipse and python/django

I am working on a small django project at home. I would like to install and use a small version control system for personal use for free. I don't want to use a web service like github because I am not always connected. I would like to have the VCS server/daemon installed and use it at my home pc (windows 7).
I would also like it to be compatible with eclipse+pydev which I use for programming.
Any help would be greatly appreciated!
Thanks,
Chris
GIT is built in a way that you can use it 'offline': doing commit, reverting change, browsing history.
I don't see any advantage in your case to use SVN instead of GIT (you can host your own GIT server, no need to use github.com)
http://book.git-scm.com/4_setting_up_a_public_repository.html
There are also GIT alternatives for distributed SCM:
Mercurial
Bazaar
BTW, for my personal prototype DropBox is sufficient ;)
I suggest using mercurial with a Bitbucket private repository. Mercurial will work just fine when you're offline, and you can push your changes to Bitbucket to access your code elsewhere (your laptop, server, etc.) later.
There's also mercurial plugins for eclipse. (see Mercurial Eclipse Plugin)
I would recommend to use Mercurial together with DropBox in order to make sure that you don't lose everything in case of crash.
See http://www.h4ck3r.net/2010/05/11/mercurial-hg-with-dropbox/
I hope it helps
For personal version control, I would recomend the following:
FileHamster
Oops! Backup
FolderTrack
Note: I am an author of FolderTrack. I recomend it for use with programming because it will treat a group of source files as one "work product". If you want to rewind your code to yesterday and that requires deleting 2 files, renameing 1 file, and chaning 15 more then foldertrack will do it.
The free license for Foldertrack is: BOS
SVN has Eclipse plugins (Subclipse, Subversive), I don't know for pydev though. But it is one of the most used version control system and it is free.
If it is for personal use, thus you probably don't have to go with distributed vcs, I would definitely go with subversion (svn). It has nice plugin for eclipse: subversive. I'm using it for years.
http://subversion.apache.org/
for eclipse:
http://www.polarion.com/products/svn/subversive.php

Installing a Python program on Linux

I wrote a Python program. I would like to add to it an installation script that will set up everything necessary - like desktop icon, entry in the menu, home directory file, etc.
I'm working on Linux (ubuntu). When a Python program is installed, what needs to happen in general? I know that it probably depends on the nature of the program.
Can you give me some general ideas? Or, point me in the right direction? I have no idea how to look for this on Google.
Thanks
If it's a Python program you're trying to package, you should consider using its 'standard' distribution framework distutils. I can't replicate the entire document here but I'd recommend that you read it. Once you're done with that, check out the Hitchhikers guide to packaging which contains details on distribute - the extensions to distutils that allow you to package and distribute more effectively.
You could create an rpm easily using checkinstall. Search for checkinstall in google and download it. It will allow you to create an rpm and set the options.
For Ubuntu if you want it to be easily distributable to other Ubuntu users it'll have to be packaged properly, which is no simple task. You might want to consult their Packaging Guide for more information.
Otherwise, generally speaking there are a few standard packaging options for Python. Setuptools is popular, but becoming reviled lately. Read James Bennett's blog post "On Packaging" for a decent in-depth look into the ups and downs of the Python packaging world.
How a program is launched and placed in the menu is determined by a .desktop file (you can read the specification or just look at some examples from /usr/share/applications). Properly installing a program (placing all files in the right directories and so on) requires either making a package like a deb or rpm, or you could use something like distutils or setuptools.
It may also help to just look at some (open source) examples of Python programs for Linux.

Eclipse + local CVS + PyDev

I tried several Python IDEs (on Windows platform) but finally I found only Eclipse + PyDev meeting my needs. This set of tools is really comfortable and easy to use. I'm currently working on a quite bigger project. I'd like to have a possibility to use CVS or any other version control system which would be installed on my local harddrive (I recently moved my house and don't have yet an access to internet.)
It doesn't matter for me if it'd be CVS - can also be any other version control system. It'd be great if it will be not too hard to configure with Eclipse. Can anyone give me some possible solution? Any hints?
Regards and thanks in advance for any clues. Please forgive my English ;)
Last time I tried this, Eclipse did not support direct access to local repositories in the same way that command line cvs does because command line cvs has both client and server functionality whereas Eclipse only has client functionality and needs to go through (e.g.) pserver, so you would probably need to have a cvs server running.
Turns out that I didn't really need it anyway as Eclipse keeps its own history of all changes so I only needed to do an occasional manual update to cvs at major milestones.
[Eventually I decided not to use cvs at all with Eclipse under Linux as it got confused by symlinks and started deleting my include files when it "synchronised" with the repository.]
If you don't mind a switch to Subversion, Eclipse has its SubClipse plugin.
As others have indicated, there are plugins available for Eclipse for SVN, Bazar, Mercurial and Git.
Even so, despite their presence, I find using the command line the most comfortable.
svn commit -m 'now committing'
Assuming you are not committing for more than several times a day, this should work well enough. Is there anything specific that is preventing you from using the command line?
I tried Eclipse+Subclipse and Eclipse+Bazaar plugin. Both work very well, but I have found that Tortoise versions of those version source control tools are so good that I resigned from Eclipse plugins. On Windows Tortoise XXX are my choice. They integrate with shell (Explorer or TotalCommander), changes icon overlay if file is changed, shows log, compare revisions etc. etc.
I would definitely recommend switching over to a different VCS—I prefer Mercurial, along with a lot of the Python community. That way, you'll be able to work locally, but still have the ability to publish your changes to the world later.
You can install TortoiseHg for Windows Explorer, and the MercurialEclipse plugin for Eclipse.
There's even a Mercurial for CVS users document to help you change over, and a list of mostly-equivalent commands.
I believe Eclipse does have CVS support built in - or at least it did have when I last used it a couple of years ago.
For further information on how to use CVS with Eclipse see the Eclipse CVS FAQ
I recently moved my house and don't have yet an access to internet.
CVS and SVN are the Centralized Version control systems. Rather than having to install them on your local system just for single version control, you could use DVCS like Mercurial or Git.
When you clone a Mercurial Repository, you have literally all versions of all the repo files available locally.
I use Eclipse with a local CVS repository without issue. The only catch is that you cannot use the ":local:" CVS protocol. Since you're on Windows, I recommend installing TortoiseCVS and then configuring the included CVSNT server as follows:
Control Panel: CVSNT
Repository configuration: create a repository and publish it
Note the Server Name and make sure it matches your hostname
Eclipse: Create a new repository location using the :pserver: connection type and point it to your local hostname
This (or any actual source control system) has the advantage over the Eclipse Local History of being able to associate checkin comments with changes, group changes into change sets, etc. You can use the Eclipse Local History to recover from minor mistakes, but it's no replacement for source control (and expires as well: see Window->Preferences General->Workspace->Local History).

Categories