Skip to content

Commit 9ece735

Browse files
authored
Remove dephell and replace it with poetry (#10)
- Dephell is not maintained anymore, so we can't rely on it - We now use a bit hacky method to generate the setup.py by building the package with poetry and extracting the setup.py from the package (as we did it in the https://github.com/exasol/integration-test-docker-environment) - We used Dephell also for running tests, this is now done by poetry
1 parent 1cbd3a8 commit 9ece735

File tree

5 files changed

+68
-63
lines changed

5 files changed

+68
-63
lines changed

.github/workflows/check_setup_py.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ jobs:
1515
- uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}
18-
- name: Run convert
19-
uses: dephell/dephell_action@master
20-
with:
21-
dephell-env: convert
18+
- uses: abatilo/actions-poetry@v2.0.0
19+
- name: Run packaging update
20+
run: bash githooks/update_setup_py.sh
2221
- name: Show changes on working copy
2322
run: git status --porcelain=v1 -uno
2423
- name: Show diff on working copy
2524
run: git diff
2625
- name: Check if setup.py changed
2726
run: |
28-
[ -z "$(git status --porcelain=v1 -uno 2>/dev/null)" ]
27+
[ -z "$(git status --porcelain=v1 -uno 2>/dev/null)" ]
28+
- name: Check if setup.py works
29+
run: pip install .

.github/workflows/pytest.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
- uses: actions/setup-python@v2
1616
with:
1717
python-version: ${{ matrix.python-version }}
18+
- name: Install Poetry
19+
uses: abatilo/actions-poetry@v2.0.0
20+
- name: Install dependencies
21+
run: poetry install
1822
- name: Run pytest
19-
uses: dephell/dephell_action@master
20-
with:
21-
dephell-env: pytest
23+
run: poetry run python3 -m pytest

githooks/update_setup_py.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,38 @@ green='\033[0;32m'
88
no_color='\033[0m'
99
grey='\033[0;90m'
1010

11-
echo -e "Update setup.py with dephell convert ${grey}(pre-commit hook)${no_color} "
12-
1311
# Jump to the current project's root directory (the one containing
1412
# .git/)
15-
ROOT_DIR=$(git rev-parse --show-cdup)
13+
ROOT_DIR=$(git rev-parse --show-toplevel || echo)
14+
NO_GIT=FALSE
15+
if [ -z "$ROOT_DIR" ]
16+
then
17+
echo "Did not found git repository, using '$PWD' as ROOT_DIR"
18+
NO_GIT=TRUE
19+
ROOT_DIR=$PWD
20+
fi
21+
1622

1723
pushd "$ROOT_DIR" > /dev/null
1824

19-
dephell venv run --env convert
20-
git add setup.py README.rst
25+
echo -e "Generate setup.py ${grey}(pre-commit hook)${no_color}"
26+
if [ -d "dist" ]
27+
then
28+
rm -r "dist"
29+
fi
30+
poetry build > /dev/null
31+
pushd dist > /dev/null
32+
tar_file=$(ls *.tar.gz)
33+
extracted_dir=${tar_file%.tar.gz}
34+
tar -xf $tar_file
35+
cp "$extracted_dir/setup.py" ../setup.py
36+
rm -r "$extracted_dir"
37+
popd > /dev/null
38+
39+
if [ "$NO_GIT" == "FALSE" ]
40+
then
41+
echo -e "Add generated files ${grey}(pre-commit hook)${no_color}"
42+
git add setup.py
43+
fi
2144

2245
popd > /dev/null

pyproject.toml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,3 @@ dill = "^0.3.2"
2525
pytest = "^6.1.1"
2626
pytest-cov = "^2.10.1"
2727

28-
[tool.dephell.main]
29-
from = {format = "poetry", path = "pyproject.toml"}
30-
to = {format = "setuppy", path = "setup.py"}
31-
32-
[tool.dephell.pytest]
33-
from = {format = "poetry", path = "pyproject.toml"}
34-
command = "pytest"
35-
36-
[tool.dephell.convert]
37-
from = {format = "poetry", path = "pyproject.toml"}
38-
command = "dephell deps convert"

