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