Skip to content

petsc, py-petsc4py: add v3.18.4, v3.18.5#36406

Merged
alalazo merged 3 commits intodevelopfrom
balay/petsc-3.18.5
Mar 27, 2023
Merged

petsc, py-petsc4py: add v3.18.4, v3.18.5#36406
alalazo merged 3 commits intodevelopfrom
balay/petsc-3.18.5

Conversation

@balay
Copy link
Copy Markdown
Contributor

@balay balay commented Mar 24, 2023

No description provided.


depends_on("py-cython", type="build", when="@main")
depends_on("py-cython@0.29.32:", when="^python@3.11: @3.19:", type="build")
depends_on("py-cython@0.24:", when="@3.19:", type="build")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As is, this says that only main depends on cython.

Copy link
Copy Markdown
Contributor Author

@balay balay Mar 24, 2023

Choose a reason for hiding this comment

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

Yes.

So I can add this change now - or later with the 3.19 release. [as it won't affect current 3.18 releases..]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I'm saying is that the 3.18 release already contains this constraint in setup.py, but we need to add it to the Spack package too.

Copy link
Copy Markdown
Contributor Author

@balay balay Mar 24, 2023

Choose a reason for hiding this comment

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

3.18 tarballs are prebuilt with cython - so there is no dependency on cython here [when spack builds petsc4py].

As noted - it was only required for @main

With petsc-3.19 - we are not including the prebuilt cython sources in the tarball - hence need this dependency for 3.19 and newer

So I would think that part of setup.py will be skipped in a spack build with petsc4py-3.18 tarballs

cc: @dalcinl to confirm.

Ref: (v3.18) setup.py:

# python-3.11+ requires cython 0.29.32+                                                                                                                                                                            
if pyver >= (3, 11):
  CYTHON = '0.29.32'
else:
  CYTHON = '0.24'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably rebuild cython sources even in older versions. This will be done automatically by adding a dependency on cython thanks to #35995. This maximizes the chances that the package will build for all versions of Python.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why don't you just use the latest Cython release 0.29.33 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a lower bound, so if a newer version is available it will use that. We want to keep the range of supported versions as wide as possible in case a different package in the DAG has different constraints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dalcinl thanks!

the suggested change is pushed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But I don't see cython source generated - even though CYTHON_FORCE_REGEN=1 is set

spack-build-out.txt
spack-build-env.txt

With cython - I would see:

running build_src
using Cython 0.29.32
cythonizing 'petsc4py/PETSc.pyx' -> 'petsc4py/PETSc.c'
running build_py
creating build

Here I'm seeing:

  running build
  running build_src
  running build_py
  creating build

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, @haampie any ideas?

Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

Confirmed the four version sha256.

tldahlgren
tldahlgren previously approved these changes Mar 24, 2023
@tldahlgren tldahlgren self-assigned this Mar 24, 2023
@dalcinl
Copy link
Copy Markdown

dalcinl commented Mar 25, 2023

Sorry, guys... Are you aware that regenerating Cython sources in old petsc4py releases will require "manual" step? See how it is done for mpi4py in conda-forge. Running that exact same line on petsc4py sources is the way to go.

PS: Sorry if you are aware of this, but looking at Spack's py-petsc4py/package.py, it is not obvious things are done the way it should be done.

@balay
Copy link
Copy Markdown
Contributor Author

balay commented Mar 25, 2023

> {{ PYTHON }} conf/cythonize.py

I'll defer the spack impl code for this to @adamjstewart

Perhaps this cython issue should be decoupled from this PR [and #36401 ] - this build change be applied to mpi4py,petsc4py,slepc4y in a separate PR

@adamjstewart
Copy link
Copy Markdown
Member

I'm fine with applying this in a separate PR. The code would look like:

python(join_path("conf", "cythonize.py"))

adamjstewart
adamjstewart previously approved these changes Mar 25, 2023
@balay
Copy link
Copy Markdown
Contributor Author

balay commented Mar 25, 2023

python(join_path("conf", "cythonize.py"))

Does it go into def build()?

What is the current default build command that it invokes? presumably I would have to replicate it in build()?

@balay
Copy link
Copy Markdown
Contributor Author

balay commented Mar 25, 2023

Ah - ok - I see it should be install(). Perhaps?

    def install(self, spec, prefix):
        with working_dir(self.build_directory):
            python(join_path("conf", "cythonize.py"))
            args = std_pip_args + ["--prefix=" + prefix, "."]
            pip(*args)

I now get:

==> py-petsc4py: Executing phase: 'install'
==> [2023-03-25-12:22:01.859652] '/opt/intel/oneapi/intelpython/python3.9/bin/python3.9' 'conf/cythonize.py'
==> [2023-03-25-12:22:09.924187] '/opt/intel/oneapi/intelpython/python3.9/bin/python3.9' '-m' 'pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/home/balay/spack/opt/spack/linux-fedora37-skylake/gcc-12.2.1/py-petsc4py-3.18.5-uy6i3q6kwn6bzmjnl2whreswqsgznxgk' '.'

Presumably its working?

@balay
Copy link
Copy Markdown
Contributor Author

balay commented Mar 25, 2023

pushed this change

else:
return self.stage.source_path

def install(self, spec, prefix):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would probably do this as:

@run_before("install")
def cythonize(self):
    python(join_path("conf", "cythonize.py"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! updated now.

@balay balay force-pushed the balay/petsc-3.18.5 branch from 746aca5 to 9c9bddd Compare March 26, 2023 06:41
@alalazo alalazo merged commit 56d98c3 into develop Mar 27, 2023
@alalazo alalazo deleted the balay/petsc-3.18.5 branch March 27, 2023 07:44
eugeneswalker pushed a commit to eugeneswalker/spack that referenced this pull request May 15, 2023
* py-petsc4py: update ldshared-dev.patch [to work with current @main]

* petsc4py: always force rebuild cython sources
balay added a commit that referenced this pull request Aug 28, 2023
…y release tarball (that depend on cython < 0.29.36)

This avoids conflict with petsc4py versions that have a dependency on cython@3.0.0

- revert #36406, #38996
- update cython dependency for mpi4py@master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants