diff --git a/default.nix b/default.nix index 48de43eed22de3fea61bcdfe26210b750cd27e8b..05eab10e079690079f395538aa835d703f4160a6 100644 --- a/default.nix +++ b/default.nix @@ -24,21 +24,16 @@ let self = rec { ninja ]; }; - protocol-python = pkgs.stdenv.mkDerivation { - pname = "protocol-python"; - version = "local"; + protocol-python = pythonPackages.buildPythonPackage { + name = "protocol-python-0.1.0"; src = pkgs.lib.sourceByRegex ./protocol [ "hello\.proto" + "setup\.py" ]; propagatedBuildInputs = [ pkgs.protobuf pythonPackages.protobuf ]; - phases = [ "unpackPhase" "buildPhase" ]; - buildPhase = '' - mkdir -p $out/lib/python${pkgs.lib.versions.majorMinor python3.version}/site-packages/protocol - protoc --python_out $out/lib/python${pkgs.lib.versions.majorMinor python3.version}/site-packages/protocol hello.proto - ''; }; simgrid-simulator = pkgs.stdenv.mkDerivation { pname = "simgrid-simulator"; diff --git a/protocol/setup.py b/protocol/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..3c9cfdf4ea63bcdc0f65e7a9d099b8e705fa652c --- /dev/null +++ b/protocol/setup.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +from distutils.core import setup +from distutils.spawn import find_executable +from os import makedirs +import subprocess +import sys + +protoc = find_executable('protoc') + +makedirs('protocol', exist_ok=True) +protoc_command = [protoc, '--python_out=protocol', 'hello.proto'] +if subprocess.call(protoc_command) != 0: + sys.exit(1) + +setup(name='protocol', + version='0.1.0', + packages=['protocol'], + + python_requires='>=3.6', + install_requires=[ + 'protobuf>=3.19.4', + ], + + description="Example python protocol library for DZ2 toy CI prototype.", + author='Millian Poquet', + author_email='millian.poquet@irit.fr', + url='https://gitlab.irit.fr/sepia/datazero/ci-prototype', + license='MIT', + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + ], +)