Commit Graph

25 Commits

Author SHA1 Message Date
Sandro Jäckel b3b12c2d08 Revert "Fix venv creation in Python environments"
This commit reverts all python changes from 234bb31f61.
2024-04-11 08:26:39 -07:00
Martin Weinelt e05a3ec1ce cpython: disable failing passthru tests on darwin
````
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
                  [--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
                  [--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
                  dest
virtualenv: error: argument dest: the destination . is not write-able at /nix/store
SystemExit: 2
````
2024-04-10 18:00:32 +02:00
Colin Putney 234bb31f61 Fix venv creation in Python environments
The way we build python environments is subtly broken. A python
environment should be semantically identical to a vanilla Python
installation in, say, /usr/local. The current implementation, however,
differs in two important ways. The first is that it's impossible to use
python packages from the environment in python virtual environments. The
second is that the nix-generated environment appears to be a venv, but
it's not.

This commit changes the way python environments are built:

  * When generating wrappers for python executables, we inherit argv[0]
    from the wrapper. This causes python to initialize its configuration
    in the environment with all the correct paths.
  * We remove the sitecustomize.py file from the base python package.
    This file was used tweak the python configuration after it was
    incorrectly initialized. That's no longer necessary.

The end result is that python environments no longer appear to be venvs,
and behave more like a vanilla python installation. In addition it's
possible to create a venv using an environment and use packages from
both the environment and the venv.
2024-03-21 19:26:57 -06:00
Sergei Trofimovich c64c04e8bf pythonInterpreters.pypy39_prebuilt: fix tests eval (#278950)
Without the change `test-pythonPackagesExtensions` test fails the eval
as:

    $ nix build -f. pythonInterpreters.pypy39_prebuilt.tests --show-trace
    error:
       … while evaluating an attribute name
         at pkgs/development/interpreters/python/tests.nix:151:16:
          150|       });
          151|     in pkgs_.${python.pythonAttr}.pkgs.foo;
             |                ^
          152|   });

       error: value is null while a string was expected

This happens because `pypy39_prebuilt` exposes `pythonAttr` attribute,
but it has a `null` value. Fix the test to filter out prebuilt pypy.
2024-01-09 18:46:49 +01:00
Thiago Kenji Okada d72b2ed9ac python27: disable tests that expect Python 3+ 2023-09-25 14:51:43 +01:00
Doron Behar ca499f6965 python.tests.tkinter: init 2023-08-19 14:00:56 +03:00
Martin Weinelt d704ee72c9 python3.tests.nixenv-virtualenv: Fix on darwin
The virtualenv mode is trying to be smart and checks whether it can
write to $out, which for some reason fails on darwin.

> virtualenv: error: argument dest: the destination . is not write-able at /nix/store

But what does work is creating it in the pwd and moving it to $out,
because mv just does what it is told.
2023-02-12 03:03:31 +01:00
Martin Weinelt 20c723dd07 python3.tests.condaExamplePackage: Exclude on non-linux
Allow python3.tests to eval on other platforms than linux, by excluding
conda tests when not on linux, because they include alsa-lib, which is
linux-only.
2023-02-11 23:22:09 +01:00
Frederik Rietdijk 2270b66d75 pythonPackagesExtensions: override all Python package sets at once
Python package sets can be overridden by overriding an interpreter
and passing in `packageOverrides = self: super: {...};`. This is fine
in case you need a single interpreter, however, it does not help you
when you want to override all sets.

With this change it is possible to override all sets at once by
appending a list of "extensions" to `pythonPackagesExtensions`.

From reading the implementation you might wonder why a list is used, and
not
`lib.composeExtensions`? The reason is the latter requires knowledge of
the library function. This approach should be easier for most users
as it is similar to how we append to lists of e.g. inputs or patches
when overriding a derivation.
2022-08-06 09:39:39 +02:00
Frederik Rietdijk 4853c2d375 python2.tests.nixenv-virtualenv: fix test
by using a python env that ignores collisions in the backports packages.
2021-12-18 14:43:50 +01:00
Robert Scott f8831c10de python3.tests: add cpython-gdb test 2021-08-19 19:37:09 +01:00
DavHau 6c0b85cf3a buildPythonPackage: add support for conda 2021-05-28 14:31:40 +02:00
Frederik Rietdijk 1e47264608 python.tests: test overriding functions 2021-02-19 10:12:21 +01:00
Frederik Rietdijk b962afabd4 python.tests: add some comments to the tests 2021-02-13 09:44:51 +01:00
Ben Siraphob 001c0cbe54 pkgs/development/interpreters: stdenv.lib -> lib 2021-01-23 20:29:03 +07:00
Frederik Rietdijk 95d9ff16f3 python.tests: not when cross-compiling
Running the tests is not possible when cross-compiling.
2020-11-23 15:29:23 +01:00
Frederik Rietdijk 5d8dd5c259 python.tests: don't mix the two types of tests
The integration tests code was included in the environment tests. After
this commit it is hopefully clearer what belongs together.
2020-08-30 12:59:24 +02:00
Frederik Rietdijk f17001afd8 Python: fix virtualenv with Python 2 2020-05-24 10:43:24 +02:00
Frederik Rietdijk 98bcf5d8da Python tests: fix use of is_virtualenv
Too many tests set it.
2020-05-24 10:43:24 +02:00
Frederik Rietdijk 2de446e0b8 python.tests: also test virtualenv
Test whether creating a virtualenv functions.
2020-05-23 18:15:45 +02:00
Frederik Rietdijk 6f873e98f4 Python integration tests: disable for older python 3 versions
because the package that is used as part of the test does not support
older versions.
2020-04-25 07:59:37 +02:00
Frederik Rietdijk 71171b3225 Python tests: test venv from a nix env with Python 3.8
This test was disabled because it did not function yet, however,
apparently it does with 3.8.
2020-04-25 07:59:37 +02:00
adisbladis 753122388d Python: Add integration test verifying NIX_PYTHONPATH with Mypy 2020-03-14 21:39:32 +00:00
adisbladis 05571d3059 Python Add test for NIX_PYTHONPREFIX 2020-03-14 21:39:31 +00:00
Frederik Rietdijk dbf125d286 Python: introduce tests for interpreters
This adds tests to the passthru of all Python interpreters.
2020-03-14 15:01:30 +01:00