SOLVED: Building on Windows

Specific support for Deluge on Microsoft Windows OS
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

SOLVED: Building on Windows

Post by Tidosho »

I've just found out about Deluge, and am blown away by it. I've already seen a few changes I could help with implementing. The issue is, Windows is my main platform, and how do I go about compiling it for Win? Using the instructions on the Support page only seems geared towards Linux, following them creates an EGG file which is useless.

Is there full Windows port source code available, with installer source? It doesn't feel truly open source without it, to me it feels Linux favoured. The compilation guidelines for Windows seem to stop past the dependencies.

Older Python torrent clients like ABC are past projects I've helped with. LH-ABC was a cross platform port of it, even this had full windows build and installer code. If someone could clear this up for me I'd gladly become a donating assistant developer, because I'm pretty ace at GUI design ;)
Last edited by Tidosho on Tue Jun 26, 2012 1:08 pm, edited 1 time in total.
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

Re: Building on Windows

Post by Tidosho »

Ah, whoops! Ignore the above, I just found another zip archive with the Win32 folder in it from Git, which has the installer ;)
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Building on Windows

Post by Cas »

The win32 folder in source is solely packaging instructions for creating the installer. It is different from your initial question on how to compile/install Deluge from source which is identical for both linux and windows.
Tidosho wrote: following them creates an EGG file which is useless.
If you look in 'C:\Python26\Scripts' you will find all the deluge exe files.
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

Re: Building on Windows

Post by Tidosho »

Cas wrote:If you look in 'C:\Python26\Scripts' you will find all the deluge exe files.
I noticed that as I built it, but why does it put it in the Python directory rather than a dist directory in the source folder? It's all really confusing. Personally I find this project really messily put together. After running the build, and then following the readme in the Win32 folder, it says:

Code: Select all

C:\deluge-1.3.5\win32>python deluge-bbfreeze.py
Traceback (most recent call last):
  File "deluge-bbfreeze.py", line 18, in <module>
    from bbfreeze import Freezer
  File "C:\Python26\lib\site-packages\bbfreeze\__init__.py", line 8, in <module>
    from bbfreeze.freezer import Freezer
  File "C:\Python26\lib\site-packages\bbfreeze\freezer.py", line 13, in <module>
    from modulegraph import modulegraph
  File "C:\Python26\lib\site-packages\bbfreeze\modulegraph\modulegraph.py", line 9, in <module>
require("altgraph")
  File "C:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg\pkg_resources.
py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "C:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg\pkg_resources.
py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: altgraph
The Win32README file tells you to run "build-bbfreeze.py", but it is named "deluge-bbfreeze.py". The build instructions need to be clearer about what version of components are needed and the exact steps. The part at the end where it says:

Code: Select all

The following packages do not have Windows installers but are straightforward to install.

     PyXDG
     Zope Interface
     Mako
     Chardet 
doesn't cut it in my eyes, as they are EGG files, I didn't know what to do with them until I googled and found out about "easy_install.exe", so they are not "straightforward".

I've dealt with cross platform torrent programs like LH-ABC, these use py2exe and WxPython, so why does Deluge have to be so bloated and confusing? If someone can give a proper explanation of the Win32README.txt file I'd appreciate it. I understood everything up to that point!
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Building on Windows

Post by Cas »

Tidosho wrote:doesn't cut it in my eyes, as they are EGG files, I didn't know what to do with them until I googled and found out about "easy_install.exe", so they are not "straightforward".
The last two lines in the instructions explicitly tell you how to install them:
After Python and Setuptools are installed, open a console and run:

C:\Python26\Scripts\easy_install.exe zope.interface chardet mako pyxdg
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

Re: Building on Windows

Post by Tidosho »

Thanks for that Calum. Now I just need to figure out why it fails on the Win32 part. In the Win32 README it has the following:

Code: Select all

