guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: python-build-system: Delete .egg-info file created in phase check.


From: Mark H Weaver
Subject: Re: python-build-system: Delete .egg-info file created in phase check.
Date: Sun, 18 Mar 2018 00:57:22 -0400

Hi Hartmut,

I just now came across the code you wrote back in Oct 2016 to delete
.egg-info files created during the 'check' phase in python-build-system:

> From b002f964bb3d69c77856ea7dcadfe82383050512 Mon Sep 17 00:00:00 2001
> From: Hartmut Goebel <address@hidden>
> Date: Fri, 7 Oct 2016 17:17:00 +0200
> Subject: [PATCH] guix: python-build-system: Delete .egg-info file created in
>  phase check.
> 
> * guix/build/python-build-system.scm (check): Delete .egg-info dirs
>   which did not exist prior to calling setup.py but afterwards.
> ---
>  guix/build/python-build-system.scm | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/guix/build/python-build-system.scm 
> b/guix/build/python-build-system.scm
> index 22c4f7d38..310ba8aa2 100644
> --- a/guix/build/python-build-system.scm
> +++ b/guix/build/python-build-system.scm
> @@ -69,7 +69,15 @@
>  (define* (check #:key tests? test-target use-setuptools? #:allow-other-keys)
>    "Run the test suite of a given Python package."
>    (if tests?
> -    (call-setuppy test-target '() use-setuptools?)
> +      ;; Running `setup.py test` creates an additional .egg-info directory in
> +      ;; build/lib in some cases, e.g. if the source is in a sub-directory
> +      ;; (given with `package_dir`). This will by copied to the output, too,
> +      ;; so we need to remove.
> +      (let ((before (find-files "build" "\\.egg-info$" #:directories? #t)))
> +        (call-setuppy test-target '() use-setuptools?)
> +        (let* ((after (find-files "build" "\\.egg-info$" #:directories? #t))
> +               (inter (lset-difference eqv? after before)))

This code doesn't behave as you apparently expect.  The problem is that
you passed the wrong equality predicate to 'lset-difference' above.

In Scheme, there are multiple equality predicates with different
semantics, and you must choose the right one.  'eqv?' tests for
operational equivalence, which for mutable objects means object
identity.  If A and B are two mutable objects, (eqv? A B) requires not
only that A and B have the same contents, but also that mutating A makes
the same change to B.

In this case, 'find-files' allocates fresh string objects each time it's
called, so 'eqv?' never returns #t.  Therefore, (lset-difference eqv?
after before) => after, and so you are deleting _all_ .egg-info files in
the build directory, including the ones that were present before running
'setup.py test'.

If you need a generic equality predicate that tests mutable objects for
equality of the contents, then 'equal?' is likely what you want.
However, in this case I prefer to use 'string=?'.

> +          (for-each delete-file-recursively inter)))
>      #t))

For now, I changed the 'eqv?' to 'string=?' in commit
171a117c61224be10f2b97a6a880ad0f4c38ef6d on core-updates, but I'm
raising attention to this now in case there are unforeseen consequences
to this change, or in case any strange behavior seen in the past might
make more sense now.

    Regards,
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]