* Re: python-build-system: Delete .egg-info file created in phase check.
@ 2018-03-18 4:57 Mark H Weaver
2018-03-18 21:48 ` Hartmut Goebel
0 siblings, 1 reply; 2+ messages in thread
From: Mark H Weaver @ 2018-03-18 4:57 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: guix-devel
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 <h.goebel@crazy-compilers.com>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: python-build-system: Delete .egg-info file created in phase check.
2018-03-18 4:57 python-build-system: Delete .egg-info file created in phase check Mark H Weaver
@ 2018-03-18 21:48 ` Hartmut Goebel
0 siblings, 0 replies; 2+ messages in thread
From: Hartmut Goebel @ 2018-03-18 21:48 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel
Hi Mark,
> For now, I changed the 'eqv?' to 'string=?' in commit
> 171a117c61224be10f2b97a6a880ad0f4c38ef6d on core-updates, but I'm
Thanks for spotting and fixing this!
--
Regards
Hartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-18 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-18 4:57 python-build-system: Delete .egg-info file created in phase check Mark H Weaver
2018-03-18 21:48 ` Hartmut Goebel
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).