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

Fix cython3 build #11

Merged
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
41 changes: 41 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
pull_request:

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install package
run: |
python setup.py install
- name: Test with pytest
run: |
pytest

13 changes: 5 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.imgmath',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages']
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.imgmath',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
Expand Down Expand Up @@ -171,6 +171,3 @@
author, 'Pytetgen', 'One line description of project.',
'Miscellaneous'),
]



4 changes: 3 additions & 1 deletion pytetgen/pytetgen.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!python
# cython: language_level=3
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# distutils: language=c++
Expand Down Expand Up @@ -354,7 +356,7 @@ cdef class Tetgenio:
def pointlist(self,val):
flatval = np.ascontiguousarray(val.flatten())
cdef int npoints = flatval.shape[0]
self.c_tetgenio.numberofpoints = npoints / <int>3
self.c_tetgenio.numberofpoints = npoints // <int>3
cdef int size = 3*sizeof(double)*self.c_tetgenio.numberofpoints
cdef np.float64_t[:] view = flatval
try:
Expand Down
15 changes: 15 additions & 0 deletions pytetgen/tests/test_simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
A simple test for pytetgen
"""
def test_simple():
import pytetgen
import numpy as np
import scipy.spatial
N=100
np.random.seed(1)
a=np.random.random(3*N).reshape(N,3)
del1=pytetgen.Delaunay(a)
del2=scipy.spatial.Delaunay(a)
T1=np.sort(np.sort(del1.simplices,axis=1),axis=0)
T2=np.sort(np.sort(del2.simplices,axis=1),axis=0)
assert(np.all(T1==T2))
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Cython
numpy
scipy
84 changes: 38 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
import numpy as np
import os
import os
import codecs

# Get the long description from the README file
Expand All @@ -14,47 +13,40 @@
with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()




setup( name = 'pytetgen',
packages=['pytetgen'],
version = '0.2.2',
description = 'wrapper for the tetgen mesh generator',
long_description=long_description,
author = 'Marcello Sega',
author_email = '[email protected]',
url='https://github.com/Marcello-Sega/pytetgen',
license='AGPLv3',
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',

# Indicate who your project is intended for
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Software Development :: Libraries :: Python Modules',

# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',

# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
],
ext_modules=[
Extension('pytetgen',
sources=['pytetgen/tetgen.cxx','pytetgen/predicates.cxx','pytetgen/pytetgen.pyx'],
compiler_directives={'language_level':3},
include_dirs=[np.get_include()],
extra_compile_args=['-g0','-O0','-DTETLIBRARY'],
language='c++'),
],
cmdclass = {'build_ext': build_ext},
install_requires=['triangle>=20200424'],
)
setup(name='pytetgen',
packages=['pytetgen'],
version='0.2.2',
description='wrapper for the tetgen mesh generator',
long_description=long_description,
author='Marcello Sega',
author_email='[email protected]',
url='https://github.com/Marcello-Sega/pytetgen',
license='AGPLv3',
classifiers=[
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 4 - Beta',
# Indicate who your project is intended for
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Topic :: Scientific/Engineering :: Chemistry',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Software Development :: Libraries :: Python Modules',
# Pick your license as you wish (should match "license" above)
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python :: 3',
],
ext_modules=[
Extension('pytetgen',
sources=['pytetgen/tetgen.cxx', 'pytetgen/predicates.cxx', 'pytetgen/pytetgen.pyx'],
compiler_directives={'language_level': 3},
include_dirs=[np.get_include()],
extra_compile_args=['-g0', '-O0', '-DTETLIBRARY'],
language='c++'),
],
cmdclass={'build_ext': build_ext},
install_requires=['triangle>=20200424'])