Skip to content
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
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include python/zfpy.pxd
include python/zfpy.pyx
recursive-include include *.h
recursive-include src *.c *.h
include LICENSE
include pyproject.toml
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = [
"setuptools",
"wheel",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wheel is from some outdated documentation; you probably don't need it for your build. It should be automatically installed where necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@william-silversmith Here's a second question that you may be able to answer. I unfortunately have minimal knowledge of Python, though I suspect it is related to our zfpy-wheels repo for building and uploading wheels to PyPI.

"cython",
"oldest-supported-numpy; python_version<'3.9'",
'numpy; python_version>="3.9"',
]
2 changes: 2 additions & 0 deletions python/zfpy.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# cython: language_level=3

import cython
cimport libc.stdint as stdint
from libc.stddef cimport ptrdiff_t
Expand Down
2 changes: 2 additions & 0 deletions python/zfpy.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# cython: language_level=3

import sys
import operator
import functools
Expand Down
41 changes: 37 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
from setuptools import setup, Extension
import numpy as np

class NumpyImport:
def __repr__(self):
import numpy as np

return np.get_include()
Comment on lines +3 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point of this class. I think it's meant to defer the import of numpy, but you call str(NumpyImport()) in the arguments to setup, so it will be evaluated and import numpy at startup anyway. Was this change made redundant by adding pyproject.toml with build system requires?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@william-silversmith Can you please address these questions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the point of the script is to delay the import of numpy. Originally, importing numpy concurrently with installation would cause the setup script to crash as numpy would not be found. This was a solution I found on StackOverflow.

Later on, new python versions would not properly render the repr, so it was necessary to add str to get it to evaluate properly, but you might be right that it has rendered the delay mechanism superfluous.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@william-silversmith Thanks for explaining (and for contributing this solution).


__fspath__ = __repr__

setup(
name="zfpy",
setup_requires=["numpy", "cython"],
version="1.0.1",
author="Peter Lindstrom, Danielle Asher",
author_email="zfp@llnl.gov",
url="https://zfp.llnl.gov",
license="License :: OSI Approved :: BSD License",
description="zfp compression in Python",
long_description="zfp is a compressed format for representing multidimensional floating-point and integer arrays. zfp provides compressed-array classes that support high throughput read and write random access to individual array elements. zfp also supports serial and parallel compression of whole arrays using both lossless and lossy compression with error tolerances. zfp is primarily written in C and C++ but also includes Python and Fortran bindings.",
ext_modules=[Extension("zfpy", ["build/python/zfpy.c"],
include_dirs=["include", np.get_include()],
libraries=["zfp"], library_dirs=["build/lib64", "build/lib/Release"]), language_level = "3"]
ext_modules=[
Extension(
"zfpy",
sources=["python/zfpy.pyx"],
include_dirs=["include", str(NumpyImport())],
libraries=["zfp"],
library_dirs=["build/lib64", "build/lib/Release"],
language_level=3,
lanugage="c",
),
],
classifiers=[
"Intended Audience :: Developers",
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: System :: Archiving :: Compression",
"Operating System :: POSIX",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows :: Windows 10",
],
)