unofficial mirror of help-guix@gnu.org 
 help / color / Atom feed
* Profiles for Python projects
@ 2020-06-18 16:53 Zelphir Kaltstahl
  2020-06-18 22:22 ` Marius Bakke
  0 siblings, 1 reply; 3+ messages in thread
From: Zelphir Kaltstahl @ 2020-06-18 16:53 UTC (permalink / raw)
  To: help-guix

Hi Guix Users!

Today I experimented a little with creating profiles from manifest.scm
file for Python projects. I have the following manifest.scm:

(specifications->manifest
 '("python@3.8.2"
   "python-falcon@2.0.0"
   "python-levenshtein@0.12.0"
   "python-jsonschema@3.2.0"
   "python-pytest@5.3.5"))

I create a profile with that and it works fine:

guix package --manifest="manifest.scm" --profile="${GUIX_EXTRA_PROFILES}"/my-env/my-env

Then I do the sourcing:

GUIX_PROFILE="${GUIX_EXTRA_PROFILES}/my-env/my-env"; source "${GUIX_PROFILE}/etc/profile"

This also works fine and when I do:

which python3
#
which pytest

I also get a path in the profile I created. So far all seems to just
work. However, then I hit a snag when trying to run the tests of the
project:

LOG_LEVEL="DEBUG" PYTHONPATH="$(pwd)/my_project" python3 -m pytest -m "my_test_marker" -s -vvv

I now get the error:

No module named pytest

So it seems, that somehow modules mentioned with

-m <module>

Are not found. If I use PyTest without

python3 -m

in front, it also does not find libraries and I get errors for the
dependencies of the actual project.

Perhaps there is an easy fix for this. Has anyone used a Guix profile
like this before and knows how to make it work?

Regards,
Zelphir


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

* Re: Profiles for Python projects
  2020-06-18 16:53 Profiles for Python projects Zelphir Kaltstahl
@ 2020-06-18 22:22 ` Marius Bakke
  2020-06-19  9:04   ` Zelphir Kaltstahl
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Bakke @ 2020-06-18 22:22 UTC (permalink / raw)
  To: Zelphir Kaltstahl, help-guix

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

Hi Zelphir,

Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:

> I create a profile with that and it works fine:
>
> guix package --manifest="manifest.scm" --profile="${GUIX_EXTRA_PROFILES}"/my-env/my-env
>
> Then I do the sourcing:
>
> GUIX_PROFILE="${GUIX_EXTRA_PROFILES}/my-env/my-env"; source "${GUIX_PROFILE}/etc/profile"

[...]

> I also get a path in the profile I created. So far all seems to just
> work. However, then I hit a snag when trying to run the tests of the
> project:
>
> LOG_LEVEL="DEBUG" PYTHONPATH="$(pwd)/my_project" python3 -m pytest -m "my_test_marker" -s -vvv
>
> I now get the error:
>
> No module named pytest

This is because you are overriding PYTHONPATH.  If you run it as ...

  LOG_LEVEL="DEBUG" PYTHONPATH="$(pwd)/my_project:$PYTHONPATH" python3 -m pytest -m "my_test_marker" -s -vvv

... you might have better luck.  Guix relies on PYTHONPATH to make
Python modules available because there is no single site-packages
directory like in some other distributions.

HTH!
Marius

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* Re: Profiles for Python projects
  2020-06-18 22:22 ` Marius Bakke
@ 2020-06-19  9:04   ` Zelphir Kaltstahl
  0 siblings, 0 replies; 3+ messages in thread
From: Zelphir Kaltstahl @ 2020-06-19  9:04 UTC (permalink / raw)
  To: Marius Bakke; +Cc: help-guix

Hi Marius!

That makes sense! I guess the GUIX Python packages are each in their own
location, so GUIX has to do this. I did not pay enough attention to the
PYTHONPATH thing.

… testing right now …

And it works! Thanks!

Regards,
Zelphir

On 19.06.20 00:22, Marius Bakke wrote:
> Hi Zelphir,
>
> Zelphir Kaltstahl <zelphirkaltstahl@posteo.de> writes:
>
>> I create a profile with that and it works fine:
>>
>> guix package --manifest="manifest.scm" --profile="${GUIX_EXTRA_PROFILES}"/my-env/my-env
>>
>> Then I do the sourcing:
>>
>> GUIX_PROFILE="${GUIX_EXTRA_PROFILES}/my-env/my-env"; source "${GUIX_PROFILE}/etc/profile"
> [...]
>
>> I also get a path in the profile I created. So far all seems to just
>> work. However, then I hit a snag when trying to run the tests of the
>> project:
>>
>> LOG_LEVEL="DEBUG" PYTHONPATH="$(pwd)/my_project" python3 -m pytest -m "my_test_marker" -s -vvv
>>
>> I now get the error:
>>
>> No module named pytest
> This is because you are overriding PYTHONPATH.  If you run it as ...
>
>   LOG_LEVEL="DEBUG" PYTHONPATH="$(pwd)/my_project:$PYTHONPATH" python3 -m pytest -m "my_test_marker" -s -vvv
>
> ... you might have better luck.  Guix relies on PYTHONPATH to make
> Python modules available because there is no single site-packages
> directory like in some other distributions.
>
> HTH!
> Marius


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 16:53 Profiles for Python projects Zelphir Kaltstahl
2020-06-18 22:22 ` Marius Bakke
2020-06-19  9:04   ` Zelphir Kaltstahl

unofficial mirror of help-guix@gnu.org 

Archives are clonable:
	git clone --mirror https://yhetil.org/guix-user/0 guix-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-user guix-user/ https://yhetil.org/guix-user \
		help-guix@gnu.org
	public-inbox-index guix-user

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.user
	nntp://news.gmane.io/gmane.comp.gnu.guix.user


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git