unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How to Write Empty File in Build Phase?
@ 2021-08-27 16:44 Antwane Mason
  2021-08-27 17:39 ` muradm
  0 siblings, 1 reply; 5+ messages in thread
From: Antwane Mason @ 2021-08-27 16:44 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

Hello,

I am currently working to resolve a build issue of python-verspec with the
ultimate goal of submitting a package for this package, onlykey-cli, and
all other dependencies required for onlykey-cli. Onlykey is a hardware
password manager, second factor authenticator, and private key storage
manager. A working solution to the build problem is to include an empty
__init__.py file in the test folder of the source code. How do I write this
file during a build phase?

Here is the package definition for reference.
-----------------------------------
(define-public python-verspec
  (package
    (name "python-verspec")
    (version "0.1.0")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "verspec" version))
        (sha256
          (base32
            "07n06wv85fm4vl1ird2mja0823js3x322wgs9gdnq1djjyk4ql64"))))
    (build-system python-build-system)
    (native-inputs
      `(("python-coverage" ,python-coverage)
        ("python-flake8" ,python-flake8)
        ("python-mypy" ,python-mypy)
        ("python-pretend" ,python-pretend)
        ("python-pytest" ,python-pytest)))
    (home-page
      "https://github.com/jimporter/verspec")
    (synopsis "Flexible version handling")
    (description "Flexible version handling")
    (license '(license:asl2.0 license:bsd-2))))
-----------------------------------

Regards,
Antwane

[-- Attachment #2: Type: text/html, Size: 1972 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to Write Empty File in Build Phase?
  2021-08-27 16:44 How to Write Empty File in Build Phase? Antwane Mason
@ 2021-08-27 17:39 ` muradm
  2021-08-28 12:40   ` Antwane Mason
  0 siblings, 1 reply; 5+ messages in thread
From: muradm @ 2021-08-27 17:39 UTC (permalink / raw)
  To: Antwane Mason; +Cc: guix-devel


May be something like this? (e-mail adhoc typing, may require 
fixing)

(define-public python-verspec
  (package
    (name "python-verspec")
    (version "0.1.0")
    (source
     (origin
       (method url-fetch)
       (uri (pypi-uri "verspec" version))
       (sha256
        (base32
         "07n06wv85fm4vl1ird2mja0823js3x322wgs9gdnq1djjyk4ql64"))
       (modules '((guix build utils)))
       (snippet
        '(with-directory-excursion "test"
           (with-output-to-file "__init__.py"
             (newline))))))
    (build-system python-build-system)
    (native-inputs
     `(("python-coverage" ,python-coverage)
       ("python-flake8" ,python-flake8)
       ("python-mypy" ,python-mypy)
       ("python-pretend" ,python-pretend)
       ("python-pytest" ,python-pytest)))
    (home-page
     "https://github.com/jimporter/verspec")
    (synopsis "Flexible version handling")
    (description "Flexible version handling")
    (license '(license:asl2.0 license:bsd-2))))

You can use (snippet of (origin, that allows pre phases actions on 
source before
any build steps/phases. (with-directory-excursion will basically 
"cd" to "test"
directory, (with-output-to-file will open file named 
"__init__.py", (newline)
will write empty line to just opened file.

Antwane Mason <ad.mason1413@gmail.com> writes:

> Hello,
>
> I am currently working to resolve a build issue of 
> python-verspec with the ultimate goal of submitting a package 
> for this
> package, onlykey-cli, and all other dependencies required for 
> onlykey-cli. Onlykey is a hardware password manager, second
> factor authenticator, and private key storage manager. A working 
> solution to the build problem is to include an empty
> __init__.py file in the test folder of the source code. How do I 
> write this file during a build phase?
>
> Here is the package definition for reference.
> -----------------------------------
> (define-public python-verspec
>   (package
>     (name "python-verspec")
>     (version "0.1.0")
>     (source
>       (origin
>         (method url-fetch)
>         (uri (pypi-uri "verspec" version))
>         (sha256
>           (base32
>             "07n06wv85fm4vl1ird2mja0823js3x322wgs9gdnq1djjyk4ql64"))))
>     (build-system python-build-system)
>     (native-inputs
>       `(("python-coverage" ,python-coverage)
>         ("python-flake8" ,python-flake8)
>         ("python-mypy" ,python-mypy)
>         ("python-pretend" ,python-pretend)
>         ("python-pytest" ,python-pytest)))
>     (home-page
>       "https://github.com/jimporter/verspec")
>     (synopsis "Flexible version handling")
>     (description "Flexible version handling")
>     (license '(license:asl2.0 license:bsd-2))))
> -----------------------------------
>
> Regards,
> Antwane



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to Write Empty File in Build Phase?
  2021-08-27 17:39 ` muradm
@ 2021-08-28 12:40   ` Antwane Mason
  2021-08-28 14:07     ` Tobias Geerinckx-Rice
  0 siblings, 1 reply; 5+ messages in thread
From: Antwane Mason @ 2021-08-28 12:40 UTC (permalink / raw)
  To: muradm, guix-devel

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

muradm,

Thank you so much for your help! That worked like a charm! Just needed to
adjust the second argument of with-output-to-file so that it takes a lambda
that returns (newline).
Here is the resulting package definition that successfully builds.

(define-public python-verspec
  (package
    (name "python-verspec")
    (version "0.1.0")
    (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "verspec" version))
        (sha256
          (base32
            "07n06wv85fm4vl1ird2mja0823js3x322wgs9gdnq1djjyk4ql64"))
        (modules '((guix build utils)))
        (snippet
        '(with-directory-excursion "test"
           (with-output-to-file "__init__.py"
             (lambda () (newline)))))))
    (build-system python-build-system)
    (native-inputs
      `(("python-coverage" ,python-coverage)
        ("python-flake8" ,python-flake8)
        ("python-mypy" ,python-mypy)
        ("python-pretend" ,python-pretend)
        ("python-pytest" ,python-pytest)))
    (home-page
      "https://github.com/jimporter/verspec")
    (synopsis "Flexible version handling")
    (description "Flexible version handling")
    (license '(license:asl2.0 license:bsd-2))))

Regards,
Antwane

[-- Attachment #2: Type: text/html, Size: 1906 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to Write Empty File in Build Phase?
  2021-08-28 12:40   ` Antwane Mason
@ 2021-08-28 14:07     ` Tobias Geerinckx-Rice
  2021-08-29 12:48       ` Antwane Mason
  0 siblings, 1 reply; 5+ messages in thread
From: Tobias Geerinckx-Rice @ 2021-08-28 14:07 UTC (permalink / raw)
  To: Antwane Mason; +Cc: muradm, guix-devel

Hi Antwane,

> (with-output-to-file "__init__.py"
>  (lambda () (newline))

=>

   (with-output-to-file "__init__.py"
     newline)

Untested, but NEWLINE taking #:optional arguments should not make it any 
less of a thunk.

Kind regards,

T G-R

Sent from a Web browser.  Excuse or enjoy my brevity.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to Write Empty File in Build Phase?
  2021-08-28 14:07     ` Tobias Geerinckx-Rice
@ 2021-08-29 12:48       ` Antwane Mason
  0 siblings, 0 replies; 5+ messages in thread
From: Antwane Mason @ 2021-08-29 12:48 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

 > (with-output-to-file "__init__.py"
 >    newline)

> Untested, but NEWLINE taking #:optional arguments should not make it any
> less of a thunk.

That code snippet worked well for me. I appreciate the suggestion!

[-- Attachment #2: Type: text/html, Size: 399 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-29 12:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 16:44 How to Write Empty File in Build Phase? Antwane Mason
2021-08-27 17:39 ` muradm
2021-08-28 12:40   ` Antwane Mason
2021-08-28 14:07     ` Tobias Geerinckx-Rice
2021-08-29 12:48       ` Antwane Mason

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).