Skip to content

fmpy: init at 0.3.23 #397658

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

fmpy: init at 0.3.23 #397658

wants to merge 3 commits into from

Conversation

tmplt
Copy link
Member

@tmplt tmplt commented Apr 10, 2025

Continuing the work from #131741, FMpy, a library for working with the FMI standard is packaged.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: python 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` labels Apr 10, 2025
@tmplt

This comment was marked as resolved.

@tmplt

This comment was marked as outdated.

@tmplt

This comment was marked as outdated.

Copy link
Contributor

@doronbehar doronbehar 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 more comments on the commits of the PR: Always make sure the PR has the following commits:

maintainers.tmplt: fix email and name
rpclib: init at 2.3.0
python312Packages.fmpy: init at <fill this>

I'd let go of the sundials commit, and put all the overriding details inside the fmpy expression. Note how I use python312Packages.fmpy and not python3Packages.fmpy - the later is not an attribute directly built by Hydra, and hence the PR does not trigger an ofborg build of it automatically.

@tmplt
Copy link
Member Author

tmplt commented Apr 10, 2025

Thanks for the review, @doronbehar. I'll handle your comments when all the kinks are ironed out.

@tmplt
Copy link
Member Author

tmplt commented Apr 10, 2025

Things to fix:

@tmplt
Copy link
Member Author

tmplt commented Apr 23, 2025

dlopen error due to FMPy extracting FMU under /tmp which is mounted noexec on my system. Setting TMPDIR=~/tmp resolves this. I don't think this is a nixpkgs issue?

@tmplt
Copy link
Member Author

tmplt commented Apr 23, 2025

I'd let go of the sundials commit, and put all the overriding details inside the fmpy expression.

Makes sense. Done.

@tmplt tmplt changed the title fmpy: init at 0.3.22 fmpy: init at 0.3.23 Apr 28, 2025
@tmplt tmplt force-pushed the fmpy branch 3 times, most recently from 329dd38 to 6c06b7c Compare April 29, 2025 10:37
@tmplt tmplt marked this pull request as ready for review April 29, 2025 11:46
@nix-owners nix-owners bot requested a review from natsukium April 29, 2025 11:48
@tmplt
Copy link
Member Author

tmplt commented Apr 29, 2025

Could not get the remoting feature to build so I gated it behind a package option, enableRemoting ? false.
The error is

nix-repl> :b (outputs.legacyPackages.x86_64-linux.python3Packages.fmpy.overrideAttrs(prev: { meta.broken = false; })).override({ enableRemoting = true; })
[...]
       > In file included from /nix/store/71xyq87gpb2qrwn314p0sf2n002lgd91-glibc-2.40-66-dev/include/fcntl.h:341,
       >                  from /build/source/native/remoting/client_tcp.cpp:12:
       > In function ‘int open(const char*, int, ...)’,
       >     inlined from ‘void* fmi2Instantiate(fmi2String, fmi2Type, fmi2String, fmi2String, const fmi2CallbackFunctions*, fmi2Boolean, fmi2Boolean)’ at /build/source/native/remoting/client_tcp.cpp:217:28:
       > /nix/store/71xyq87gpb2qrwn314p0sf2n002lgd91-glibc-2.40-66-dev/include/bits/fcntl2.h:52:31: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
       >    52 |           __open_missing_mode ();
       >       |           ~~~~~~~~~~~~~~~~~~~~^~

Unsure what's going on here, or whether this is an upstream issue.

@tmplt tmplt requested a review from doronbehar April 29, 2025 11:58
Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

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

Lots of comments! Indeed a complex package you are trying to package!

