With CODESYS 3.5.5.0 the LibDoc Scripting Collection is part of the CODESYS Setup. With this, installing a complete Python environment is not necessary! Only installing the HTML Help Workshop is now an option to have the full benefit of the Scripting Collection.
The content of this page is based on the information in "The Hitchhiker's Guide to Python" [1] and the content found in the Python Packaging User Guide [2]
First, download the Python interpreter for the Python 2.7 scripting language from the official Website. If you want to be sure you are installing a fully up-to-date version then use the "Windows Installer" link from the home page of the Python.org web site .
The Windows version is provided as an MSI package. To install it manually, just double-click the file. The MSI package format allows Windows administrators to automate installation with their standard tools.
By design, Python installs to a directory with the version number embedded, e.g. Python version 2.7 will install at C:\Python27\, so that you can have multiple versions of Python on the same system without conflicts. Of course, only one interpreter can be the default application for Python file types. It also does not automatically modify the PATH environment variable, so that you always have control over which copy of Python is run.
Typing the full path name for a Python interpreter each time quickly gets tedious, so add the directories for your default Python version to the PATH. Assuming that your Python installation is in C:\Python27\, add this to your PATH:
C:\Python27\;C:\Python27\Scripts\
The second (Scripts) directory receives command files when certain packages are installed, so it is a very useful addition.
If you want to read some background information about Python packaging and installation tools, please take a look to the Python Packaging User Guide [2]
The most crucial third-party Python software of all is Setuptools, which extends the packaging and installation facilities provided by the distutils in the standard library. Once you add Setuptools to your Python system you can download and install any compliant Python software product with a single command. It also enables you to add this network installation capability to your own Python software with very little work.
To install setuptools from scratch:
Securely download ez_setup.py.
Then run the following (which may require administrator access):
> python ez_setup.py
pip is a tool for installing and managing Python packages.
To install pip, run the python script available here: get-pip.py
> python get-pip.py
After Setuptools & Pip, the next development tool that you should install is virtualenv . Use pip
> pip install virtualenv
The virtualenv kit provides the ability to create virtual Python environments that do not interfere with either each other, or the main Python installation. If you install virtualenv before you begin coding then you can get into the habit of using it to create completely clean Python environments for each project. This is particularly important for developing projects, where each framework and application will have many dependencies.
To set up a new Python environment, change the working directory to wherever you want to store the environment, and run the virtualenv utility in your project's directory
> virtualenv LibDoc
> cd LibDoc
> Scripts\activate
(LibDoc) >
To use an environment, run the activate.bat batch file in the Scripts subdirectory of that environment. Your command prompt will change to show the active environment. Once you have finished working in the current virtual environment, run the deactivate.bat batch file to restore your settings to normal.
Each new environment automatically includes a copy of pip in the Scripts subdirectory, so that you can setup the third-party libraries and tools that you want to use in that environment. Put your own code within a subdirectory of the environment, however you wish. When you no longer need a particular environment, simply copy your code out of it, and then delete the main directory for the environment.
Virtualenv Wrapper is a set of extensions to the virtualenv tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
Features:
Organizes all of your virtual environments in one place.
Wrappers for creating, copying and deleting environments, including user-configurable hooks.
Use a single command to switch between environments.
Tab completion for commands that take a virtual environment as argument.
User-configurable hooks for all operations.
Plugin system for more creating sharable extensions.
Please take a look to the nice documentation .
Using pip we can install virtualenvwrapper-win with the code below:
> pip install virtualenvwrapper-win
After this step we can do the following things:
> mkvirtualenv LibDoc
> workon LibDoc
(LibDoc) >
(LibDoc) > deactivate
>
Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.
It is easy to add a basic syntax highlighting for reStructuredText.
The editor provides a PlugIn system and can be extended for example with a SpellChecker.
Notepad++ provide a lot of functionality to be your favorite tool for writing larger documents in reStructuredText.
For transforming reStructuredText in a document for the Microsoft Online Help this tool is necessary.
Please download the htmlhelp.exe from Microsofts download area and execute the installer application.
For generating perfect formated PDF documents a full blown TeX installation is necessary.
Please download the TeX Live installer from the TeX Users Group web site.
A huge amount of information is out there in the net about TeX, LaTeX, ...
One Example of a "short" introduction in to LaTeX: https://tobi.oetiker.ch/lshort/lshort-a5.pdf
Write translations for any documentation that uses PO-Files for localization. PO-Files is used widely, in many programming languages and many projects – from WordPress to many PHP projects, Django or pretty much anything on Linux. Library developers can use Poedit to maintain their translation files (or templates) and keep them fresh. It may be too simple for more complicated projects, but most of the time, that simplicity comes handy.
Please download the Poedit.exe from the web site managed by Václav Slavík.
This package contains the compiler and set of system headers necessary for producing binary wheels for Python packages. A binary wheel of a Python package can then be installed on any Windows system without requiring access to a C compiler.
For the analysis of source code from the CODESYS runtime system, the LibDoc Scripting Collection uses the preprocessor of the MinGW compiler.
Start by downloading and installing the MinGW compiler at http://www.mingw.org/wiki/Getting_Started
An automated GUI installer assistant called mingw-get-setup.exe is the preferred method for first time installation.
Add the path of the compiler to your PATH environment variable (eg: c:\MinGW\bin should appear in the PATH)
Now open the prompt and check if the compiler is correctly installed (gcc --version should be properly working)
It is very useful to tell distutils to use mingw. To achieve this,
create a file named distutils.cfg (if you already don't have it) in your local Lib\distutils folder and add to it the following lines:
[build] compiler = mingw32
The LibDoc Scripting Collection is provided as a file called LibDoc-<version>.zip. To install the scripting collection please execute the following command.
(LibDoc) > pip install LibDoc-<version>.zip
To test all this installations, please execute the following lines of code:
> Scripts\activate
(LibDoc) > pip list
docopt (0.6.1)
LibDoc (0.0.1a4)
docutils (0.11)
Jinja2 (2.7.1)
pip (1.5)
setuptools (2.1)
Sphinx (1.2)
(LibDoc) > python
>>> from libdoc import __version__
>>> print __version___
<version>
>>> exit()
(LibDoc) > libdoc --version
<version>