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

check-esxi-hardware: refactor from python2 to python3 #102282

Merged
merged 5 commits into from Nov 23, 2020

Conversation

freezeboy
Copy link
Contributor

Motivation for this change

Working on issue: #101964

I took the opportunity to update the dependencies to support python3

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 102282 run on x86_64-linux 1

12 packages built:
  • check-esxi-hardware
  • python27Packages.nocasedict
  • python27Packages.nocaselist
  • python27Packages.pywbem
  • python27Packages.yamlloader
  • python37Packages.nocasedict
  • python37Packages.nocaselist
  • python37Packages.yamlloader
  • python38Packages.nocasedict
  • python38Packages.nocaselist
  • python38Packages.pywbem
  • python38Packages.yamlloader

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 102282 run on x86_64-darwin 1

12 packages built:
  • check-esxi-hardware
  • python27Packages.nocasedict
  • python27Packages.nocaselist
  • python27Packages.pywbem
  • python27Packages.yamlloader
  • python37Packages.nocasedict
  • python37Packages.nocaselist
  • python37Packages.yamlloader
  • python38Packages.nocasedict
  • python38Packages.nocaselist
  • python38Packages.pywbem
  • python38Packages.yamlloader

@@ -27,7 +27,7 @@ in python2Packages.buildPythonApplication rec {
runHook postInstall
'';

propagatedBuildInputs = with python2Packages; [ pywbem ];
propagatedBuildInputs = with python3Packages; [ pywbem requests ];
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
propagatedBuildInputs = with python3Packages; [ pywbem requests ];
propagatedBuildInputs = with python3Packages; [ pywbem requests setuptools ];
[nix-shell:~/.cache/nixpkgs-review/pr-102282]$ ./results/check-esxi-hardware/bin/check_esxi_hardware.py --help
Traceback (most recent call last):
  File "/nix/store/fx2jz12qvfvv3q4ckwqbzyrfgis67sdz-check-esxi-hardware-20200710/bin/.check_esxi_hardware.py-wrapped", line 290, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Copy link
Member

Choose a reason for hiding this comment

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

Lets take this opportunity to add a simple test for that:

  checkPhase = ''
    $out/bin/check_esxi_hardware.py --help
  '';

Copy link
Member

Choose a reason for hiding this comment

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

setuptools is a default build dependency, so this test will always succeed during a build, regardless of whether setuptools is available during runtime outside a build. Note this is also a bit of an issue with pythonImportsCheck and all tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

you might be able to do something like:

  checkPhase = ''
    unset PYTHONPATH
    $out/bin/check_esxi_hardware.py --help
  '';


let
bName = "check_esxi_hardware";
pName = stdenv.lib.replaceStrings [ "_" ] [ "-" ] bName;

in python2Packages.buildPythonApplication rec {
in python3Packages.buildPythonApplication rec {
Copy link
Member

Choose a reason for hiding this comment

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

There is an executable that is installed that has an extension, please remove the extension. Executables in /bin should not have any.

@freezeboy freezeboy force-pushed the update-check-esxi-hardware branch 2 times, most recently from 0695491 to b1ec9db Compare November 1, 2020 22:57
@peterhoeg
Copy link
Member

I really want to try this out but we have this check deployed on many locations so I need to be sure it doesn't break anything. Has anyone tried this against actual ESXi instances?

@jonringer
Copy link
Contributor

@peterhoeg

NIX_PATH=nixpkgs=https://github.com/freezeboy/nixpkgs/archive/update-check-esxi-hardware.tar.gz nix-shell -p check-esxi-hardware

@peterhoeg
Copy link
Member

Thanks @jonringer - it wasn't so much about "how" to try it out but more if anyone had actually given this a go.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/368

@SuperSandro2000
Copy link
Member

@freezeboy Can you resolve the merge conflict?

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

LGTM
shows usage

https://github.com/NixOS/nixpkgs/pull/102282
13 packages built:
check-esxi-hardware python27Packages.nocasedict python27Packages.nocaselist python27Packages.pywbem python27Packages.yamlloader python37Packages.nocasedict python37Packages.nocaselist python37Packages.pywbem python37Packages.yamlloader python38Packages.nocasedict python38Packages.nocaselist python38Packages.pywbem python38Packages.yamlloader

@jonringer jonringer merged commit b29a031 into NixOS:master Nov 23, 2020
@freezeboy freezeboy deleted the update-check-esxi-hardware branch November 23, 2020 14:43
@jonringer
Copy link
Contributor

Thanks @jonringer - it wasn't so much about "how" to try it out but more if anyone had actually given this a go.

if there was an issue with the interpreter, it's usually very apparent

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.

None yet

6 participants