Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675

Warning: preg_match_all(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 670

Warning: Invalid argument supplied for foreach() in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 671

Warning: preg_replace(): Compilation failed: group name must start with a non-digit at offset 4 in /home/fuzzyman/webapps/www.ironpython.info/includes/MagicWord.php on line 675
Deployment - IronPython Cookbook

Deployment

From IronPython Cookbook

(.NET 3.0)
m (Batch Files: typo fix)
 
Line 31: Line 31:
===.NET 3.0===
===.NET 3.0===
-
The .NET 3.0 framework is required on the target computer whenever any of the enclosed classes are used.  If the author uses the words Windows Communication Foundation (WF), Windows Workflow Foundation (WWF), Windows CardSpace (WCS), Windows Presentation Foundation (WPF), or XAML then the file is likely to require the .NET Framework 3.0.
+
The .NET 3.0 framework is required on the target computer whenever any of the enclosed classes are used.  If the author uses the words Windows Communication Foundation (WCF), Windows Workflow Foundation (WWF), Windows CardSpace (WCS), Windows Presentation Foundation (WPF), or XAML then the file is likely to require the .NET Framework 3.0.
Some examples of statements which require .NET 3.0:
Some examples of statements which require .NET 3.0:
Line 40: Line 40:
clr.AddReference("PresentationCore") # WPF
clr.AddReference("PresentationCore") # WPF
-
# To be appended: # references for WCF, WCF, WWF
+
# To be appended: # references for WCF, WCS, WWF
</pre>
</pre>
Line 60: Line 60:
# In any case point the extension to the "ipy.exe" IronPython interpreter.
# In any case point the extension to the "ipy.exe" IronPython interpreter.
 +
==Batch Files==
 +
 +
An alternative to setting up file associations, which entails more involved changes to your or the user's system, is to deploy a [http://en.wikipedia.org/wiki/Batch_file batch file] along with your script. The batch file should reside in the same directory and bear the same name (but using the BAT extension, of course) as your main Python script. The batch file can then be used to launch your script either from the [http://www.voidspace.org.uk/python/articles/command_line.shtml Windows Command Prompt] or the Windows Explorer assuming the following contents:
 +
 +
<pre>
 +
@ipy "%~dpn0.py" %*
 +
</pre>
 +
 +
This is a very generic line that basically launches '''ipy.exe''' (assuming it is in your environment '''PATH''') and supplies the name of your python script as the first argument (this is the odd-looking bit reading '''"%~dpn0.py"''') and passes-through the remaining arguments from the batch on to your script (this is the '''%*''' bit). You may be wondering what '''%~dpn0.py''' means after all. Taking the simple case first, a '''%0''' appearing in a batch file gets replaced at run-time with the text you typed to invoke the batch file on the command-line (excluding arguments). When you insert a '''~''' and some reserved letters between '''%''' and '''0''' then the various path components of the batch file path are expanded at run-time based on the modifiers you supply. The useful modifiers to know are d (drive letter), p (directory path), n (file name) and x (extension). So by saying '''%~dpn0.py''', we told the batch interpreter that we want to expand the drive, directory path and file name of the batch file, but note, not the extension (no x was mentioned). Instead we supplied the conventional Python extension (py). This may also explain why the batch file name must be the same as the file name of your main Python script. The surrounding double-quotes (") ensure that paths with spaces are handled as a single atom and not mistaken as multiple arguments to the batch. Finally, the '''@''' at the beginning tells the batch file interpreter not to echo the statement it is executing to the console. The at-sign (@) shortcut basically avoids having <et another line at the start of the batch reading '''ECHO OFF'''. Ffor single-liner batches, a simple '''@''' does the job well.
Back to [[Contents]].
Back to [[Contents]].

Current revision as of 23:07, 10 November 2007

TOOLBOX
LANGUAGES