From 07a3903fda0178f7685413cdf33b6005d60c354b Mon Sep 17 00:00:00 2001 From: Ben Hutcheson Date: Sat, 23 Apr 2022 05:58:11 +1000 Subject: [PATCH] fix(plc4py): change from using poetry to setuptools * Created setup.py to use with pip-tools * Updated plc4py/pom.xml to use pipenv * Replace default topic in setup.py * Remove Pipfile from being tracked * Update pom.xml to use venv to build * Change dist folder to target * Updated venv bin directory detection * Removed poetry dependency check * Add maven clean plugin to plc4py * maven clean plugin version property * Updated version numbe to 0.10a0. PEP440 Co-authored-by: hutcheb --- .gitignore | 2 + pom.xml | 8 +- sandbox/plc4py/pom.xml | 95 +++++++++++++++++++++--- sandbox/plc4py/pyproject.toml | 44 ----------- sandbox/plc4py/setup.cfg | 22 ++++++ sandbox/plc4py/setup.py | 57 ++++++++++++++ src/main/script/prerequisiteCheck.groovy | 34 +-------- 7 files changed, 174 insertions(+), 88 deletions(-) delete mode 100644 sandbox/plc4py/pyproject.toml create mode 100644 sandbox/plc4py/setup.cfg create mode 100644 sandbox/plc4py/setup.py diff --git a/.gitignore b/.gitignore index 9936559c313..46be4cf264a 100644 --- a/.gitignore +++ b/.gitignore @@ -99,6 +99,8 @@ plc4py/venv/ **/__pycache__/**/* /plc4cpp/.vscode/ipch *.egg-info +**/Pipfile.lock +**/Pipfile # Exclude gradle stuff .gradle diff --git a/pom.xml b/pom.xml index 0be04a4f275..7b7d9f054ae 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,7 @@ 5.8.2 1.8.2 1.2.10 + 3.2.0 0.6.3 4.4.0 4.1.75.Final @@ -791,7 +792,8 @@ **/.pytest_cache/** **/.mypy_cache/** - **/poetry.lock + **/Pipfile + **/Pipfile.lock **/.project @@ -1601,6 +1603,7 @@ https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-linux-x86_64.tar.gz ${project.build.directory}/cmake-${cmake-version}-linux-x86_64/bin/ Unix Makefiles + venv/bin/ @@ -1617,6 +1620,7 @@ https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-linux-${os.arch}.tar.gz ${project.build.directory}/cmake-${cmake-version}-linux-${os.arch}/bin/ Unix Makefiles + venv/bin/ @@ -1633,6 +1637,7 @@ https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-macos-universal.tar.gz ${project.build.directory}/cmake-${cmake-version}-macos-universal/CMake.app/Contents/bin Unix Makefiles + venv/bin/ @@ -1649,6 +1654,7 @@ https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-windows-x86_64.zip ${project.build.directory}/cmake-${cmake-version}-windows-x86_64/bin MinGW Makefiles + venv/Scripts/ diff --git a/sandbox/plc4py/pom.xml b/sandbox/plc4py/pom.xml index 65d7eb8c7a8..2ddcda1dfe0 100644 --- a/sandbox/plc4py/pom.xml +++ b/sandbox/plc4py/pom.xml @@ -78,6 +78,22 @@ org.codehaus.mojo exec-maven-plugin + + python-venv + compile + + exec + + + python + + -m + venv + ./venv + + + + python-install compile @@ -85,37 +101,96 @@ exec - poetry + ${python.venv.bin}pip install + . - - - - org.codehaus.mojo - exec-maven-plugin - - python-test + python-test-compile test-compile exec - poetry + ${python.venv.bin}pip - run + install + .[dev] + + + + + + python-test + test + + exec + + + ${python.venv.bin}python + + -m pytest -v tests + + + python-package + package + + exec + + + ${python.venv.bin}pip + + wheel + . + -w + dist + --no-deps + + + + + + + maven-clean-plugin + ${maven.clean.plugin.version} + + + + venv + false + + + dist + false + + + .pytest_cache + false + + + plc4py.egg-info + false + + + build + false + + + + + diff --git a/sandbox/plc4py/pyproject.toml b/sandbox/plc4py/pyproject.toml deleted file mode 100644 index 49167d1b9dd..00000000000 --- a/sandbox/plc4py/pyproject.toml +++ /dev/null @@ -1,44 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -[tool.poetry] -name = "plc4py" -version = "0.1.0" -description = "Implementation of the Apache PLC4X project for Python" -license = "Apache-2.0" -authors = ["Apache PLC4X "] - -[tool.poetry.dependencies] -python = "^3.8" -pytest-asyncio = "^0.18.3" - -[tool.poetry.dev-dependencies] -pre-commit = "^2.6.0" -pytest-mock = "^3.3.1" -mock = "^4.0.2" -mypy = "^0.942" -flake8 = "^4.0.1" - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.masonry.api" - -[tool.pytest.ini_options] -asyncio_mode = "strict" - -[tool.poetry.plugins."plc4py.drivers"] -"modbus" = "plc4py.drivers.modbus.ModbusConnection:ModbusConnectionLoader" diff --git a/sandbox/plc4py/setup.cfg b/sandbox/plc4py/setup.cfg new file mode 100644 index 00000000000..3bc8d916ade --- /dev/null +++ b/sandbox/plc4py/setup.cfg @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +[tool:pytest] +testpaths = tests +asyncio_mode=auto \ No newline at end of file diff --git a/sandbox/plc4py/setup.py b/sandbox/plc4py/setup.py new file mode 100644 index 00000000000..9bb84aa5129 --- /dev/null +++ b/sandbox/plc4py/setup.py @@ -0,0 +1,57 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from setuptools import setup, find_packages + +setup( + name="plc4py", + version="0.10a0", + description="Plc4py The Python Industrial IOT Adapter", + classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: Apache 2.0 License", + "Programming Language :: Python :: 3.8", + "Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator", + ], + keywords="modbus plc4x", + url="https://plc4x.apache.org", + author='"Apache PLC4X <>"', + author_email="dev@plc4x.apache.org", + license="Apache 2.0", + packages=find_packages(include=["plc4py", "plc4py.*"]), + install_requires=[ + "pytest-asyncio>=0.18.3", + "pip-tools", + ], + extras_require={ + "dev": [ + "requires", + "pre-commit>=2.6.0", + "pytest-mock>=3.3.1", + "mock>=4.0.2", + "mypy>=0.942", + "flake8>=4.0.1", + ] + }, + entry_points={ + "plc4py.drivers": [ + "modbus = plc4py.drivers.modbus.ModbusConnection:ModbusConnectionLoader" + ] + }, +) diff --git a/src/main/script/prerequisiteCheck.groovy b/src/main/script/prerequisiteCheck.groovy index e9d2098937b..c87b44c2658 100644 --- a/src/main/script/prerequisiteCheck.groovy +++ b/src/main/script/prerequisiteCheck.groovy @@ -319,38 +319,7 @@ def checkPython() { Matcher matcher = extractVersion(stdOut + stdErr) if (matcher.size() > 0) { def curVersion = matcher[0][1] - def result = checkVersionAtLeast(curVersion, "2.7.0") - if (!result) { - allConditionsMet = false - } - } else { - println "missing (Please install at least version 3.6.0)" - allConditionsMet = false - } - } catch (Exception e) { - println "missing" - allConditionsMet = false - } -} - -def checkPoetry(boolean isWin) { - print "Detecting Poetry version: " - try { - def process - if (isWin) { - process = ("poetry.bat --version").execute() - } else { - process = ("poetry --version").execute() - } - - def stdOut = new StringBuilder() - def stdErr = new StringBuilder() - process.consumeProcessOutput(stdOut, stdErr) - process.waitForOrKill(500) - Matcher matcher = extractVersion(stdOut + stdErr) - if (matcher.size() > 0) { - def curVersion = matcher[0][1] - def result = checkVersionAtLeast(curVersion, "1.0.0") + def result = checkVersionAtLeast(curVersion, "3.6.0") if (!result) { allConditionsMet = false } @@ -593,7 +562,6 @@ if (cppEnabled) { if (pythonEnabled) { checkPython() - checkPoetry(os == "windows") checkSetupTools() }