Skip to content

Conversation

william-silversmith
Copy link
Contributor

Fixes the syntax error, cythonizes dynamically (may make this run on more platforms), sets language level to 3 (Python 2 is EOL for years now) to remove a warning, and adds license and classifiers so PyPI can categorize it better.

Loads numpy dynamically so it won't crash if numpy was installed at the same time as the setup call is run.

Uses numpy for installation, but oldest-supported-numpy for isolated compilation for py38 via pyproject.toml

Adds MANIFEST.in to ensure sdist includes source files, LICENSE, etc.

Resolves #233

This was moved from #236

@lindstro lindstro mentioned this pull request Oct 29, 2024
@da-wad
Copy link
Contributor

da-wad commented Nov 25, 2024

Let me know when you merge this @lindstro ?

@lindstro
Copy link
Member

LGTM

@lindstro lindstro merged commit 01506c8 into LLNL:develop Nov 25, 2024
@lindstro
Copy link
Member

@da-wad #237 has been merged.

Comment on lines +3 to +7
class NumpyImport:
def __repr__(self):
import numpy as np

return np.get_include()
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).

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syntax error in setup.py
4 participants