Skip to content

Commit

Permalink
build: pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrdjan committed Apr 24, 2023
1 parent 315e8bb commit fe14c80
Show file tree
Hide file tree
Showing 14 changed files with 3,868 additions and 4,029 deletions.
85 changes: 0 additions & 85 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
recursive-exclude doc *
recursive-exclude examples *
recursive-exclude tests *
recursive-exclude tests *
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Asynchronous, non-blocking [SAP NetWeawer RFC SDK](https://support.sap.com/en/pr
- [Windows](#windows)
- [macOS](#macos)
- [Download and installation](#download-and-installation)
- [Linux](#linux)
- [Windows and macOS](#windows-and-macos)
- [Getting started](#getting-started)
- [Call ABAP Function Module from Python](#call-abap-function-module-from-python)
- [Call Python function from ABAP](#call-python-function-from-abap)
Expand Down Expand Up @@ -80,13 +82,23 @@ Asynchronous, non-blocking [SAP NetWeawer RFC SDK](https://support.sap.com/en/pr

## Download and installation

### Linux

Cython must be installed upfront because the build from source is standard installation method on Linux.

Also the `pip` option `--no-build-isolation` is mandatory:

```shell
pip install pyrfc
pip install --no-build-isolation pyrfc
```

Cython is required on Linux platforms, for the the default build from source installation method.
### Windows and macOS

```shell
pip install pyrfc
```

Build from source can be also requested on Windows and Darwin platforms:
Build from source can be requested also on Windows and macOS platforms:

```shell
pip install pyrfc --no-binary :all:
Expand All @@ -99,7 +111,7 @@ Alternative build from source installation:
```shell
git clone https://github.com/SAP/PyRFC.git
cd PyRFC
python setup.py bdist_wheel
python -m build --wheel --sdist --outdir dist
pip install --upgrade --no-index --find-links=dist pyrfc
```

Expand Down
107 changes: 10 additions & 97 deletions doc/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ Toolchain preparation

Linux platform
---------------
* :ref:`Install Python, pip <install-python-linux>` and utilities:

* :ref:`Install Python, pip <install-python-linux>` and packages:

.. code-block:: sh
pip install cython wheel pytest sphinx
pip install build cython wheel pytest sphinx
* :ref:`Install SAP NW RFC Library <install-c-connector>`
* To get any software from the Git source control system the Git
Expand All @@ -33,23 +34,23 @@ Windows platform

.. code-block:: sh
pip install cython wheel pytest sphinx
pip install build cython wheel pytest sphinx
* :ref:`Visual C++ Redistributable Package for Visual Studio 2013 <install-vs-cpp-redist>` is required for runtime,

* :ref:`Install SAP NW RFC Library <install-c-connector>`
* To get any software from the Git source control system the Git
client is required as well. Download and install from
http://code.google.com/p/msysgit/downloads/list?can=3.
During installation specify that Git runs
out of the Bash shell as you may need that shell later on.
* Download and install the compiler toolchain, tested on Windows platforms
* Download and install the compiler toolchain, following `SAP Note 2573790 - Installation, Support and Availability of the SAP NetWeaver RFC Library 7.50 <https://launchpad.support.sap.com/#/notes/2573790>`_

* `MS VisualStudio2008 Express Edition <http://go.microsoft.com/?linkid=7729279>`_ or later
* `Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 <http://www.microsoft.com/en-us/download/details.aspx?id=3138>`_ or later

macOS platform
--------------

* Install Xcode command line tools with C++ development headers and check if `uchar.h` copied to $SAPNWRFC_HOME/include
* Install Xcode command line tools with C++ development headers

.. code-block:: sh
Expand All @@ -60,72 +61,17 @@ macOS platform
Building the code
=================

To build wheels for different Python versions, install these versions
on your system and create a virtual environment for each of these versions,
for example:

``virtualenv --python=<PATH e.g. c:\Python27\python.exe OR /usr/bin/python2.7> ...``

Otherwise, follow the example below.

Linux platform
--------------

Clone the repository:

.. code-block:: sh
git clone https://github.com/SAP/PyRFC
Edit ``setup.py`` and set the CYTHON_VERSION

Build the distribution

.. code-block:: sh
python setup.py clean --all
python setup.py bdist_wheel
cd PyRFC
python -m build --wheel --outdir dist
The result is found in the ``dist/`` directory. The process has to be done on all platforms
for which we provide wheels.

Windows platform
----------------

Open the ``GIT Bash`` shell and clone the repository.

.. code-block:: sh
git clone https://github.com/SAP/PyRFC
Open the ``CMD Shell`` from ``Microsoft Windows SDK 7.0`` and change to cloned ``pyrfc`` folder.

Edit ``setup.py`` and set the CYTHON_VERSION

Set env variables for the release, use /x64 for 64 bit and /x86 for 32 bit:

.. code-block:: sh
set DISTUTILS_USE_SDK=1
setenv /x64 /release
Build the distribution:

.. code-block:: sh
python setup.py clean --all
python setup.py bdist_wheel
Check the ``pyrfc\dist`` folder for a new created wheel.

macOS platform
--------------

.. code-block:: sh
MACOS_UNICODE_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/unicode
sudo ln -s $MACOS_UNICODE_DIR $SAPNWRFC_HOME/include/unicode
sudo cp $MACOS_UNICODE_DIR/uchar.h $SAPNWRFC_HOME/include/.

Linting and Formatting
----------------------
Expand All @@ -140,39 +86,6 @@ Linting and Formatting
black src test
Virtual Environments
--------------------

You may have buth 32bit and 64bit versions of Python installed on your
system and use virtual environments. This is basically possible (e.g. installing
the 32bit version on 64 bit system in ``C:\Python27_32\``, but beware of modifying
the PATH variable.

However, the PATH variable is modified when using a virtual environment, therefore
modify the ``Scripts/activate.bat`` file with:

.. code-block:: sh
set SAPNWRFC_HOME=C:\nwrfcsdk_x86
set PATH=C:\nwrfcsdk_x86\lib\;%PATH%
set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
This assures that specific SAP NW RFC Library is used (e.g. 32bit in this example).
This is not required for building the distribution, but rather for importing the Python connector.

The build process remains the same, only before building the distribution, you need to
activate the virtual environment and assure that library paths are correct in ``setup.py``.

Python 3
--------

Prerequisites for building on Python 3, tested on Linux Mint and Ubuntu

.. code-block:: sh
sudo apt-get install python3-setuptools python3-dev python-configparser
sudo pip3 install cython sphinx ipython pytest wheel
Building the documentation
==========================
Expand Down
57 changes: 55 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
[build-system]
requires = ["setuptools", "wheel", "Cython"] # PEP 508 specifications.
requires = ["Cython ~= 0.29.0", "setuptools ~= 67.7.0", "wheel ~= 0.40.0"]
build-backend = "setuptools.build_meta"

# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
[project]
name = "xtest_sapnwrfc"
version = "0.0.14"
readme = "README.md"
license = { file = "LICENSES/Apache-2.0.txt" }
description = "Python bindings for SAP NetWeaver RFC SDK"
authors = [ { name = "SAP SE"} ]
maintainers = [ { name = "Srdjan Boskovic", email = "srdjan.boskovic@sap.com" } ]
requires-python = ">=3.7"
keywords = ["pyrfc", "sap", "nwrfc", "sapnwrfc", "abap"]
classifiers = [
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only"
]
dependencies = []

[project.urls]
homepage = "https://github.com/SAP/PyRFC"
documentation = "http://sap.github.io/PyRFC"
repository = "https://github.com/SAP/PyRFC.git"

[tool.cython-lint]
max-line-length = 148
max-line-length = 148

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[tool.setuptools]
include-package-data = false
#exclude-package-data = {"*" = ["*.cpp", "*.html", "*.pyx", "*.pxd"]}
#license-files=["LICENSES/*.txt"]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
xtest_sapnwrfc = ["*.pxd"]

[tool.setuptools.exclude-package-data]
xtest_sapnwrfc = ["*.pyx", "*.pxd", "*.cpp"]

[tool.setuptools.dynamic]
readme = {file = "README.md"}
Loading

0 comments on commit fe14c80

Please sign in to comment.