Hi,
I've been trying to figure out how to install a local python package into my ARTIQ Nix environment on Ubuntu 22.04.4. The package will need to import ARTIQ as it implements several kernel
functions. I've been running into trouble getting Nix to include the package for me.
As a minimum example I've tried creating the following files:
artiq-8-custompkg/
├── example_pkg
│ ├── example_pkg
│ │ ├── example.py
│ │ └── __init__.py
│ ├── pyproject.toml
│ └── setup.py
└── flake.nix
The contents of each file are:
example.py
:
from artiq.experiment import kernel
def example():
print("Testing 1")
@kernel
def kernel_example():
print("Testing 2")
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
setup.py
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(name='example_pkg',
version='1.0',
# Modules to import from other scripts:
packages=find_packages(),
)
flake.nix
{
inputs.extrapkg.url = "git+https://git.m-labs.hk/M-Labs/artiq-extrapkg.git?ref=release-8";
outputs = { self, extrapkg }:
let
pkgs = extrapkg.pkgs;
artiq = extrapkg.packages.x86_64-linux;
test = extrapkg.pkgs.python3Packages.buildPythonPackage rec {
pname = "example_pkg";
version="1.0";
src = "example_pkg";
};
in {
defaultPackage.x86_64-linux = pkgs.buildEnv {
name = "artiq-env";
paths = [
# ========================================
# EDIT BELOW
# ========================================
(pkgs.python3.withPackages(ps: [
# List desired Python packages here.
artiq.artiq
ps.flask
test
]))
];
};
};
nixConfig = { # work around https://github.com/NixOS/nix/issues/6771
extra-trusted-public-keys = "nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc=";
extra-substituters = "https://nixbld.m-labs.hk";
};
}
When I run nix shell
from theartiq-8-custompkg
directory I get the following error:
error: builder for '/nix/store/ngpgf2zp3wl4xaqsvvzzwfrx296i9bsv-python3.11-example_pkg-1.0.drv' failed with exit code 1;
last 16 log lines:
> Sourcing python-remove-tests-dir-hook
> Sourcing python-catch-conflicts-hook.sh
> Sourcing python-remove-bin-bytecode-hook.sh
> Sourcing setuptools-build-hook
> Using setuptoolsBuildPhase
> Sourcing pypa-install-hook
> Using pypaInstallPhase
> Sourcing python-imports-check-hook.sh
> Using pythonImportsCheckPhase
> Sourcing python-namespaces-hook
> Sourcing python-catch-conflicts-hook.sh
> Sourcing setuptools-check-hook
> Using setuptoolsCheckPhase
> Running phase: unpackPhase
> unpacking source archive example_pkg
> do not know how to unpack source archive example_pkg
For full logs, run 'nix log /nix/store/ngpgf2zp3wl4xaqsvvzzwfrx296i9bsv-python3.11-example_pkg-1.0.drv'.
error: 1 dependencies of derivation '/nix/store/ayk4qf9wwzda1i91sbkl6f63zwab7h6q-python3-3.11.9-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nffx49gvg9x7vlff8b8sjb5dypyisqlr-artiq-env.drv' failed to build
Do I have the right approach here? Or is there a better approach for installing a local python package?