Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dlt-pendulum #29013

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff -run pendulum-3.0.2/pyproject.toml pendulum-3.0.2-patch/pyproject.toml
--- pendulum-3.0.2/pyproject.toml 2023-12-16 14:06:01.000000000 -0700
+++ pendulum-3.0.2-patch/pyproject.toml 2023-12-17 18:24:01.209934743 -0700
@@ -20,7 +20,6 @@

dependencies = [
"python-dateutil>=2.6",
- "tzdata>=2020.1",
"cffi>=1.17",
20 changes: 20 additions & 0 deletions recipes/dlt-pendulum/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2015 Sébastien Eustace

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 7 additions & 0 deletions recipes/dlt-pendulum/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set PENDULUM_EXTENSIONS=1

maturin build -vv -j %CPU_COUNT% --release --strip --manylinux off --interpreter=%PYTHON%

FOR /F "delims=" %%i IN ('dir /s /b rust\target\wheels\*.whl') DO set dlt_pendulum_wheel=%%i

%PYTHON% -m pip install --no-deps %dlt_pendulum_wheel% -vv
79 changes: 79 additions & 0 deletions recipes/dlt-pendulum/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

set -ex

export PENDULUM_EXTENSIONS=1

# closely following https://github.com/conda-forge/dask-sql-feedstock/blob/8cf4fd16d5e25c57f52a0162d55f795ddd995307/recipe/build.sh

# See https://github.com/conda-forge/rust-feedstock/blob/master/recipe/build.sh for cc env explanation
if [ "$c_compiler" = gcc ] ; then
case "$target_platform" in
linux-64) rust_env_arch=X86_64_UNKNOWN_LINUX_GNU ;;
linux-aarch64) rust_env_arch=AARCH64_UNKNOWN_LINUX_GNU ;;
linux-ppc64le) rust_env_arch=POWERPC64LE_UNKNOWN_LINUX_GNU ;;
*) echo "unknown target_platform $target_platform" ; exit 1 ;;
esac

export CARGO_TARGET_${rust_env_arch}_LINKER=$CC
fi

declare -a _xtra_maturin_args

mkdir -p $SRC_DIR/.cargo

if [ "$target_platform" = "linux-ppc64le" ] ; then

# following https://github.com/conda-forge/watchfiles-feedstock/blob/649985fc7b59232b7fb23f188a7ac4d1b17c6111/recipe/meta.yaml#L17
# PyPy has weird sysconfigdata name
rm -f $PREFIX/lib/pypy$PY_VER/_sysconfigdata.py

elif [ "$target_platform" = "osx-64" ] ; then
cat <<EOF >> $SRC_DIR/.cargo/config
[target.x86_64-apple-darwin]
linker = "$CC"
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

EOF

_xtra_maturin_args+=(--target=x86_64-apple-darwin)

elif [ "$target_platform" = "osx-arm64" ] ; then
cat <<EOF >> $SRC_DIR/.cargo/config
# Required for intermediate codegen stuff
[target.x86_64-apple-darwin]
linker = "$CC_FOR_BUILD"

# Required for final binary artifacts for target
[target.aarch64-apple-darwin]
linker = "$CC"
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

EOF
_xtra_maturin_args+=(--target=aarch64-apple-darwin)

# This variable must be set to the directory containing the target's libpython DSO
export PYO3_CROSS_LIB_DIR=$PREFIX/lib

# xref: https://github.com/PyO3/pyo3/commit/7beb2720
export PYO3_PYTHON_VERSION=${PY_VER}

# xref: https://github.com/conda-forge/python-feedstock/issues/621
sed -i.bak 's,aarch64,arm64,g' $BUILD_PREFIX/venv/lib/os-patch.py
sed -i.bak 's,aarch64,arm64,g' $BUILD_PREFIX/venv/lib/platform-patch.py

elif [ "$target_platform" = "linux-ppc64le" ] ; then
# as above
export PYO3_CROSS_LIB_DIR=$PREFIX/lib
export PYO3_PYTHON_VERSION=${PY_VER}
fi

maturin build -vv -j "${CPU_COUNT}" --release --strip --manylinux off --interpreter="${PYTHON}" "${_xtra_maturin_args[@]}"

"${PYTHON}" -m pip install $SRC_DIR/rust/target/wheels/dlt_pendulum*.whl --no-deps -vv
59 changes: 59 additions & 0 deletions recipes/dlt-pendulum/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{% set name = "dlt-pendulum" %}
{% set version = "3.0.2" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://github.com/dlt-hub/pendulum/archive/{{ version }}.tar.gz
sha256: 9a0225a8e97399ad7c3930856d581093b65e36bb27c85c0da5a2575ddbaa9248
patches:
- 0001-remove-tzdata-dep-for-pip-check.patch

build:
number: 0

requirements:
build:
- python # [build_platform != target_platform]
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- maturin >=1.0,<2.0 # [build_platform != target_platform]
- {{ compiler('c') }}
- {{ stdlib('c') }}
- {{ compiler('rust') }}
host:
- python
- maturin >=1.0,<2.0
- poetry-core
- pip
run:
- python
- python-dateutil >=2.6
- tzdata >=2020.1
- cffi >=1.17

test:
requires:
- pip
commands:
- pip check
# make sure the extensions actually built (this might be fragile since these modules are private)
- python -c "from pendulum._pendulum import parse_iso8601" # [python_impl == 'cpython']
- python -c "from pendulum._helpers import days_in_year" # [python_impl == 'cpython']
imports:
- pendulum

about:
home: https://github.com/dlt-hub/pendulum
license: MIT
license_family: MIT
license_file: LICENSE
summary: Python datetimes made easy
description: |
Drop-in replacement for the standard datetime class.
It behaves exactly like it but with many improvements.

extra:
recipe-maintainers:
- rxm7706