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

Cleanup pkgs/top-level/python-packages.nix #27379

Closed
wants to merge 23 commits into from

Conversation

wizzup
Copy link
Contributor

@wizzup wizzup commented Jul 14, 2017

Motivation for this change

This is the first batch of python-packages.nix cleanup as discuss here.

Things done
  • Tested using sandboxing : nix.useSandbox on NixOS
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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 nox --run "nox-review wip"
  • Tested execution : tested using this scripts
  • Fits CONTRIBUTING.md.
Additional information

altair and pygame_sdl2 failed to build on python 3.6 before this PR, I test against upstream/master

Try to run following command on your system, if there is no error please reply to me so I can fix them.

$ nix-shell -p python36Packages.altair
$ nix-shell -p python36Packages.pygame_sdl2

buildPythonPackage rec {
name = "django-tagging-0.4.5";

src = fetchurl {
Copy link
Member

Choose a reason for hiding this comment

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

do you also want to convert instances of fetchurl to fetchPypi or do you want to keep this out of scope of pull request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for now, to make it easy for me, just moving buildPythonPackges out and use callPackage first.

Copy link
Member

@FRidh FRidh Jul 14, 2017

Choose a reason for hiding this comment

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

I recommend making several changes at the same time. Most importantly is using

  1. fetchPypi when possible
  2. have pname, version and name attributes so we can more easily update packages

Example https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/jupyter_client/default.nix

@wizzup
Copy link
Contributor Author

wizzup commented Jul 14, 2017

@FRidh This 0d16766 is ok with nix-shell -p

$ nix-shell -I nixpkgs=/nix/nixpkgs -p pythonPackages.django_tagging

[nix-shell:/nix/nixpkgs]$ 

but failed on nox-review.

$ nix-shell -p nox --run 'nox-review wip'                                                                                                                                                              
error: while evaluating anonymous function at /nix/nixpkgs/lib/meta.nix:47:54, called from /nix/nixpkgs/lib/attrsets.nix:199:52:                                                                       
while evaluating ‘isDerivation’ at /nix/nixpkgs/lib/attrsets.nix:295:18, called from /nix/nixpkgs/lib/meta.nix:47:62:                                                                                  
while evaluating the attribute ‘django_tagging_0_3’ at /nix/nixpkgs/pkgs/top-level/python-packages.nix:9943:3:                                                                                         
while evaluating ‘override’ at /nix/nixpkgs/lib/customisation.nix:78:20, called from /nix/nixpkgs/pkgs/top-level/python-packages.nix:9943:24:                                                          
while evaluating ‘makeOverridable’ at /nix/nixpkgs/lib/customisation.nix:72:24, called from /nix/nixpkgs/lib/customisation.nix:78:29:                                                                  
anonymous function at /nix/nixpkgs/pkgs/development/python-modules/django_tagging/default.nix:1:1 called with unexpected argument ‘name’, at /nix/nixpkgs/lib/customisation.nix:74:12                  
Traceback (most recent call last):                                                                                                                                                                     
  File "/nix/store/kdfayij6fxnmgdly9l9zyl0np6wgp4gc-nox-0.0.5/bin/.nox-review-wrapped", line 12, in <module>                                                                                           
    sys.exit(cli())                                                                                                                                                                                    
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 722, in __call__                                                              
    return self.main(*args, **kwargs)                                                                                                                                                                  
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 697, in main                                                                  
    rv = self.invoke(ctx)                                                                                                                                                                              
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 1066, in invoke                                                               
    return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                                                                            
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 895, in invoke                                                                
    return ctx.invoke(self.callback, **ctx.params)                                                                                                                                                     
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/core.py", line 535, in invoke                                                                
    return callback(*args, **kwargs)                                                                                                                                                                   
  File "/nix/store/nn3d0x4q24ba5h42b1lqrxxf9m3p1gb5-python3.6-click-6.7/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func                                                         
    return f(get_current_context(), *args, **kwargs)                                                                                                                                                   
  File "/nix/store/kdfayij6fxnmgdly9l9zyl0np6wgp4gc-nox-0.0.5/lib/python3.6/site-packages/nox/review.py", line 82, in wip                                                                              
    packages('.'))                                                                                                                                                                                     
  File "/nix/store/kdfayij6fxnmgdly9l9zyl0np6wgp4gc-nox-0.0.5/lib/python3.6/site-packages/nox/nixpkgs_repo.py", line 81, in packages                                                                   
    universal_newlines=True)                                                                                                                                                                           
  File "/nix/store/v96ayp4hp476fqabmx86vgvwcn8wb7f9-python3-3.6.1/lib/python3.6/subprocess.py", line 336, in check_output                                                                              
    **kwargs).stdout                                                                                                                                                                                   
  File "/nix/store/v96ayp4hp476fqabmx86vgvwcn8wb7f9-python3-3.6.1/lib/python3.6/subprocess.py", line 418, in run                                                                                       
    output=stdout, stderr=stderr)                                                                                                                                                                      
subprocess.CalledProcessError: Command '['nix-env', '-f', '.', '-qaP', '--out-path', '--show-trace']' returned non-zero exit status 1.                                                                 

Is it OK?

homepage = https://github.com/Fantomas42/django-tagging;
};
};
django_tagging = callPackage ../development/python-modules/django_tagging { };

