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
pythonPackages.diagrams: init at 0.17.0 #101533
Conversation
Please move the |
Perhaps this could be added to e.g. nixpkgs/pkgs/top-level/all-packages.nix Line 22650 in 91358d4
|
0ee823b
to
847aa7e
Compare
Oh cool. I wasn't aware of that. Added it. Rebased to resolve the suggestions. I've tried my best to follow the nixpkgs and python-modules conventions and am happy to learn more and make any changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks pretty good already.
It is customary for python packages to get the checkPhase
running. Currently no tests are being found, even though upstream has tests. This is because the PyPi Package doesn't include any.
----------------------------------------------------------------------
Ran 0 tests in 0.001s
Also the default checkPhase
might not work for this package. To find out how the test suite is run it is usually helpful to check how their CI is set up.
https://github.com/mingrammer/diagrams/blob/master/.github/workflows/test.yml#L35
Please try and get the tests running.
version = "0.17.0"; | ||
disabled = ! isPy3k; | ||
|
||
# TODO consider packaging from Github: https://github.com/mingrammer/diagrams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be easy. Use fetchFromGitHub
instead of fetchPypi
and set format = "pyproject";
. I assume we would then have the tests/
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent a few hours working on this. I am far from a python expert, but it seems like the GitHub repo is structurally quite different from the pypi tarball. I will upload a new branch in a bit with my (unsuccessful) efforts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I will take a look at it.
…On Sun, Oct 25, 2020, 11:13 AM Martin Weinelt ***@***.***> wrote:
***@***.**** requested changes on this pull request.
That looks pretty good already.
It is customary for python packages to get the checkPhase running.
Currently no tests are being found, even though upstream has tests. This is
because the PyPi Package doesn't include any.
----------------------------------------------------------------------
Ran 0 tests in 0.001s
Also the default checkPhase might not work for this package. To find out
how the test suite is run it is usually helpful to check how their CI is
set up.
https://github.com/mingrammer/diagrams/blob/master/.github/workflows/test.yml#L35
Please try and get the tests running.
------------------------------
In pkgs/development/python-modules/diagrams/default.nix
<#101533 (comment)>:
> @@ -0,0 +1,68 @@
+{ lib
+, fetchFromGitHub
+, buildPythonPackage
+, fetchPypi
+, isPy3k
+, graphviz
+}:
+
+buildPythonPackage rec {
+ pname = "diagrams";
+ version = "0.17.0";
+ disabled = ! isPy3k;
+
+ # TODO consider packaging from Github: https://github.com/mingrammer/diagrams
This should be easy. Use fetchFromGitHub instead of fetchPypi and set format
= "pyproject";. I assume we would then have the tests/ directory.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#101533 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMAS4NKIHC3VS6HL72ADLSMQ6A3ANCNFSM4S5MGCDQ>
.
|
For me personally, I'd make use of this through a python environment,
rather than using it from top-level.
Happy to change the PR to match best practices.
…On Tue, Oct 27, 2020, 1:16 PM Evan Stoll ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkgs/top-level/all-packages.nix
<#101533 (comment)>:
> @@ -3145,6 +3145,8 @@ in
dev86 = callPackage ../development/compilers/dev86 { };
+ diagrams = with python3.pkgs; toPythonApplication diagrams;
In the case of OpenRazer, I think it was appropriate due to the nature of
the package, but I am also curious about best practices, especially in this
case.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#101533 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMASZF6U77QIWDNTOH2BTSM355TANCNFSM4S5MGCDQ>
.
|
Here is my attempt to package this from the upstream GitHub instead of the pypi tarball. Currently this produces an empty python module. I'm not (yet) familiar with python packaging to understand what is happening. https://github.com/addict3d/nixpkgs/tree/add-python-diagrams-from-github It appears that the library code is generated correctly and the tests all pass, but getting the library working is important. |
847aa7e
to
5857fa9
Compare
I removed the top-level/all-packages entry because it doesn't make sense as a binary. You need a python environment with this library, and then to produce an image, call |
Add python diagrams library. Generate nice architecture diagrams with python code, allowing for rapid iteration. The images are rendered using dot from graphviz. Closes NixOS#101532
5857fa9
to
0fcd1f6
Compare
Since the Not quite sure what else can be done if we can't determine how the GitHub sources can be installed or etc. I also wonder if sourcing GitHub and pulling the sources from Pypi with tests from GitHubdiff --git a/pkgs/development/python-modules/diagrams/default.nix b/pkgs/development/python-modules/diagrams/default.nix
index 1f05abab32c..bbfa50a5a3c 100644
--- a/pkgs/development/python-modules/diagrams/default.nix
+++ b/pkgs/development/python-modules/diagrams/default.nix
@@ -4,17 +4,28 @@
, fetchPypi
, isPy3k
, graphviz
+, pytestCheckHook
}:
-buildPythonPackage rec {
+let
pname = "diagrams";
version = "0.17.0";
+ gitHubSrc = fetchFromGitHub {
+ owner = "mingrammer";
+ repo = pname;
+ rev = "v${version}";
+ sha256 = "1h5i9xb4fsmy81sznvqycxl712d9k695vznkpx2wm1ki7hvz86s8";
+ };
+in
+buildPythonPackage rec {
disabled = ! isPy3k;
+ inherit pname version;
# TODO consider packaging from Github: https://github.com/mingrammer/diagrams
# note: outscale package is broken, __init__.py is missing
src = fetchPypi {
inherit pname version;
+
sha256 = "17v5nzswva74bawxrvkza8a5d9aqyhb2gkncp3fqv6rszmk62hw6";
};
@@ -22,6 +33,8 @@ buildPythonPackage rec {
./diags_fix_aliases.patch
];
+ checkInputs = [ pytestCheckHook ];
+
# This script is patching setup.py from the pypi tarball, to retain
# the png images which this library uses to generate diagrams.
postPatch = ''
@@ -55,6 +68,8 @@ buildPythonPackage rec {
done
echo " ],)"
} >> setup.py
+
+ cp -r ${gitHubSrc}/tests .
'';
buildInputs = [ graphviz ]; |
I thought we could fetch this from GitHub and set
The author only uses this with poetry to develop, build and publish, so they don't need that explicitly. The test phase uses the unittest module: https://github.com/mingrammer/diagrams/blob/master/.github/workflows/test.yml#L35 The problems remind me of supakeen/pinnwand#93. |
Builds after patching the upstream git checkout like this and adding diff --git a/pyproject.toml b/pyproject.toml
index 8725f84..c134ab8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -11,8 +11,8 @@ include = ["resources/**/*"]
[tool.poetry.dependencies]
python = "^3.6"
-graphviz = "^0.13.2"
-jinja2 = "^2.10"
+graphviz = "^0.14.1"
+jinja2 = "^2.11"
contextvars = { version = "^2.4", python = "~3.6" }
[tool.poetry.dev-dependencies]
@@ -24,3 +24,7 @@ isort = "^4.3"
[tool.black]
line-length = 120
+
+[build-system]
+requires = ["poetry_core>=1.0.0"]
+build-backend = "poetry.core.masonry.api" You're also missing You'll also need |
hey @addict3d are you still planning on taking this package into Nixpkgs? I've been using your branch for a while and would be keen to see it merged |
oh. err sorry about that. yes I will get back to this and address the comments |
I'm closing this in favor of packaging directly from upstream (GitHub) rather than pypi. This way the package will include tests, and it removes one layer of indirection. See #102060 |
Motivation for this change
Add python diagrams library. Generate nice architecture diagrams
with python code, allowing for rapid iteration.
The images are rendered using dot from graphviz. It outputs your choice of
[png jpg svg pdf]
Closes #101532
Things done
I generated some diagrams using this library, with both of the following shell expressions. There are many examples on the project's website.
The closure size is ~150M.
The library itself has ~20M in images.