The modification is to add these lines to:
    
        C:\Python26\Lib\site-packages\bbfreeze-0.96.5-py2.6-win32.egg\bbfreeze\recipes.py
The structure I have is \Python26\Lib\site-packages\bbfreeze-1.0.0-py2.6.egg-info (instead of bbfreeze-0.96.5-py2.6-win32.egg) and \Python26\Lib\site-packages\bbfreeze, not a bbfreeze folder inside the bbfreeze-1.0.0-py2.6.egg-info folder as the readme suggests I should.

Then it suggests to run (deluge source folder)/win32/build-bbfreeze.py when the only file there is deluge-bbfreeze.py.

The whole Readme doesn't make sense, it asks you to add lines but doesn't say WHAT to put. Can you take a look?
Cas
Top Bloke
Top Bloke
Posts: 3679
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Building on Windows

Post by Cas »

As I said before the win32 readme is for packaging Deluge. That means it is only really used by us when creating a Deluge release and rarely used by users or devs. There may be a few minor errors in it however only a bit of lateral thinking is required to overcome them.
Tidosho wrote:Then it suggests to run (deluge source folder)/win32/build-bbfreeze.py when the only file there is deluge-bbfreeze.py.
If it says build-bbfreeze.py but deluge-bbfreeze.py is in source tree then clearly use that instead.
Tidosho wrote:and \Python26\Lib\site-packages\bbfreeze,
If there is a bbfreeze\recipes.py file then that is what needs to be edited, the location may have changed in newer version but its still the same file.
Tidosho wrote: it asks you to add lines but doesn't say WHAT to put.
It does:
Right at the top of the Python function 'recipe_gtk_and_friends':
return True

Code: Select all

pkg_resources.DistributionNotFound: altgraph
The bbfreeze script error suggests that you do not have altgraph installed.
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

Re: Building on Windows

Post by Tidosho »

Cas wrote:As I said before the win32 readme is for packaging Deluge. That means it is only really used by us when creating a Deluge release and rarely used by users or devs.
Thanks Cas. I always like to build an application I've modified complete with installer so I can test the full release as an end user would see it, from install to uninstall. I've always done it, an app isn't completely tested otherwise in my book.

I'll have another play about with it tomorrow and see if I can figure it out, but Deluge is absolutely fantastic. You and the other devs have done a smashing job, and I'd like Deluge to be a uTorrent killer because the commercialised bloat UT is becoming since Bittorrent Inc took it over is terrible. Deluge wipes the floor with it on magnet link establishment and start times, uTorrent takes ages to get going fully!
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

Re: Building on Windows

Post by Tidosho »

I've figured it all out Cas, so I'll do a HOWTO in this section, I feel it'll be useful to other outside devs like me, because the current SVN Win32README is all completely messed up, outdated and incorrect. I've managed to get it to build and create an installer ;)
Tidosho
New User
New User
Posts: 8
Joined: Mon Jun 25, 2012 1:39 pm

HOWTO: Complete Windows Compilation Tutorial

Post by Tidosho »

Contrary to Tidosho's comments there is nothing wrong with our instructions, I recommend users follow our official wiki/git instructions and only use this for reference if they encounter issues. - Cas

It isn't very well documented on this site how to actually build Deluge for Windows properly, as it's mixed in with all the Linux instructions. Here's my guide on compiling it and then getting the installer to build.

1. First, follow the instructions on the Installing/Source page, starting from the Windows Dependencies section, installing all the first set of dependencies from the links.

2. Where the page says:

Code: Select all

The following packages do not have Windows installers but are straightforward to install.

     PyXDG
     Zope Interface
     Mako
     Chardet 
DO NOT download anything from those links, we'll sort that out next. The page is written in a way that confuses you into clicking the links and downloading/installing manually. DON'T, instead, continue on.

3. After you've installed all the first set of dependencies, open a command console (Start, Run, type cmd, hit Enter) and type:

Code: Select all

