Cyril Roelandt <tipec...@gmail.com> skribis: > * guix/import/pypi.scm (compute-inputs, guess-requirements): New procedures.
Nice! Please mention the ‘guix-hash-url’, ‘make-pypi-sexp’, ‘python->package-name’, etc. changes and the tests. > +(define (maybe-inputs python->package-name inputs) > + (match inputs > + (() > + '()) > + ((inputs ...) > + `((,python->package-name (,'quasiquote ,inputs)))))) Please add a docstring. The first argument is misnamed: There’s only on call site and its value is 'inputs, so I think you should remove this argument. > +(define (guess-requirements source-url tarball) > + "Given SOURCE-URL and a TARBALL of the package, return a list of the > required > +packages specified in the requirements.txt file." Perhaps this should mention that TARBALL is extracted in the current directory. > + (define (tarball-directory url) > + "Given the URL of the package's tarball, return the name of the directory > +that will be created upon decompressing it." Use comments instead of docstrings for internal procedures. Also mention the #f return value. > + (let ((basename (substring url (+ 1 (string-rindex url #\/))))) > + (cond The opening paren should be under the ‘e’ of ‘let’. > + ((string-suffix? ".tar.gz" basename) > + (string-drop-right basename 7)) > + ((string-suffix? ".tar.bz2" basename) > + (string-drop-right basename 8)) > + (else #f)))) Would be nice to emit a warning like “unsupported archive format; cannot determine package dependencies” in the #f case. > + (if (zero? (system* "tar" "xf" tarball req-file)) > + (dynamic-wind > + (const #t) > + (lambda () > + (read-requirements req-file)) > + (lambda () > + (delete-file req-file) > + (rmdir dirname))) > + '())) When ‘tar’ exits with non-zero, it would be nice to report the failure and exit value using ‘warning’ from (guix ui). > + ,@(maybe-inputs 'inputs > + (compute-inputs source-url temp)) Second line should be aligned with 'inputs. > + (match url > + ("https://pypi.python.org/pypi/foo/json" > + (with-output-to-file file-name > + (lambda () > + (display test-json)))) > + ("https://example.com/foo-1.0.0.tar.gz" > + (begin > + (mkdir "foo-1.0.0") > + (with-output-to-file "foo-1.0.0/requirements.txt" > + (lambda () > + (display test-requirements))) > + (system* "tar" "czvf" file-name "foo-1.0.0/") > + (system* "rm" "-rf" "foo-1.0.0") Use ‘delete-file-recursively’ here. Could you send an updated patch? Thank you! Ludo’.