Skip to content

Commit

Permalink
devel/py-time-machine: Add new port
Browse files Browse the repository at this point in the history
time-machine, is intended to combine the advantages of freezegun and
libfaketime Python modules. It works without LD_PRELOAD but still mocks
the standard library functions everywhere they may be referenced.
It does so by modifying the built-in functions at the C level, to point
them through wrappers that return different values when mocking.
Normally in Python, built-in functions are immutable, but
time-machine overcomes this by using C code to replace their function
pointers.

https://github.com/adamchainz/time-machine
  • Loading branch information
nivit committed Jun 17, 2023
1 parent fec6169 commit aadc486
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions devel/Makefile
Expand Up @@ -5605,6 +5605,7 @@
SUBDIR += py-thrift
SUBDIR += py-thriftpy2
SUBDIR += py-tiamat
SUBDIR += py-time-machine
SUBDIR += py-timelib
SUBDIR += py-timeout-decorator
SUBDIR += py-tinyarray
Expand Down
26 changes: 26 additions & 0 deletions devel/py-time-machine/Makefile
@@ -0,0 +1,26 @@
PORTNAME= time-machine
DISTVERSION= 2.10.0
CATEGORIES= devel python
MASTER_SITES= PYPI
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
DISTNAME= ${PORTNAME:S/-/_/1}-${PORTVERSION}

MAINTAINER= nivit@FreeBSD.org
COMMENT= Travel through time in your Python tests
WWW= https://github.com/adamchainz/time-machine

LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE

BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}setuptools>=63.1.0:devel/py-setuptools@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}wheel>=0.40.0:devel/py-wheel@${PY_FLAVOR}
RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}dateutil>=2.8.2:devel/py-dateutil@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}six>=1.5:devel/py-six@${PY_FLAVOR}

USES= python
USE_PYTHON= autoplist pep517

post-install:
${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/_time_machine${PYTHON_EXT_SUFFIX}.so

.include <bsd.port.mk>
3 changes: 3 additions & 0 deletions devel/py-time-machine/distinfo
@@ -0,0 +1,3 @@
TIMESTAMP = 1686987050
SHA256 (time_machine-2.10.0.tar.gz) = 64fd89678cf589fc5554c311417128b2782222dd65f703bf248ef41541761da0
SIZE (time_machine-2.10.0.tar.gz) = 28249
7 changes: 7 additions & 0 deletions devel/py-time-machine/pkg-descr
@@ -0,0 +1,7 @@
time-machine is intended to combine the advantages of freezegun and libfaketime
Python modules. It works without LD_PRELOAD but still mocks the standard
library functions everywhere they may be referenced. It does so by modifying
the built-in functions at the C level, to point them through wrappers that
return different values when mocking. Normally in Python, built-in functions
are immutable, but time-machine overcomes this by using C code to replace their
function pointers.

0 comments on commit aadc486

Please sign in to comment.