Skip to content

Commit

Permalink
fix(plc4py): change from using poetry to setuptools
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
hutcheb and hutcheb authored Apr 22, 2022
1 parent 97c28ee commit 07a3903
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 88 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ plc4py/venv/
**/__pycache__/**/*
/plc4cpp/.vscode/ipch
*.egg-info
**/Pipfile.lock
**/Pipfile

# Exclude gradle stuff
.gradle
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<junit.platform.version>1.8.2</junit.platform.version>
<logback.version>1.2.10</logback.version>
<maven.clean.plugin.version>3.2.0</maven.clean.plugin.version>
<milo.version>0.6.3</milo.version>
<mockito.version>4.4.0</mockito.version>
<netty.version>4.1.75.Final</netty.version>
Expand Down Expand Up @@ -791,7 +792,8 @@
<!-- Python related files -->
<exclude>**/.pytest_cache/**</exclude>
<exclude>**/.mypy_cache/**</exclude>
<exclude>**/poetry.lock</exclude>
<exclude>**/Pipfile</exclude>
<exclude>**/Pipfile.lock</exclude>

<!-- Eclipse related files -->
<exclude>**/.project</exclude>
Expand Down Expand Up @@ -1601,6 +1603,7 @@
<cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-linux-x86_64.tar.gz</cmake.url>
<cmake.root>${project.build.directory}/cmake-${cmake-version}-linux-x86_64/bin/</cmake.root>
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
</properties>
</profile>
<profile>
Expand All @@ -1617,6 +1620,7 @@
<cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-linux-${os.arch}.tar.gz</cmake.url>
<cmake.root>${project.build.directory}/cmake-${cmake-version}-linux-${os.arch}/bin/</cmake.root>
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
</properties>
</profile>
<!-- Profile for mac (Self-Enabling) -->
Expand All @@ -1633,6 +1637,7 @@
<cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-macos-universal.tar.gz</cmake.url>
<cmake.root>${project.build.directory}/cmake-${cmake-version}-macos-universal/CMake.app/Contents/bin</cmake.root>
<cmake.generator>Unix Makefiles</cmake.generator>
<python.venv.bin>venv/bin/</python.venv.bin>
</properties>
</profile>
<!-- profile for windows (Self-Enabling) -->
Expand All @@ -1649,6 +1654,7 @@
<cmake.url>https://github.com/Kitware/CMake/releases/download/v${cmake-version}/cmake-${cmake-version}-windows-x86_64.zip</cmake.url>
<cmake.root>${project.build.directory}/cmake-${cmake-version}-windows-x86_64/bin</cmake.root>
<cmake.generator>MinGW Makefiles</cmake.generator>
<python.venv.bin>venv/Scripts/</python.venv.bin>
</properties>
</profile>

Expand Down
95 changes: 85 additions & 10 deletions sandbox/plc4py/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,119 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>python-venv</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>python</executable>
<arguments>
<argument>-m</argument>
<argument>venv</argument>
<argument> ./venv</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>python-install</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>poetry</executable>
<executable>${python.venv.bin}pip</executable>
<arguments>
<argument>install</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>python-test</id>
<id>python-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>poetry</executable>
<executable>${python.venv.bin}pip</executable>
<arguments>
<argument>run</argument>
<argument>install</argument>
<argument>.[dev]</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>python-test</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${python.venv.bin}python</executable>
<arguments>
<argument>-m</argument>
<argument>pytest</argument>
<argument>-v</argument>
<argument>tests</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>python-package</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${python.venv.bin}pip</executable>
<arguments>
<argument>wheel</argument>
<argument>.</argument>
<argument>-w</argument>
<argument>dist</argument>
<argument>--no-deps</argument>
</arguments>
</configuration>
</execution>

</executions>
</plugin>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.plugin.version}</version>
<configuration>
<filesets>
<fileset>
<directory>venv</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>dist</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>.pytest_cache</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>plc4py.egg-info</directory>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>build</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>

</plugins>
</build>

Expand Down
44 changes: 0 additions & 44 deletions sandbox/plc4py/pyproject.toml

This file was deleted.

22 changes: 22 additions & 0 deletions sandbox/plc4py/setup.cfg
Original file line number Diff line number Diff line change
@@ -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
57 changes: 57 additions & 0 deletions sandbox/plc4py/setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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"
]
},
)
34 changes: 1 addition & 33 deletions src/main/script/prerequisiteCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -593,7 +562,6 @@ if (cppEnabled) {

if (pythonEnabled) {
checkPython()
checkPoetry(os == "windows")
checkSetupTools()
}

Expand Down

0 comments on commit 07a3903

Please sign in to comment.