django_tagging_0_3 = self.django_tagging.override (attrs: rec {
Copy link
Member

Choose a reason for hiding this comment

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

This should be probably changed to

django_tagging_0_3 = self.django_tagging.overrideDerivation (attrs: rec {

Copy link
Member

Choose a reason for hiding this comment

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

Good point, but it should be overrideAttrs then since we want to override the call to stdenv.mkDerivation and not to derivation.

Copy link
Member

Choose a reason for hiding this comment

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

This package can be also removed at some point, when graphite-web is upgraded:

https://github.com/graphite-project/graphite-web/blob/master/requirements.txt

@wizzup wizzup force-pushed the fix-pythonPackages branch 3 times, most recently from e27febd to f7214a2 Compare July 14, 2017 12:04
@bjornfor
Copy link
Contributor

@wizzup: Please add proper commit messages, i.e. "package: what"

@wizzup
Copy link
Contributor Author

wizzup commented Jul 14, 2017

@bjornfor Oh, I thought I will git rebase -i or maybe squash all commits after reviewed.

There are no change to the packages itself, just cleanup work.

@bjornfor
Copy link
Contributor

@wizzup: Ok. Just don't forget :-)

@FRidh
Copy link
Member

FRidh commented Jul 14, 2017

@wizzup just don't pass in pkgs or pythonPackages but use individual packages as function parameters.

@wizzup
Copy link
Contributor Author

wizzup commented Jul 14, 2017

@FRidh I don't think I understand what you mean, could you point to code or show me some example?

I have to go for now, will continue later (tomorrow maybe).

@@ -0,0 +1,27 @@
{
stdenv, lib, pkgs,
Copy link
Member

Choose a reason for hiding this comment

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

@FRidh meant, instead of using pkgs here, use libdiscid here.


patchPhase = ''
substituteInPlace discid/libdiscid.py \
--replace '_open_library(_LIB_NAME)' "_open_library('${pkgs.libdiscid}/lib/libdiscid.so.0')"
Copy link
Member

Choose a reason for hiding this comment

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

then you would write:

substituteInPlace discid/libdiscid.py \
  --replace '_open_library(_LIB_NAME)' "_open_library('${libdiscid}/lib/libdiscid.so.0')"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's funny, I remember I have try this and it failed so I have to put pkgs back in.
Let my try again.

@@ -0,0 +1,34 @@
{
stdenv, lib, pkgs, buildPythonPackage, fetchFromGitHub,
Copy link
Member

Choose a reason for hiding this comment

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

pkgs is not used here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I do really forget to remove.

{
stdenv, buildPythonPackage, fetchPypi,
pip, pandoc, glibcLocales,
haskellPackages, texlive
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FRidh How can I not use haskellPacakges and texlive here (for line 27)? reference to this contex

Copy link
Member

Choose a reason for hiding this comment

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

@wizzup for haskellPackages and texlive your approach is ok.

@Mic92
Copy link
Member

Mic92 commented Jul 15, 2017

I would recommend to not add more python packages to this pull request. Otherwise it will be difficult to find reviewers and the risc of merge conflicts increases.

@wizzup
Copy link
Contributor Author

wizzup commented Jul 15, 2017

Should I create new PR for another batch?

Do I have to squash all commit in to single one with proper commit message?

@wizzup
Copy link
Contributor Author

wizzup commented Jul 15, 2017

I use these script to test my code

git diff upstream/master --summary | cut -d '/' -f 4 - | xargs -i ./tstpy.sh {} 2>/dev/null

tstpy.sh

NAME=$1

echo ${NAME}

nix-shell --run 'echo 2.7 Done' -I nixpkgs=/nix/nixpkgs -p python27Packages.${NAME}
nix-shell --run 'echo 3.6 Done' -I nixpkgs=/nix/nixpkgs -p python36Packages.${NAME}

@Mic92
Copy link
Member

Mic92 commented Jul 15, 2017

I would propose the following approach:

Leave the commits as they are, but keep them a more descriptive commit title like:

python.pkgs.$name: move to separate expression

You can probably also automated this (https://davidwalsh.name/update-git-commit-messages)
Then mark the pull request as non-WIP and wait for it to merge.

This is a tedious task, but unless we have to tools to automate moving out python expressions,
we need to ensure to not breaking something accidentally.

 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
wizzup added 13 commits July 15, 2017 20:16
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
 move to separate expression
@wizzup wizzup changed the title [WIP] cleanup pkgs/top-level/python-packages.nix Cleanup pkgs/top-level/python-packages.nix Jul 15, 2017
@Mic92 Mic92 closed this in a5d75f0 Jul 15, 2017
@Mic92
Copy link
Member

Mic92 commented Jul 15, 2017

I changed the commit title (there was a newline between package name and remaining message)
and I removed lib from the individual packages.

@wizzup
Copy link
Contributor Author

wizzup commented Jul 16, 2017

Cool! Sorry about newline in commit message. I never use filter-branch before.

For the next batch I will use proper commit message from start.

@FRidh FRidh reopened this Jul 16, 2017
@FRidh
Copy link
Member

FRidh commented Jul 16, 2017

Ah, I thought only one commit had been pushed. Closing again.
Thanks to you both for the "boring" work! :)

@FRidh FRidh closed this Jul 16, 2017
@wizzup wizzup deleted the fix-pythonPackages branch July 19, 2017 08:14
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.

None yet

4 participants