Changes between Version 1 and Version 2 of Packages/Python


Ignore:
Timestamp:
Dec 11, 2014, 3:06:21 AM (5 years ago)
Author:
Chris Johns
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Packages/Python

    v1 v2  
    44
    55
    6 Python is a programming language that can be embedded in user programs giving them the added functionality of a fully featured scripting language. You can find out more about Python by visting its web site -
     6Python is a programming language that can be embedded in user programs giving them the added functionality of a fully featured scripting language. You can find out more about Python by visiting its web site -
    77
    88  http://www.python.org/
     
    1010
    1111
    12 Python and RTEMS are a great combination. RTEMS provides you with a stable, scalable real-time operating system on which you build your applications. It also allows you to run low priority threads for monitoring and managment functions. SNMP and a webserver are examples of typical services and interfaces you find on embedded devices. These days with more internet integration in embedded real-time products the number of complex protocols grows. Python has an extensive protocol library that can be used by your application to meet these demands. For example you could send an email using SMTP, fetch configuration data from a POP or IMAP email account, or via the HTTP protocol from a web server.
     12Python and RTEMS are a great combination. RTEMS provides you with a stable, scalable real-time operating system on which you build your applications. It also allows you to run low priority threads for monitoring and management functions. SNMP and a webserver are examples of typical services and interfaces you find on embedded devices. These days with more internet integration in embedded real-time products the number of complex protocols grows. Python has an extensive protocol library that can be used by your application to meet these demands. For example you could send an email using SMTP, fetch configuration data from a POP or IMAP email account, or via the HTTP protocol from a web server.
    1313
    1414So far I have used on RTEMS the following modules -
    1515
    16 #The httplib (requires some minor, see Sourceforge Bug #1229646) to read web pages from a number of web servers.
    17 #The imaplib to open and read my email INBOX.
    18 #The smtplib to send email. I sent email to Joel to say hi. This uses the email package that can handle generating and parsing email.
    19 #The os module. I was able to list, change and make directories.
     161. The httplib (requires some minor, see Sourceforge Bug !#1229646) to read web pages from a number of web servers.
     171. The imaplib to open and read my email INBOX.
     181. The smtplib to send email. I sent email to Joel to say hi. This uses the email package that can handle generating and parsing email.
     191. The os module. I was able to list, change and make directories.
    2020
    2121If you use C++ in your application you can use PyCXX to integrate your C++ code to Python. The PyCXX project can be found at http://cxx.sourceforge.net/.
     
    2727RTEMS version is 4.6 but 4.7 will be even easier to support thanks to Ralf's excellent work in cleaning up the RTEMS header files. The RTEMS build is multilib therefore the multilib library install paths are used.
    2828
    29 Python running on most modern machines makes use of dynmanic loading of code. On Unix this is shared libraries and on Windows this is a DLL. On RTEMS we do not support dynamic loading so we need to build and include in the Python library required modules. Python normally handles this by running a Python program in the new Python intepreter. This program performs a range of checks and determines the modules the platform requires. We cannot do this for RTEMS so we have a list of modules and add them to the generated Makefile.
     29Python running on most modern machines makes use of dynamic loading of code. On Unix this is shared libraries and on Windows this is a DLL. On RTEMS we do not support dynamic loading so we need to build and include in the Python library required modules. Python normally handles this by running a Python program in the new Python interpreter. This program performs a range of checks and determines the modules the platform requires. We cannot do this for RTEMS so we have a list of modules and add them to the generated Makefile.
    3030
    3131The build machine is running Fedora Core 3 with a working RTEMS tool set.
     
    3434 * Fetch the Python patch from the RTEMS web site (ftp://ftp.rtems.org/pub/rtems/4.6.99.2/contrib/python).
    3535 * Unpack the Python source.
    36  * Perform a native build for the build machine outside the Python source tree. We need to create a local program call ''pgen''. Python does not cross-compile out of the box and so a simple work around is to build Python for the local machine first and reference it. The ''pgen'' program is not used in the cross-compile for RTEMS but no reference results in it tring to be cross-compiled and run which will not succeed.
     36 * Perform a native build for the build machine outside the Python source tree. We need to create a local program call ''pgen''. Python does not cross-compile out of the box and so a simple work around is to build Python for the local machine first and reference it. The ''pgen'' program is not used in the cross-compile for RTEMS but no reference results in it trying to be cross-compiled and run which will not succeed.
    3737 
    3838         $ tar jxf Python-2.4.1.tar.bz2
     
    5050
    5151
    52 You will end up wuth a Python library and Python header files ready for your application.
     52You will end up with a Python library and Python header files ready for your application.
    5353= RTEMS Python Application =
    5454
     
    8888The build script in the example directory -
    8989
    90 #Builds 3 C files
    91 #Run the local Python 2.4 interpreter to compile all the python code. We only need the compiled python code.
    92 #Creates a tar file of the compiled Python library code.
    93 #Link the example.
    94 #Convert to a binary image.
    95 #Compress the image. The Cybertec Microcore boot monitor accept gzip and 7zip files.
    96 = RTEMS Python Build Script#[wiki:Script script] =
     901. Builds 3 C files
     911. Run the local Python 2.4 interpreter to compile all the python code. We only need the compiled python code.
     921. Creates a tar file of the compiled Python library code.
     931. Link the example.
     941. Convert to a binary image.
     951. Compress the image. The Cybertec Microcore boot monitor accept gzip and 7zip files.
     96= RTEMS Python Build Script =
    9797
    9898
    9999The script requires you supply 4 options. The options are not checked. You can down the script with the example. See the RTEMS Python Application section.
    100100
    101 #The RTEMS target. For example ''m68k'' for ''m68k-rtems''.
    102 #The CPU or BSP label. This is the directory the library and headers are installed into under the RTEMS prefix.
    103 #The compiler flags for the CPU. For example the Coldfire 5272 is m5200. This is separared from the CPU name so the processors such the i386 family can be supported.
    104 #The prefix is the path the installed RTEMS.
     1011. The RTEMS target. For example ''m68k'' for ''m68k-rtems''.
     1021. The CPU or BSP label. This is the directory the library and headers are installed into under the RTEMS prefix.
     1031. The compiler flags for the CPU. For example the Coldfire 5272 is m5200. This is separared from the CPU name so the processors such the i386 family can be supported.
     1041. The prefix is the path the installed RTEMS.
    105105
    106106The script does not build in unicode support into Python. If you require unicode support you need remove ''--disable-unicode'' from the configure command line and place the unicode modules into the Modules list the script contains. Unicode is disabled as it contains a number of large 64K byte tables. These are not correctly declared as ''const'' so end up in the executable and then in the data space.