Part 1 of this series is available here</a></p>
To begin porting a C Python module to IronPython a few things are needed, I will explain how to get some of them and leave the rest up to the reader to research and download/install. I am assuming that you will be doing development on Windows, if you prefer Linux, there are equivalents available and I will note them below.</p>
If you are developing on Linux, I highly recommend either getting the latest Mono tarball, or building from source yourself. The latest Mono in the various Linux distributions’ repositories are not the latest and greatest release, and some of that latest and greatest stuff is nice to have when developing for IronPython.</p>
If you are not familiar with open source development on Github, here’s a quick and dirty tutorial which should get you going.</p>
Github is called a social development platform. The idea is to get developers communicating back and forth and provide ways for communities to work together. That being said, the major benefit of Github for open source projects is that is makes contributing very nice and much less painful than other methods. The general way to contribute to a project is to fork it. To fork a project on Github means that you create your own working area for the project, with it’s own source control history of your changes, and changes that you incorporate from other people into your branch of the source.</p>
Obviously, working on Github requires an account, so if you don’t already have one, you’ll need to sign up for an account, then you can fork to your heart’s content. I would also like to mention that strictly speaking, you do not have to setup a Github account, if you have access to your own git repository and server, you could theoretically send patches to the IronPython team that way, but it is MUCH more preferred to work using the Github method.</p>
When you browse to the IronPython project on Github (which is actually part of the IronLanguages project) at https://github.com/ironlanguages/main</a> you’ll see something like below (depending on if you are logged in or not).</p>
Github provides you several ways of getting the source for the project. </p>
These options are for if you want to get the source only and not really hack on it. If you want to hack on the source and contribute back new features or bug fixes, then you will want to fork the project1</a></sup>.</p>
</p>
The important button in this case is the “Fork” button which is near the top of the page. As shown above, you have to be logged in to be able to fork a project. Forking a project creates your own personal work area. You are automatically added to the “developers” list for the project and given push access to your fork of the project. Github will tell you there is hardcore forking action going on and then redirect you to the project page for your fork as shown below.</p>
You can see that the project in my case is now “slide / ironlanguages” not “IronLanguages / main.” When you fork IronPython specifically, you will actually end up with a project called “username / main” which in my mind was not very descriptive of what it actually was, but luckily Github lets you rename your fork. Click on the “Admin” button on the fork’s project page, you can change the name in the repository settings.</p>
I renamed mine to ironlanguages, so I knew exactly what it was (I contribute to some other open source projects on Github, so keeping them straight is important). </p>
Now that you have a fork, you are ready to get the sources and start hacking away. Browse to the directory on your computer where you would like to keep the source and use the Git client to clone the repository URL displayed on your fork2</a></sup>. </p>
If you are using TortoiseGit on Windows, browse to the root of where you want the source and right click to show the TortoiseGit context menu entries.</p>
Select “Git Clone…”</p>
Most of the necessary information will be filled in for you when you paste in the URL for the repository you want to clone, if not use the image above to help.</p>
You will notice that I am loading a Putty key, this helps with authorization and not having to enter a password for every operation with Github. I highly recommend you follow the how to on Github for setting up your keys3</a></sup>.</p>
When you press OK, a progress dialog will appear showing you the progress of the clone.</p>
This will take some time as there is quite a bit of code in the repository (including IronRuby, the DLR, Python files for the standard library, and more). If everything goes as planned, you will see something like the following:</p>
Now, you should have a local copy of the repo in the directory you specified.</p>
Interesting areas to look at in the code.</p>
Once you have the IronPython sources on your local system, take a look at the C Python source code.</p>
Interesting areas to look at.</p>
Next time, I’ll start pulling apart the C Python pyexpat module source code and create a skeleton IronPython module.</p>
References</p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
</a></p>
Setting up the environment – Part 2
.NET Framework 4.0 SDK (Windows) or Mono 2.10.x (Linux)</div>
This includes tools such as msbuild (xbuild for Mono), the C# compiler and other such tools. This is the bare minimum required for building IronPython from sources.</div></li></ul>
-
TortoiseGit (or any other Git client) for Windows or git (Linux)</div>
This will be used to get the latest sources from Github for IronPython.</div></li></ul>
-
Visual Studio 2010 (Windows recommended) or MonoDevelop 2.8 (Linux)</div>
You CAN build IronPython sources using only the .NET SDK, but having a good debugger makes life much easier.</div></li></ul>
-
Python 2.7.2 sources (http://www.python.org</a>)</div>
The Python sources are required so that you can look at internal implementations of C based modules to make sure your IronPython modules match the implementation.</div></li></ul></li></ul>
Click the “ZIP” link right above the “Files” tab of the UI. This will grab the head (latest) of the source code and allow you to download it as a zip file. If you want to peruse the source and see how things are done before jumping in head first, this can be a good way of doing that.</div>
-
Depending on your role in a project (developer, administrator, etc.) you will have the option of having a direct committable URL for the project. There are SSH and HTTP options available for developers and administrators that allow directly pushing changes to the main project. Most people do NOT have this access. </div>
-
The other option, for those who are not in the project developers group directly, but would still like to get the source with all the Git information is the “Git Read-Only” option. This allows you to git [sic] the source and pull updates, but does not allow you to commit anything to the project.</div></li></ol>