Skip to content

Commit

Permalink
incomplete proof of concept for NixOS/nixpkgs#255262
Browse files Browse the repository at this point in the history
Signed-off-by: lucasew <lucas59356@gmail.com>
  • Loading branch information
lucasew committed Sep 16, 2023
1 parent 2158df8 commit 1907a68
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions nix/pytest-circular-import/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
2 changes: 2 additions & 0 deletions nix/pytest-circular-import/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.python3Packages.callPackage ./package.nix { }
1 change: 1 addition & 0 deletions nix/pytest-circular-import/demo_cython_pytest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import native_sum
Empty file.
9 changes: 9 additions & 0 deletions nix/pytest-circular-import/demo_cython_pytest/module.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#cython: language_level=3

cimport cython

def native_sum(x, y):
return cy_sum(x, y)

cdef int cy_sum(int x, int y):
return x + y
4 changes: 4 additions & 0 deletions nix/pytest-circular-import/demo_cython_pytest/module_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from demo_cython_pytest import native_sum

def test_module():
assert native_sum(2, 2) == 4
19 changes: 19 additions & 0 deletions nix/pytest-circular-import/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ buildPythonPackage
, pytestCheckHook
, cython
, python
}:

buildPythonPackage {
pname = "demo_cython_pytest";
version = "0.0.1";

src = ./.;

pythonImportsCheck = [ "demo_cython_pytest.module.native_sum" ];

nativeBuildInputs = [
# pytestCheckHook
cython
];
}
31 changes: 31 additions & 0 deletions nix/pytest-circular-import/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from distutils.core import Extension
from setuptools import setup, find_packages
from Cython.Build import cythonize
from Cython.Distutils import build_ext
# from distutils.command.build_ext import build_ext


def ext_modules():
modules = []
includes = []
libraries = []
modules += cythonize(Extension(
"*",
["demo_cython_pytest/module.pyx"],
include_dirs=includes,
libraries=libraries
))
return modules

setup(
name="demo_cython_pytest",
version="0.0.1",
description="Circular imports?",
author="lucasew",
packages=["demo_cython_pytest"],
ext_modules=ext_modules(),
include_package_data=True,
cmdclass=dict(
build_ext=build_ext
)
)
6 changes: 6 additions & 0 deletions nix/pytest-circular-import/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
(pkgs.python3Packages.callPackage ./package.nix { })
];
}

0 comments on commit 1907a68

Please sign in to comment.