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

[SCons] Fix stage directory from appearing in setup_cantera #1102

Merged
merged 1 commit into from
Sep 20, 2021

Conversation

speth
Copy link
Member

@speth speth commented Sep 18, 2021

Changes proposed in this pull request

  • Fix setting the SCons variable python_module_loc to remove the stage directory prefix so that doesn't show up in the setup_cantera script or the post-install message.
  • Changes how the Python module is installed to a "staging directory" to avoid the staging directory name from ending up in the .pyc files.

On this second point, I'm hoping we're finally using the --root option to setuptools correctly. Previously (#296) we had tried using it in some cases and not been able to get it to do what we wanted.

If applicable, fill in the issue number this pull request is fixing

Fixes #1094

If applicable, provide an example illustrating new features this pull request is introducing

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@speth speth marked this pull request as ready for review September 20, 2021 12:52
Copy link
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

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

A few "double checks" here, thanks @speth!

interfaces/cython/SConscript Outdated Show resolved Hide resolved
@@ -122,6 +123,10 @@ else:
# Install Python module in the default location
extra = ''

if env['stage_dir']:
# Get the absolute path to the stage directory
extra += ' --root=' + str(Path.cwd().parents[1].joinpath(env["stage_dir"]))
Copy link
Member

Choose a reason for hiding this comment

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

This line is long enough to me to deserve its own variable, so it can clarify what is happening here. In particular, an example of what Path.cwd().parents[1] should be, in a comment, would help future us remember why this is here. I have a couple of questions as well.

  1. Is Path.cwd() always guaranteed to be the directory that we want? I mean, Path.cwd() returns the current working directory of the Python process, which is not necessarily the root of the project. I think it should be, because SCons requires the SConstruct file, but is there a more stable way to find the right path?
  2. stage_dir may have relative path components in it, so probably best to .resolve() the path after joining.
  3. You can avoid the str(...) by using an f-string here

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding (1), SCons changes the working directory such that cwd() here is the directory containing the SConscript file, the interfaces/cython subdirectory of the Cantera source directory. I think that can be regarded as stable behavior.

interfaces/cython/SConscript Show resolved Hide resolved
Fixes setup_cantera and the post-install message to reference the path
of the Python module on the target system rather than the staging
directory.

Also, generated .pyc files no long specify the path in the staging
directory. This has no effect on the use of the .pyc files, but helps
avoid warnings/errors from packaging system linters (notably, on
FreeBSD).

Fixes Cantera#1094
Copy link
Member

@ischoegl ischoegl left a comment

Choose a reason for hiding this comment

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

looks good ... :shipit:

@bryanwweber bryanwweber merged commit 29587ee into Cantera:main Sep 20, 2021
@bryanwweber bryanwweber mentioned this pull request Feb 7, 2022
5 tasks
@speth speth deleted the fix-1094 branch July 23, 2024 15:38
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.

Fails to install into the stage directory
3 participants