setup.py

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,30 @@
1-
21
# -*- coding: utf-8 -*-
3-
4-
# DO NOT EDIT THIS FILE!
5-
# This file has been autogenerated by dephell <3
6-
# https://github.com/dephell/dephell
7-
8-
try:
9-
from setuptools import setup
10-
except ImportError:
11-
from distutils.core import setup
12-
13-
14-
import os.path
15-
16-
readme = ''
17-
here = os.path.abspath(os.path.dirname(__file__))
18-
readme_path = os.path.join(here, 'README.rst')
19-
if os.path.exists(readme_path):
20-
with open(readme_path, 'rb') as stream:
21-
readme = stream.read().decode('utf8')
22-
23-
24-
setup(
25-
long_description=readme,
26-
name='exasol-udf-mock-python',
27-
version='0.1.0',
28-
description='Mocking framework for Exasol Python UDFs',
29-
python_requires='>=3.6.1',
30-
project_urls={"homepage": "https://github.com/exasol/udf-mock-python", "repository": "https://github.com/exasol/udf-mock-python"},
31-
author='Torsten Kilias',
32-
author_email='torsten.kilias@exasol.com',
33-
license='MIT',
34-
keywords='exasol udf mock testing',
35-
packages=['exasol_udf_mock_python'],
36-
package_dir={"": "."},
37-
package_data={},
38-
install_requires=['dill==0.*,>=0.3.2', 'pandas==1.*,>=1.1.3'],
39-
extras_require={"dev": ["pytest==6.*,>=6.1.1", "pytest-cov==2.*,>=2.10.1"]},
40-
)
2+
from setuptools import setup
3+
4+
packages = \
5+
['exasol_udf_mock_python']
6+
7+
package_data = \
8+
{'': ['*']}
9+
10+
install_requires = \
11+
['dill>=0.3.2,<0.4.0', 'pandas>=1.1.3,<2.0.0']
12+
13+
setup_kwargs = {
14+
'name': 'exasol-udf-mock-python',
15+
'version': '0.1.0',
16+
'description': 'Mocking framework for Exasol Python UDFs',
17+
'long_description': '# UDF Mock for Python\n\nThis projects provides a mock runner for Python3 UDFs which allows you\nto test your UDFs locally without a database.\n\n**Note:** This project is in a very early development phase.\nPlease, be aware that the behavior of the mock runner doesn\'t perfectly\nreflect the behaviors of the UDFs inside the database and that the interface still can change.\nIn any case, you need to verify your UDFs with integrations test inside the database.\n\n## Getting started\n\n### Installing via pip\n```\npip install git+https://github.com/exasol/udf-mock-python.git@master\n```\n\n### Installing via poetry\nAdd it to your `tool.poetry.dependencies` or `tool.poetry.dev-dependencies`\n\n```\n[tool.poetry.dev-dependencies]\nexasol-udf-mock-python = { git = "https://github.com/exasol/udf-mock-python.git", branch = "master" }\n...\n```\n\n### How to use the Mock\n\nThe mock runner runs your python UDF in a python environment in which\nno external variables, functions or classes are visble.\nThis means in practice, you can only use things you defined inside your\nUDF and what gets provided by the UDF frameworks,\nsuch as exa.meta and the context for the run function.\nThis includes imports, variables, functions, classes and so on.\n\nYou define a UDF in this framework within in a wrapper function.\nThis wrapper function then contains all necessary imports, functions,\nvariables and classes.\nYou then handover the wrapper function to the `UDFMockExecutor`\nwhich runs the UDF inside if the isolated python environment.\nThe following example shows, how you use this framework:\nThe following example shows the general setup for a test with the Mock:\n\n```\ndef udf_wrapper():\n\n def run(ctx):\n return ctx.t1+1, ctx.t2+1.1, ctx.t3+"1"\n\nexecutor = UDFMockExecutor()\nmeta = MockMetaData(\n script_code_wrapper_function=udf_wrapper,\n input_type="SCALAR",\n input_columns=[Column("t1", int, "INTEGER"),\n Column("t2", float, "FLOAT"),\n Column("t3", str, "VARCHAR(20000)")],\n output_type="RETURNS",\n output_columns=[Column("t1", int, "INTEGER"),\n Column("t2", float, "FLOAT"),\n Column("t3", str, "VARCHAR(20000)")]\n)\nexa = MockExaEnvironment(meta)\nresult = executor.run([Group([(1,1.0,"1"), (5,5.0,"5"), (6,6.0,"6")])], exa)\n```\n\n**Checkout the [tests](tests) for more information about, how to use the Mock.**\n\n## Limitations or missing features\n\nSome of the following limitations are fundamental, other are missing\nfeature and might get removed by later releases:\n\n- Data type checks for outputs are more strict as in real UDFs\n- No support for Import or Export Specification or Virtual Schema adapter\n- No support for dynamic input and output parameters\n- No support for exa.import_script\n- No BucketFS\n- Execution is not isolated in a container\n - Can access and manipulate the file system of the system running the Mock\n - UDF inside of the database only can write /tmp to tmp and\n only see the file system of the script-language container and the mounted bucketfs\n - Can use all python package available in the system running the Mock\n - If you use package which are currently not available in the script-language containers,\n you need create your own container for testing inside of the database\n - Does not emulate the ressource limitations which get a applied in the database\n- Only one instance of the UDF gets executed\n- No support for Python2, because Python2 is officially End of Life\n',
18+
'author': 'Torsten Kilias',
19+
'author_email': 'torsten.kilias@exasol.com',
20+
'maintainer': None,
21+
'maintainer_email': None,
22+
'url': 'https://github.com/exasol/udf-mock-python',
23+
'packages': packages,
24+
'package_data': package_data,
25+
'install_requires': install_requires,
26+
'python_requires': '>=3.6.1',
27+
}
28+
29+
30+
setup(**setup_kwargs)

0 commit comments

Comments
 (0)