diff --git a/README.md b/README.md index 6be10c96c8e..d03f7f86372 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ or retrying failed connection attempts (to name just a few of dozens of such low Remote procedure calls ([RPCs][rpcs]) are at the heart of the Ice framework. You create RPCs with an easy 2-step process: + 1. Define the contract between your client and your server with the [Slice][slice] languageā€”Ice's [IDL][idl]. 2. Run the Slice compiler on these Slice definitions to generate stubs in the programming language(s) of your choice. @@ -85,7 +86,7 @@ languages. ## Building Ice from source -[C++](cpp/BUILDING.md) | [C#](csharp/BUILDING.md) | [Java](java/BUILDING.md) | [Java Compat](java-compat/BUILDING.md) | [JavaScript/TypeScript](js) | [MATLAB](matlab) | [Objective-C](objective-c) | [PHP](php) | [Python](python) | [Ruby](ruby) | [Swift](swift) +[C++](cpp/BUILDING.md) | [C#](csharp/BUILDING.md) | [Java](java/BUILDING.md) | [Java Compat](java-compat/BUILDING.md) | [JavaScript/TypeScript](js/BUILDING.md) | [MATLAB](matlab/BUILDING.md) | [Objective-C](objective-c/BUILDING.md) | [PHP](php/BUILDING.md) | [Python](python/BUILDING.md) | [Ruby](ruby/BUILDING.md) | [Swift](swift/BUILDING.md) ## Copyright and license diff --git a/python/BUILDING.md b/python/BUILDING.md new file mode 100644 index 00000000000..7005362ef40 --- /dev/null +++ b/python/BUILDING.md @@ -0,0 +1,165 @@ +# Ice for Python Build Instructions + +This document describes how to build and install Ice for Python from source. +You can also download and install a [binary distribution]. + +* [Building with Pip](#building-with-pip) +* [Building with Visual Studio 2015 and MSBuild (Python 3\.11 for Windows)](#building-with-visual-studio-2015-and-msbuild-python-311-for-windows) +* [Building on Linux or macOS](#building-on-linux-or-macos) +* [Configuring your Environment for Python](#configuring-your-environment-for-python) +* [Running the Python Tests](#running-the-python-tests) + +## Building with Pip + +You can build the Ice for Python extension from source using `pip`: + +```shell +pip install +``` + +## Building with Visual Studio 2015 and MSBuild (Python 3.11 for Windows) + +You can build an Ice for Python extension that links with the Ice C++ DLLs using Visual Studio and MSBuild. + +First, open a Visual Studio 2015 command prompt: + +* VS2015 x86 Native Tools Command Prompt + +or + +* VS2015 x64 Native Tools Command Prompt + +Using the first Command Prompt produces `Win32` binaries by default, while +the second Command Prompt produces `x64` binaries by default. + +In the Command Prompt, change to the `python` subdirectory: + +```shell +cd python +``` + +You must build Ice for C++ from the `cpp` subdirectory. If you have not done so, +refer to the [C++ build instructions](../cpp/BUILDING.md). + +Then build the extension: + +```shell +msbuild msbuild\ice.proj +``` + +This builds the extension with `Release` binaries for the default platform. The +extension will be placed in `python\x64\Release\IcePy.pyd` for the `x64` +platform and `python\Win32\Release\IcePy.pyd` for the `Win32` platform. + +If you want to build a debug version of the extension, set the MSBuild +`Configuration` property to `Debug`: + +```shell +msbuild msbuild\ice.proj /p:Configuration=Debug +``` + +The debug version of the extension will be placed in +`python\x64\Debug\IcePy_d.pyd` for the `x64` platform and +`python\Win32\Debug\IcePy_d.pyd` for the `Win32` platform. + +For Debug builds, a debug version of the Python interpreter must be installed +as well. + +If you want to build the extension for a different platform than the Command +Prompt's default platform, you need to set the MSBuild property `Platform`. The +supported values for this property are `Win32` and `x64`. + +The following command builds the `x64` platform binaries with the `Release` +configuration: + +```shell +msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 +``` + +This command builds the `Win32` platform binaries with the `Release` +configuration: + +```shell +msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=Win32 +``` + +When using the MSBuild Platform property, the build platform doesn't depend +on the command prompt's default platform. + +The build will use the default location for Python defined in +`python\msbuild\ice.props`. You can override it by setting the `PythonHome` +MSBuild property. For example, the following command will use the Python +installation from `C:\Python310-AMD64` instead of the default location: + +```shell +msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 /p:PythonHome=C:\Python310-AMD64 +``` + +## Building on Linux or macOS + +Ice for Python supports Python versions 2.7 and 3.11. Note however that +your Python installation must have been built with a C++ compiler that is +compatible with the compiler used to build Ice for C++. + +The build of Ice for Python requires to first build Ice for C++ in the `cpp` +subdirectory. + +From the top-level source directory, edit `config/Make.rules` to establish your +build configuration. The comments in the file provide more information. + +Change to the Ice for Python source subdirectory: + +```shell +cd python +``` + +Execute `python -V` to verify that the correct Python interpreter is in your +executable search path. + +Run `make` to build the extension. + +Upon successful completion, run `make install`. You may need additional user +permissions to install in the directory specified by `config/Make.rules`. + +## Configuring your Environment for Python + +Modify your environment to allow Python to find the Ice extension for Python. +The python interpreter must be able to locate the IcePy extension as well as +the Python source files in the `python` subdirectory. This is normally +accomplished by setting the `PYTHONPATH` environment variable to contain the +necessary subdirectory. + +For example on Windows, with Ice for Python installed in `C:\Ice`: + +```shell +set PYTHONPATH=C:\Ice\python;C:\Ice\python\Win32\Release +``` + +For example on Linux or macOS, with Ice for Python installed in `/opt/Ice`: + +```shell +export PYTHONPATH=/opt/Ice/python +``` + +## Running the Python Tests + +After a successful build, you can run the tests as follows: + +Windows: + +```shell +python allTests.py --config=Release --platform=Win32 +``` + +(adjust `--config` and `--platform` to match your build) + +Linux/macOS: + +```shell +python allTests.py +``` + +If everything worked out, you should see lots of `ok` messages. In case of a +failure, the tests abort with `failed`. + +[binary distribution]: https://zeroc.com/downloads/ice diff --git a/python/README.md b/python/README.md index 6643b8a2b3a..5f760df43b1 100644 --- a/python/README.md +++ b/python/README.md @@ -1,145 +1,74 @@ -# Building Ice for Python +# Ice for Python -This document describes how to build and install Ice for Python from source. -You can also download and install a [binary distribution][1]. +[Getting started] | [Examples] | [Documentation] | [Building from source] -* [Building with Pip](#building-with-pip) -* [Building with Visual Studio 2015 and MSBuild (Python 3\.10 for Windows)](#building-with-visual-studio-2015-and-msbuild-python-310-for-windows) -* [Building on Linux or macOS](#building-on-linux-or-macos) -* [Configuring your Environment for Python](#configuring-your-environment-for-python) -* [Running the Python Tests](#running-the-python-tests) +The [Ice framework] provides everything you need to build networked applications, +including RPC, pub/sub, server deployment, and more. -## Building with Pip +Ice for Python is the Python implementation of Ice. -You can build the Ice for Python extension from source using `pip`: -``` -pip install -``` - -## Building with Visual Studio 2015 and MSBuild (Python 3.11 for Windows) - -You can build an Ice for Python extension that links with the Ice C++ DLLs using Visual Studio and MSBuild. - -First, open a Visual Studio 2015 command prompt: +## Sample Code -- VS2015 x86 Native Tools Command Prompt -or -- VS2015 x64 Native Tools Command Prompt +```slice (Hello.ice) +#pragma once -Using the first Command Prompt produces `Win32` binaries by default, while -the second Command Prompt produces `x64` binaries by default. - -In the Command Prompt, change to the `python` subdirectory: -``` -cd python +module Demo +{ + interface Hello + { + void sayHello(); + } +} ``` -You must build Ice for C++ from the `cpp` subdirectory. If you have not done so, -refer to the [C++ build instructions](../cpp/BuildInstructionsWindows.md). -Then build the extension: -``` -msbuild msbuild\ice.proj -``` -This builds the extension with `Release` binaries for the default platform. The -extension will be placed in `python\x64\Release\IcePy.pyd` for the `x64` -platform and `python\Win32\Release\IcePy.pyd` for the `Win32` platform. +```python +// Client application (client.py) +import sys +import Ice -If you want to build a debug version of the extension, set the MSBuild -`Configuration` property to `Debug`: -``` -msbuild msbuild\ice.proj /p:Configuration=Debug -``` -The debug version of the extension will be placed in -`python\x64\Debug\IcePy_d.pyd` for the `x64` platform and -`python\Win32\Debug\IcePy_d.pyd` for the `Win32` platform. - -For Debug builds, a debug version of the Python interpreter must be installed -as well. - -If you want to build the extension for a different platform than the Command -Prompt's default platform, you need to set the MSBuild property `Platform`. The -supported values for this property are `Win32` and `x64`. +Ice.loadSlice('Hello.ice') +import Demo -The following command builds the `x64` platform binaries with the `Release` -configuration: -``` -msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 -``` -This command builds the `Win32` platform binaries with the `Release` -configuration: +# Ice.initialize returns an initialized Ice communicator, the communicator is destroyed +# once it goes out of scope. +with Ice.initialize(sys.argv) as communicator: + hello = Demo.HelloPrx.checkedCast( + communicator.stringToProxy("hello:default -h localhost -p 10000")) + hello.sayHello() ``` -msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=Win32 -``` -When using the MSBuild Platform property, the build platform doesn't depend -on the command prompt's default platform. -The build will use the default location for Python defined in -`python\msbuild\ice.props`. You can override it by setting the `PythonHome` -MSBuild property. For example, the following command will use the Python -installation from `C:\Python310-AMD64` instead of the default location: -``` -msbuild msbuild\ice.proj /p:Configuration=Release /p:Platform=x64 /p:PythonHome=C:\Python310-AMD64 -``` +```python +// Server application (server.py) -## Building on Linux or macOS +import signal +import sys +import Ice -Ice for Python supports Python versions 2.7 and 3.11. Note however that -your Python installation must have been built with a C++ compiler that is -compatible with the compiler used to build Ice for C++. +Ice.loadSlice('Hello.ice') +import Demo -The build of Ice for Python requires to first build Ice for C++ in the `cpp` -subdirectory. -From the top-level source directory, edit `config/Make.rules` to establish your -build configuration. The comments in the file provide more information. +class Printer(Demo.Hello): + def sayHello(self, current): + print("Hello World!") -Change to the Ice for Python source subdirectory: -``` -cd python -``` - -Execute `python -V` to verify that the correct Python interpreter is in your -executable search path. - -Run `make` to build the extension. - -Upon successful completion, run `make install`. You may need additional user -permissions to install in the directory specified by `config/Make.rules`. - -## Configuring your Environment for Python - -Modify your environment to allow Python to find the Ice extension for Python. -The python interpreter must be able to locate the IcePy extension as well as -the Python source files in the `python` subdirectory. This is normally -accomplished by setting the `PYTHONPATH` environment variable to contain the -necessary subdirectory. - -For example on Windows, with Ice for Python installed in `C:\Ice`: -``` -set PYTHONPATH=C:\Ice\python;C:\Ice\python\Win32\Release -``` -For example on Linux or macOS, with Ice for Python installed in `/opt/Ice`: -``` -export PYTHONPATH=/opt/Ice/python -``` - -## Running the Python Tests +# Ice.initialize returns an initialized Ice communicator, the communicator is destroyed +# once it goes out of scope. +with Ice.initialize(sys.argv) as communicator: -After a successful build, you can run the tests as follows: - -Windows: -``` -python allTests.py --config=Release --platform=Win32 + # Install a signal handler to shutdown the communicator on Ctrl-C + signal.signal(signal.SIGINT, lambda signum, frame: communicator.shutdown()) + if hasattr(signal, 'SIGBREAK'): + signal.signal(signal.SIGBREAK, lambda signum, frame: communicator.shutdown()) + adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default -h localhost -p 10000") + adapter.add(Printer(), Ice.stringToIdentity("hello")) + adapter.activate() + communicator.waitForShutdown() ``` -(adjust `--config` and `--platform` to match your build) - -Linux/macOS: -``` -python allTests.py -``` - -If everything worked out, you should see lots of `ok` messages. In case of a -failure, the tests abort with `failed`. -[1]: https://zeroc.com/downloads/ice +[Getting started]: https://doc.zeroc.com/ice/3.7/hello-world-application/writing-an-ice-application-with-python +[Examples]: https://github.com/zeroc-ice/ice-demos/tree/3.7/python +[Documentation]: https://doc.zeroc.com/ice/3.7 +[Building from source]: https://github.com/zeroc-ice/ice/blob/3.7/python/BUILDING.md +[Ice framework]: https://github.com/zeroc-ice/ice diff --git a/ruby/BUILDING.md b/ruby/BUILDING.md new file mode 100644 index 00000000000..df49c3210a5 --- /dev/null +++ b/ruby/BUILDING.md @@ -0,0 +1,172 @@ +# Ice for Ruby Build Instructions + +This file describes how to build and install Ice for Ruby from source code on +Linux and macOS. If you prefer, you can also download [binary distributions][1] +for the supported platforms. + +* [Ruby Build Requirements](#ruby-build-requirements) + * [Operating Systems and Compilers](#operating-systems-and-compilers) + * [Ruby Versions](#ruby-versions) +* [Building the Ruby Extension](#building-the-ruby-extension) +* [Installing Ice for Ruby](#installing-ice-for-ruby) +* [Configuring your Environment for Ruby](#configuring-your-environment-for-ruby) +* [Running the Ruby Tests](#running-the-ruby-tests) +* [SELinux Notes for Ruby](#selinux-notes-for-ruby) + +## Ruby Build Requirements + +### Operating Systems and Compilers + +Ice for Ruby is expected to build and run properly on macOS and on any recent +Linux distribution for x86 and x86_64, and was extensively tested using the +operating systems and Ruby versions listed for our [supported platforms][2]. + +### Ruby Versions + +Ice for Ruby supports Ruby versions 2.0 or later. You can use a source or +binary installation of Ruby. + +If you use an RPM installation, the following packages are required: + +* ruby +* ruby-devel +* ruby-libs (RHEL) + +## Building the Ruby Extension + +The instructions for compiling the Ice extension assume that you have already +installed Ruby. + +The build of Ice for Ruby requires that you first build Ice for C++ in the +`cpp` subdirectory. + +From the top-level source directory, edit `config/Make.rules` to establish your +build configuration. The comments in the file provide more information. + +Change to the Ice for Ruby source subdirectory: + +```shell +cd ruby +``` + +Run `make` to build the extension. + +## Installing Ice for Ruby + +You can perform an automated installation with the following command: + +```shell +make install +``` + +This process uses the `prefix` variable in `../config/Make.rules` as the +installation's root directory. The subdirectory `/ruby` is created as a +copy of the local `ruby` directory and contains the Ice for Ruby extension +library as well as Ruby source code. Using this installation method requires +that you modify your environment as described in *Configuring your Environment +for Ruby* below. + +Another option is to copy the contents of the local `ruby` directory to your +Ruby installation's `site_ruby` directory. For example, if you installed Ruby +via RPM, you can use the steps below: + +```shell +cd /ruby/ruby +sudo tar cf - * | (cd /usr/lib/ruby/site_ruby/1.8/i386-linux; tar xvf -) +``` + +On x86_64 systems, change the last command to: + +```shell +sudo tar cf - * | (cd /usr/lib64/ruby/site_ruby/1.8/x86_64-linux; tar xvf -) +``` + +There is no need to modify your environment if you use this approach. + +## Configuring your Environment for Ruby + +The Ruby interpreter must be able to locate the Ice extension. If you used the +automated installation described above, you need to define the `RUBYLIB` +environment variable as follows: + +```shell +export RUBYLIB=/opt/Ice/ruby:$RUBYLIB +``` + +This example assumes that your Ice for Ruby installation is located in the +`/opt/Ice` directory. + +You must also modify `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` to include the +directory `/opt/Ice/lib`: + +```shell +export LD_LIBRARY_PATH=/opt/Ice/lib:$LD_LIBRARY_PATH (Linux) +export DYLD_LIBRARY_PATH=/opt/Ice/lib:$DYLD_LIBRARY_PATH (macOS) +``` + +To verify that Ruby can load the Ice extension successfully, open a command +window and start the interpreter using `irb`. + +At the prompt, enter: + +```shell +require "Ice" +``` + +If the interpreter responds with the value true, the Ice extension was loaded +successfully. Enter `exit` to quit the interpreter. + +## Running the Ruby Tests + +The `test` subdirectory contains Ruby implementations of the core Ice test +suite. Python is required to run the test suite. + +The test suites require that the Ice for C++ tests be built in the `cpp` +subdirectory of this source distribution. + +Open a command window and change to the top-level directory. At the command +prompt, execute: + +```shell +python allTests.py +``` + +You can also run tests individually by changing to the test directory and +running this command: + +```shell +python run.py +``` + +If everything worked out, you should see lots of `ok` messages. In case of a +failure, the tests abort with `failed`. + +## SELinux Notes for Ruby + +If SELinux is enabled on your RHEL system, you may encounter this error message +when Ruby attempts to load the Ice extension: + +```shell +cannot restore segment prot after reloc: Permission denied +``` + +There are two ways to solve this problem: + +* Change the default security context for the Ice extension using the following + command: + +```shell +chcon -t texrel_shlib_t /opt/Ice/ruby/IceRuby.so +``` + +Replace `/opt/Ice` with your installation directory. + +* Disable SELinux completely by adding the following line to your + `/etc/sysconfig/selinux` file: + +```shell +SELINUX=disabled +``` + +[1]: https://zeroc.com/downloads/ice +[2]: https://doc.zeroc.com/ice/3.7/release-notes/supported-platforms-for-ice-3-7-10 diff --git a/ruby/README.md b/ruby/README.md index bd6d8f678b2..b4510fb120f 100644 --- a/ruby/README.md +++ b/ruby/README.md @@ -1,162 +1,41 @@ -# Building Ice for Ruby on Linux and macOS +# Ice for Ruby -This file describes how to build and install Ice for Ruby from source code on -Linux and macOS. If you prefer, you can also download [binary distributions][1] -for the supported platforms. +[Getting started] | [Examples] | [Documentation] | [Building from source] -* [Ruby Build Requirements](#ruby-build-requirements) - * [Operating Systems and Compilers](#operating-systems-and-compilers) - * [Ruby Versions](#ruby-versions) -* [Building the Ruby Extension](#building-the-ruby-extension) -* [Installing Ice for Ruby](#installing-ice-for-ruby) -* [Configuring your Environment for Ruby](#configuring-your-environment-for-ruby) -* [Running the Ruby Tests](#running-the-ruby-tests) -* [SELinux Notes for Ruby](#selinux-notes-for-ruby) +The [Ice framework] provides everything you need to build networked applications, +including RPC, pub/sub, server deployment, and more. -## Ruby Build Requirements +Ice for Ruby is the Ruby implementation of Ice. -### Operating Systems and Compilers +## Sample Code -Ice for Ruby is expected to build and run properly on macOS and on any recent -Linux distribution for x86 and x86_64, and was extensively tested using the -operating systems and Ruby versions listed for our [supported platforms][2]. +```slice (Hello.ice) +#pragma once -### Ruby Versions - -Ice for Ruby supports Ruby versions 2.0 or later. You can use a source or -binary installation of Ruby. - -If you use an RPM installation, the following packages are required: -``` -ruby -ruby-devel -ruby-libs (RHEL) -``` - -## Building the Ruby Extension - -The instructions for compiling the Ice extension assume that you have already -installed Ruby. - -The build of Ice for Ruby requires that you first build Ice for C++ in the -`cpp` subdirectory. - -From the top-level source directory, edit `config/Make.rules` to establish your -build configuration. The comments in the file provide more information. - -Change to the Ice for Ruby source subdirectory: -``` -cd ruby -``` - -Run `make` to build the extension. - -## Installing Ice for Ruby - -You can perform an automated installation with the following command: +module Demo +{ + interface Hello + { + void sayHello(); + } +} ``` -make install -``` - -This process uses the `prefix` variable in `../config/Make.rules` as the -installation's root directory. The subdirectory `/ruby` is created as a -copy of the local `ruby` directory and contains the Ice for Ruby extension -library as well as Ruby source code. Using this installation method requires -that you modify your environment as described in *Configuring your Environment -for Ruby* below. - -Another option is to copy the contents of the local `ruby` directory to your -Ruby installation's `site_ruby` directory. For example, if you installed Ruby -via RPM, you can use the steps below: -``` -cd /ruby/ruby -sudo tar cf - * | (cd /usr/lib/ruby/site_ruby/1.8/i386-linux; tar xvf -) -``` - -On x86_64 systems, change the last command to: -``` -sudo tar cf - * | (cd /usr/lib64/ruby/site_ruby/1.8/x86_64-linux; tar xvf -) -``` - -There is no need to modify your environment if you use this approach. -## Configuring your Environment for Ruby +```ruby +// Client application (client.rb) +require 'Ice' -The Ruby interpreter must be able to locate the Ice extension. If you used the -automated installation described above, you need to define the `RUBYLIB` -environment variable as follows: -``` -export RUBYLIB=/opt/Ice/ruby:$RUBYLIB -``` +Ice::loadSlice('Hello.ice') -This example assumes that your Ice for Ruby installation is located in the -`/opt/Ice` directory. - -You must also modify `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` to include the -directory `/opt/Ice/lib`: -``` -export LD_LIBRARY_PATH=/opt/Ice/lib:$LD_LIBRARY_PATH (Linux) -export DYLD_LIBRARY_PATH=/opt/Ice/lib:$DYLD_LIBRARY_PATH (macOS) -``` - -To verify that Ruby can load the Ice extension successfully, open a command -window and start the interpreter using `irb`. - -At the prompt, enter: -``` -require "Ice" -``` - -If the interpreter responds with the value true, the Ice extension was loaded -successfully. Enter `exit` to quit the interpreter. - -## Running the Ruby Tests - -The `test` subdirectory contains Ruby implementations of the core Ice test -suite. Python is required to run the test suite. - -The test suites require that the Ice for C++ tests be built in the `cpp` -subdirectory of this source distribution. - -Open a command window and change to the top-level directory. At the command -prompt, execute: -``` -python allTests.py -``` - -You can also run tests individually by changing to the test directory and -running this command: -``` -python run.py -``` - -If everything worked out, you should see lots of `ok` messages. In case of a -failure, the tests abort with `failed`. - -## SELinux Notes for Ruby - -If SELinux is enabled on your RHEL system, you may encounter this error message -when Ruby attempts to load the Ice extension: -``` -cannot restore segment prot after reloc: Permission denied -``` -There are two ways to solve this problem: - -- Change the default security context for the Ice extension using the following -command: - -``` -chcon -t texrel_shlib_t /opt/Ice/ruby/IceRuby.so -``` - -Replace `/opt/Ice` with your installation directory. - -- Disable SELinux completely by adding the following line to your -`/etc/sysconfig/selinux` file: - -``` -SELINUX=disabled +Ice::initialize(ARGV) do |communicator| + hello = Demo::HelloPrx::checkedCast( + communicator.stringToProxy("hello:default -h localhost -p 10000")) + hello.sayHello() +end ``` -[1]: https://zeroc.com/downloads/ice -[2]: https://doc.zeroc.com/ice/3.7/release-notes/supported-platforms-for-ice-3-7-10 +[Getting started]: https://doc.zeroc.com/ice/3.7/hello-world-application/writing-an-ice-application-with-ruby +[Examples]: https://github.com/zeroc-ice/ice-demos/tree/3.7/ruby +[Documentation]: https://doc.zeroc.com/ice/3.7 +[Building from source]: https://github.com/zeroc-ice/ice/blob/3.7/ruby/BUILDING.md +[Ice framework]: https://github.com/zeroc-ice/ice