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

octoprint.python.pkgs.octolapse: init at 0.4.1 #136513

Merged
merged 2 commits into from Jan 19, 2022
Merged

octoprint.python.pkgs.octolapse: init at 0.4.1 #136513

merged 2 commits into from Jan 19, 2022

Conversation

j0hax
Copy link
Member

@j0hax j0hax commented Sep 2, 2021

Motivation for this change

Package the popular Octolapse plugin along with an additional python dependency

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages 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/)
  • 21.11 Release Notes (or backporting 21.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.

meta = with lib; {
description = "Stabilized timelapses for Octoprint";
homepage = "https://github.com/FormerLurker/OctoLapse";
license = licenses.agpl3;
Copy link
Member

Choose a reason for hiding this comment

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

According to the file headers (e.g., 1 and 2) the license is AGPL3+.

Suggested change
license = licenses.agpl3;
license = licenses.agpl3Plus;

{ lib, buildPythonPackage, fetchPypi, mock }:

buildPythonPackage rec {
pname = "file_read_backwards";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pname = "file_read_backwards";
pname = "file-read-backwards";

Naming should follow PEP 0503 -> https://nixos.org/manual/nixpkgs/unstable/#contributing

@j0hax
Copy link
Member Author

j0hax commented Sep 5, 2021

As #136349 was coincidentally opened very shortly before my PR, should I remove f567732?

@illustris
Copy link
Contributor

It's better to have file-read-backwards added this way. Use this PR for octolapse, I'll drop it from mine.

@j0hax
Copy link
Member Author

j0hax commented Sep 5, 2021

@illustris would you like me to add you as a maintainer for octolapse as well?

@illustris
Copy link
Contributor

Sure. I actively use it, so I'd be happy to fix it if it breaks in the future.

@j0hax j0hax requested a review from fabaff September 6, 2021 14:48
@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/595

sha256 = "13q20g7brabplc198jh67lk65rn140r8217iak9b2jy3in8fggv4";
};

propagatedBuildInputs = with super; [ awesome-slugify setuptools pillow sarge six psutil file_read_backwards ];
Copy link
Contributor

@urbas urbas Sep 19, 2021

Choose a reason for hiding this comment

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

Suggested change
propagatedBuildInputs = with super; [ awesome-slugify setuptools pillow sarge six psutil file_read_backwards ];
propagatedBuildInputs = with super; [ awesome-slugify setuptools pillow sarge six psutil file-read-backwards ];

Thinking more about this, I wonder why this doesn't fail the build. Shouldn't these plugins be included in octoprint's build somehow? Maybe there should be an octoprint-full package in all-packages.nix or something like that?

Would you know how is one supposed to use these plugins or at least build them?

Edit: Okay, found a way to build this:

% nix build -Lvf . --no-link pkgs.octoprint.python.pkgs.octolapse
error: undefined variable 'file_read_backwards' at /home/mat/programming/nixpkgs/pkgs/applications/misc/octoprint/plugins.nix:413:94
(use '--show-trace' to show detailed location information)

I would vote to add a octoprint-full into the top-level and make sure these plugins actually build.

Copy link
Contributor

@illustris illustris Sep 19, 2021

Choose a reason for hiding this comment

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

A -full package with all optional plugins isn't a pattern I've seen often in nixpkgs. For example:

https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/monitoring/grafana
https://github.com/NixOS/nixpkgs/tree/master/pkgs/servers/roundcube
https://github.com/NixOS/nixpkgs/tree/master/pkgs/shells/fish
https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/cluster/helm

Gimp has plugins, and has a wrapper package gimp-with-plugins, but even this defaults to plugins ? null
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/graphics/gimp/wrapper.nix

Gimp differs from the above packages in having its plugins exposed as gimpPlugins.<name>. Yosys does something similar. This might be less confusing than having a -full package with all plugins, especially given some of these plugins are very situational and not needed by most people. The ender3v2tempfix plugin, for example, is essential if and only if you have an ender 3 v2 printer.

Copy link
Member

Choose a reason for hiding this comment

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

The name needs to be updated or we run into an eval error when the addon is used.

version = "2.0.0";

src = fetchPypi {
pname = builtins.replaceStrings ["-"] ["_"] pname;
Copy link
Member

Choose a reason for hiding this comment

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

Use lib instead of builtins.

Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember someone saying something about lib enabling reflection, but I can't find it any more. @SuperSandro2000 can you point me to any documentation / discussion about why lib is preferred over builtins here?

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 no documentation for every little thing. lib sometimes has some extra sugar on top of the builtins like fetchurl and it is just easier to use lib everywhere because you don't need to think about anything. For replaceStrings lib and builtins are identical.

Copy link
Contributor

@urbas urbas left a comment

Choose a reason for hiding this comment

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

Successfully built nix build -Lvf . --no-link pkgs.octoprint.python.pkgs.octolapse. 👍

sha256 = "13q20g7brabplc198jh67lk65rn140r8217iak9b2jy3in8fggv4";
};

pythonImportsCheck = [ "file_read_backwards" ];
Copy link
Contributor

Choose a reason for hiding this comment

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

TL;DR: I think we'll have to give up on the import check in this plugin. I suggest you remove this import check entirely (read below for a more detailed explanation):

Suggested change
pythonImportsCheck = [ "file_read_backwards" ];

Detailed explanation:

Similarly to the other comment, this should be like this:

    pythonImportsCheck = [ "octoprint_octolapse" ];

However, I just checked and octoprint's plugins execute some code on import which fails the import check:

python3.8-OctoPrintPlugin-Octolapse> Check whether the following modules can be imported: octoprint_octolapse
python3.8-OctoPrintPlugin-Octolapse> Initializing GcodePositionProcessor V1.0.1 - Copyright (C) 2019  Brad Hochgesang...Python 3+ Detected...complete
python3.8-OctoPrintPlugin-Octolapse> 2021-11-27 16:07:30,253 - octolapse.__init__ - INFO - Release mode detected.
python3.8-OctoPrintPlugin-Octolapse> Error in atexit._run_exitfuncs:
python3.8-OctoPrintPlugin-Octolapse> Traceback (most recent call last):
python3.8-OctoPrintPlugin-Octolapse>   File "/nix/store/66p7i56lg3zzp7nj6g0fywb704ihp4iy-python3-3.8.11/lib/python3.8/logging/__init__.py", line 2127, in shutdown
python3.8-OctoPrintPlugin-Octolapse>     h.close()
python3.8-OctoPrintPlugin-Octolapse>   File "/nix/store/iqdafs15896fzih94jgicr7lgx0b4h5j-python3.8-OctoPrint-1.6.1/lib/python3.8/site-packages/octoprint/logging/handlers.py", line 31, in close
python3.8-OctoPrintPlugin-Octolapse>     self._executor.shutdown(wait=True)
python3.8-OctoPrintPlugin-Octolapse> AttributeError: 'OctolapseConsoleHandler' object has no attribute '_executor'

@SuperSandro2000: I suggest we omit the imports check here. It would require a change a change to the buildPlugin function to support this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to me. If everything else looks good, I'll go ahead and comment out the check, it may be sensible to add it at a later time when the import works.

Copy link
Member

Choose a reason for hiding this comment

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

Good to know.

@j0hax
Copy link
Member Author

j0hax commented Jan 16, 2022

Anything else needed in order to finish this PR up?

@SuperSandro2000
Copy link
Member

rebase and force push to fix the merge conflict.

@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review with nixpkgs-review-checks extension. It is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch).

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

2 packages built:
  • python310Packages.file-read-backwards
  • python39Packages.file-read-backwards

@SuperSandro2000 SuperSandro2000 merged commit 9693f55 into NixOS:master Jan 19, 2022
@j0hax j0hax deleted the octolapse branch January 19, 2022 12:28
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

7 participants