C:\Python26\Scripts\easy_install.exe zope.interface chardet mako pyxdg
This will download and install that second set of dependencies automatically. Continue on to my next step!

4. Download the ZIP version of the source code, and extract it into the root of C:\ so you will have a folder structure like C:\deluge-1.3.5, inside which is the source code. If you have a double deluge-1.3.5 structure, cut and paste the source files into the root deluge-1.3.5 folder and delete the duplicate. Make sure your folder has a Win32 folder in it, the tar.gz versions of the source don't seem to.

5. Next we need to add Python to your PATH. Right click My Computer, click Properties, Advanced System Settings, then the Environment Variables button. This is for Windows 7, XP might be a little different, I haven't used it in a while. Next, in the System Variables section at the bottom find the Path part, click it and hit Edit. Add "C:\Python26;" to the beginning (without quotes), and close all windows by OK'ing and Applying them.

Install the GTK+ Windows runtime by googling for it. The latest version will do, but make sure that during the install YOU MUST select the option to include GTK in your PATH, the installer will do this for you, unlike Python. Next, install NSIS Installer from [url]http:\\nsis.sourceforge.net[/url].

6. Once the GTK is installed, the first step you should do is make sure you have a clean build environment. Open your command prompt again, and type:

Code: Select all

C:\deluge-1.3.5\python setup.py clean -a
7. Now to actually do the build:

Code: Select all

C:\deluge-1.3.5\python setup.py build
If you get any build errors saying modules weren't found, you can use the easy_install command like we did previously, for example I had "pefile" and "altgraph" modules missing, so I typed:

Code: Select all

C:\Python26\Scripts\easy_install.exe pefile altgraph
Repeat for any other modules as needed. While we're here type in

Code: Select all

C:\Python26\Scripts\easy_install.exe bbfreeze
as we'll need it later.

Next, you'll want to install the program, as just running build creates an EGG file, which is a Python Package. On Windows omit the "sudo" part of the install code as that's for linux, so you'd type:

Code: Select all

python C:\deluge-1.3.5\setup.py install
This will put the files in C:\Python26\Scripts. The installer will put it all together so don't worry, carry on.

8. That is the point you should STOP FOLLOWING the instruction page, the rest is for Linux. Now we need to concentrate on building the installer.

9. Go into the Win32 folder and open the deluge-win32-installer.nsi file into a text editor. Replace line 44:

Code: Select all

!define DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR "..\build-win32\deluge-bbfreeze-${PROGRAM_VERSION}"
with this:

Code: Select all

!define DELUGE_PYTHON_BBFREEZE_OUTPUT_DIR "C:\build-win32\deluge-bbfreeze-${PROGRAM_VERSION}" 
and line 119 which is this:

Code: Select all

OutFile "..\build-win32\deluge-${PROGRAM_VERSION}-win32-setup.exe" 
Change it to this:

Code: Select all

OutFile "C:\build-win32\deluge-${PROGRAM_VERSION}-win32-setup.exe"
I put a specific drive letter on as NSIS kept giving me errors, changing it fixed the issue.

In your command prompt, enter:

Code: Select all

python C:\deluge-1.3.5\Win32\deluge-bbfreeze.py
This will bbfreeze it, and the whole thing will either end up in C:\build-win32, or the C:\deluge-1.3.5\build-win32 folder. If it is in the second, copy the deluge-bbfreeze-1.3.5 folder into the C:\build-win32\ folder.

Finally you should now be able to right click the installer script, and click Compile with NSIS. It will then build the installer, it will reside in C:\build-win32 as deluge-1.3.5-win32-setup.exe.

The Win32README.txt file is completely outdated as it uses older versions of components and requires lines in scripts to be changed that aren't needed as the newer versions are OK so DON'T refer to it. If anyone has any errors, post them here and I'll help. It took me a lot of messing about so all this was done in random steps but I think I've got it right finally!
Post Reply