Comment on lines +7 to +15
stdenv.mkDerivation rec {
pname = "rpclib";
version = "2.3.0";

src = fetchFromGitHub {
owner = "rpclib";
repo = "rpclib";
rev = "v${version}";
sha256 = "0dlbkl47zd2fkxwbn93w51wmvfr8ssp4zribn5wi4cpiky44a4g9";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
stdenv.mkDerivation rec {
pname = "rpclib";
version = "2.3.0";
src = fetchFromGitHub {
owner = "rpclib";
repo = "rpclib";
rev = "v${version}";
sha256 = "0dlbkl47zd2fkxwbn93w51wmvfr8ssp4zribn5wi4cpiky44a4g9";
stdenv.mkDerivation (finalAttrs: {
pname = "rpclib";
version = "2.3.0";
src = fetchFromGitHub {
owner = "rpclib";
repo = "rpclib";
rev = "v${finalAttrs.version}";
sha256 = "0dlbkl47zd2fkxwbn93w51wmvfr8ssp4zribn5wi4cpiky44a4g9";

license = with lib.licenses; [ mit ];
maintainers = with lib.maintainers; [ tmplt ];
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
})

meta = {
description = "RPC library for C++, providing both a client and server implementation";
homepage = "https://github.com/rpclib/rpclib/";
license = with lib.licenses; [ mit ];
Copy link
Contributor

Choose a reason for hiding this comment

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

This will probably not change too often to justify opening a with *;. So I'd suggest:

Suggested change
license = with lib.licenses; [ mit ];
license = lib.licenses.mit;

homepage = "https://github.com/CATIA-Systems/FMPy";
license = with lib.licenses; [ bsd2 ];
maintainers = with lib.maintainers; [ tmplt ];
platforms = with lib.platforms; linux ++ darwin ++ windows;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty much the same as lib.platforms.all;.

broken = enableRemoting;
description = "Simulate Functional Mockup Units (FMUs) in Python";
homepage = "https://github.com/CATIA-Systems/FMPy";
license = with lib.licenses; [ bsd2 ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
license = with lib.licenses; [ bsd2 ];
license = lib.licenses.bsd2;

Comment on lines +162 to +163
substituteInPlace src/fmpy/gui/__init__.py \
--replace-fail "@QT6_LIBEXEC_DIR@" "${qt6.qtbase}/libexec/"
Copy link
Contributor

Choose a reason for hiding this comment

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

To make it a bit clearer that the derivation is eventually built using Nixpkgs Python setup hooks, maybe it'd be a bit more correct to put this in a postConfigure.

'';

# Don't run upstream build scripts as they are too specialized.
# cvode is already built, so we only need to build native binaries.
Copy link
Contributor

Choose a reason for hiding this comment

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

Another worth noting thing to comment about could be:

Suggested change
# cvode is already built, so we only need to build native binaries.
# cvode is already built, so we only need to build native binaries.
# We run these cmake builds and then run the standard Nixpkgs Python
# setup-hooks.

Comment on lines +150 to +152
+ lib.optionalString (enableRemoting && stdenv.isLinux) ''
# The reproduction of build_remoting.py
# NB: does not build due do to incorrect open(8) call
Copy link
Contributor

Choose a reason for hiding this comment

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

Put that comment near broken = true;.

Suggested change
+ lib.optionalString (enableRemoting && stdenv.isLinux) ''
# The reproduction of build_remoting.py
# NB: does not build due do to incorrect open(8) call
+ lib.optionalString (enableRemoting && stdenv.isLinux) ''

Comment on lines +131 to +140
# Remove artifacts that we do not build
+ lib.optionalString stdenv.isLinux ''
sed --regexp-extended --in-place '/(.dll|.dylib|.exe)/d' pyproject.toml
''
+ lib.optionalString stdenv.isDarwin ''
sed --regexp-extended --in-place '/(.dll|.so|linux|.exe)/d' pyproject.toml
''
+ lib.optionalString (!enableRemoting) ''
sed --regexp-extended --in-place '/(client_tcp|server_tcp)/d' pyproject.toml
'';
Copy link
Contributor

Choose a reason for hiding this comment

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

Upstream should be nudged to not require these artifacts depending on the platform... Have you made an effort in that regard? Even if we'd decide to keep removing these lines ourselves, maybe it'd recommend at least for the darwin v.s linux. something like:

# Remove the other system's extension.
''
sed --regexp-extended --in-place '/\.(dll|${
  "linux" = "dylib";
  "darwin" = "so";
}.${stdenv.hostPlatform.system}|exe)/d' pyproject.toml
''

NOTE: Technically, a bit more sophisticated Nix function should be used here, since exe is always removed although Windows is a supported platform.

In general, I'm very surprised upstream writes all of these extensions, and that you have to remove them because you want to build to a specific platform... I'd try to discuss this with upstream to make it easier for us and for others to build and distribute their software...

--subst-var-by cvode ${cvode}
# Sundials are provided outside of this package
sed --regexp-extended --in-place '/(sundials_)/d' pyproject.toml
Copy link
Contributor

Choose a reason for hiding this comment

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

Not to mention they hard-code these sundials paths... Why do they do it?

@tmplt
Copy link
Member Author

tmplt commented Apr 29, 2025

Good comments, @doronbehar, thanks! It may be a week or two before I can handle these.

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.

3 participants