Skip to content

Commit

Permalink
build: package build standardization
Browse files Browse the repository at this point in the history
Package build re-factored, following PEP-518, versioning done in pyproject.toml
  • Loading branch information
bsrdjan committed Apr 25, 2023
1 parent fe14c80 commit 5b09879
Show file tree
Hide file tree
Showing 16 changed files with 7,200 additions and 6,394 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ setuptools*.egg

material
ci/test
ci/issues
ci/issues

tests/tmp
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
recursive-exclude doc *
recursive-exclude examples *
recursive-exclude tests *
recursive-exclude tests *
include src/pyrfc/csapnwrfc.pxd
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ 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 @@ -82,23 +80,13 @@ 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 --no-build-isolation pyrfc
```

### Windows and macOS

```shell
pip install pyrfc
```

Build from source can be requested also on Windows and macOS platforms:
Cython must be installed upfront because the build from source is standard installation method on Linux.

Build from source can be requested also on other platforms:

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

Run ``python`` and type ``from pyrfc import *``. If this finishes silently, without oputput, the installation was successful.

Using virtual environments you can isolate Python/PyRFC projects, working without administrator privileges.

See also the [pyrfc documentation](http://sap.github.io/PyRFC),
complementing _SAP NWRFC SDK_[documentation](https://support.sap.com/nwrfcsdk), especially [SAP NWRFC SDK 7.50 Programming Guide](https://support.sap.com/content/dam/support/en_us/library/ssp/products/connectors/nwrfcsdk/NW_RFC_750_ProgrammingGuide.pdf).

Expand Down
7 changes: 4 additions & 3 deletions ci/utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ $python_versions.Split(" ") | ForEach {
pyenv shell $version
python -V

If($action -eq "pip") {
python -m pip install --upgrade pip
If($action -eq "tools") {
python -m pip install --upgrade pip build setuptools cython wheel
} else {
If($action -ne "test") {
python setup.py bdist_wheel
python -m build --no-isolation --wheel --outdir dist
pip install --upgrade --force --find-links=dist pyrfc
}
If($action -ne "skip-test") {
pytest -vvx
}
}
}
pytest -vvx
14 changes: 8 additions & 6 deletions ci/utils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ do
rm -rf tests/stfc-mrfc/__pycache__
echo py$version
pyenv activate py$version
if [[ $1 == pip ]]; then
pip install --upgrade pip
if [[ $1 == tools ]]; then
pip install --upgrade pip build setuptools cython wheel
else
if [[ $1 != test ]]; then
PYRFC_BUILD_CYTHON=yes python setup.py bdist_wheel
PYRFC_BUILD_CYTHON=yes python -m build --no-isolation --wheel --outdir dist
pip install --upgrade --force --find-links=dist pyrfc
fi
if [[ $1 != skip-test ]]; then
else
pytest -vvx
fi
fi
done
python setup.py sdist
if [[ $1 != tools ]]; then
python -m build --no-isolation --sdist --outdir dist
pytest -vvx
fi
54 changes: 4 additions & 50 deletions doc/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,64 +120,18 @@ For pyrfc:
Python Connector Installation
=============================

Download the wheel from your platform, from the `latest release <https://github.com/SAP/PyRFC/releases/latest>`_ and pip install.
see `README: Download and Installation <https://github.com/SAP/PyRFC#download-and-installation>`_

Using virtual environments you can isolate Python/PyRFC projects, working without administrator privileges.

Windows
-------

.. _`install-python-win`:

* If not already installed, install the Python first: https://www.python.org/downloads/windows/

Add Python and Scripts directories to ``PATH`` environment variable, e.g.

.. code-block:: none
set PATH=c:\Python37;c:\Python37\Scripts;%PATH%
* Install ``pip`` if not already included: https://pip.pypa.io/en/stable/installing/

* Install the Python connector from the `latest release <https://github.com/SAP/PyRFC/releases/latest>`_

.. code-block:: sh
wget https://github.com/SAP/PyRFC/releases/download/2.0.0/pyrfc-2.0.0-cp38-cp38-win_amd64.whl
pip install pyrfc-1.9.97-cp37-cp37m-macosx_10_14_x86_64.whl
Run ``python`` and type ``from pyrfc import *``. If this finishes silently, without oputput, the installation was successful.

Please look up the correct wheel name, depending on your platform and Python version.

* Run ``python`` and type ``from pyrfc import *``. If this finishes silently, without oputput, the installation was successful.

Linux
-----

.. _`install-python-linux`:

* Install Python 3

* Install ``pip`` if not already included: https://pip.pypa.io/en/stable/installing/

* Install the Python connector from the `latest release <https://github.com/SAP/PyRFC/releases/latest>`_

.. code-block:: sh
wget https://github.com/SAP/PyRFC/releases/download/2.0.0/pyrfc-2.0.0-cp38-cp38-linux_x86_64.whl
pip install pyrfc-1.9.94-cp37-cp37m-linux_x86_64.whl
Please look up the correct wheel name, depending on your platform and Python version.

* Run ``python`` and type ``from pyrfc import *``. If this finishes silently, without oputput, the installation was successful.
Using virtual environments you can isolate Python/PyRFC projects, working without administrator privileges.

macOS
-----

.. _`install-python-macOS`:

The macOS system version of Python is usually the older one and using wirtual environments,
The macOS system version of Python is usually the older one. Using wirtual environments,
like `pyenv <https://github.com/pyenv/pyenv>`_ for example, is recommended:

.. code-block:: sh
Expand Down
15 changes: 5 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"

# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
[project]
name = "xtest_sapnwrfc"
version = "0.0.14"
name = "pyrfc"
version = "2.8.3"
readme = "README.md"
license = { file = "LICENSES/Apache-2.0.txt" }
description = "Python bindings for SAP NetWeaver RFC SDK"
Expand Down Expand Up @@ -42,18 +42,13 @@ max-line-length = 148

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = false
#exclude-package-data = {"*" = ["*.cpp", "*.html", "*.pyx", "*.pxd"]}
#license-files=["LICENSES/*.txt"]
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"]
include = ["pyrfc"]

[tool.setuptools.dynamic]
readme = {file = "README.md"}
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import inspect
import sys
import os
from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension

PACKAGE_NAME = "xtest_sapnwrfc"
PACKAGE_NAME = "pyrfc"
MODULE_NAME = "_cyrfc"

BUILD_CYTHON = bool(os.getenv("PYRFC_BUILD_CYTHON")) or sys.platform.startswith("linux")
Expand Down Expand Up @@ -184,12 +184,9 @@
setup(
name=PACKAGE_NAME,
# install_requires=["setuptools"],
# zip_safe = False,
# packages=find_packages(where="src", exclude=["*.cpp", "*.pxd", "*.html"]),
# package_dir={"": "src"},
cmdclass=CMDCLASS, # type: ignore
ext_modules=cythonize(PYRFC_EXT, annotate=True, compiler_directives={'language_level' : "3"}) # type: ignore
ext_modules=cythonize(PYRFC_EXT, annotate=True, compiler_directives={"language_level": "3"}) # type: ignore
if BUILD_CYTHON
else [PYRFC_EXT], # type: ignore
test_suite=MODULE_NAME,
)
)
2 changes: 1 addition & 1 deletion src/xtest_sapnwrfc/__init__.py → src/pyrfc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import importlib.metadata
import os

__version__ = importlib.metadata.version("xtest_sapnwrfc")
__version__ = importlib.metadata.version("pyrfc")
__version_info__ = tuple(__version__.split("."))

if os.name == "nt":
Expand Down
Loading

0 comments on commit 5b09879

Please sign in to comment.