Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/charmoniumQ/PROBE into data…
Browse files Browse the repository at this point in the history
…flow_graph
  • Loading branch information
Shofiya2003 committed Aug 7, 2024
2 parents 802430c + b13a0dc commit 3db6ca0
Show file tree
Hide file tree
Showing 96 changed files with 5,854 additions and 3,665 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
**/.directory
**/.Trash*
**/desktop.ini

probe_log
38 changes: 28 additions & 10 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,43 @@ check-ruff:
#ruff format --check probe_src # TODO: uncomment
ruff check probe_src

check-format-rust:
env --chdir probe_src/probe_frontend cargo fmt --check

fix-format-rust:
env --chdir probe_src/probe_frontend cargo fmt

check-clippy:
env --chdir probe_src/probe_frontend cargo clippy

fix-clippy:
env --chdir probe_src/probe_frontend cargo clippy --fix --allow-staged

check-mypy:
MYPYPATH=probe_src mypy --strict --package arena
MYPYPATH=probe_src mypy --strict --package probe_py
mypy --strict --package probe_py.manual
mypy --strict --package probe_py.generated
mypy --strict probe_src/libprobe

compile-libprobe:
compile-lib:
make --directory=probe_src/libprobe all

test-ci: compile-libprobe
make --directory=probe_src/tests/c all
cd probe_src && python -m pytest .
compile-cli:
env --chdir=probe_src/probe_frontend cargo build --release

test-dev: compile-libprobe
compile-tests:
make --directory=probe_src/tests/c all
cd probe_src && python -m pytest . --failed-first --maxfail=1

compile: compile-lib compile-cli compile-tests

test-ci: compile-lib
pytest probe_src

test-dev: compile-lib
pytest probe_src --failed-first --maxfail=1

check-flake:
nix flake check --all-systems

pre-commit: fix-format-nix fix-ruff check-mypy check-flake compile-libprobe test-dev
pre-commit: fix-format-nix fix-ruff fix-format-rust fix-clippy compile check-mypy test-dev

on-push: check-format-nix check-ruff check-mypy check-flake compile-libprobe test-ci
on-push: check-format-nix check-ruff check-format-rust check-clippy compile check-mypy check-flake test-ci
117 changes: 45 additions & 72 deletions README.md

Large diffs are not rendered by default.

77 changes: 70 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 113 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,51 +1,127 @@
{
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};

crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};

advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};

rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
python312-debug = pkgs.python312.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ ["--with-pydebug"];
# patches = oldAttrs.patches ++ [ ./python.patch ];
});
export-and-rename = pkg: file-pairs:
pkgs.stdenv.mkDerivation {
pname = "${pkg.pname}-only-bin";
rust-overlay,
...
}@inputs: let
supported-systems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
"armv7l-linux"
];
in
flake-utils.lib.eachSystem supported-systems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
python = pkgs.python312;
frontend = (import ./probe_src/probe_frontend/frontend.nix) ({ inherit system pkgs python; } // inputs);
in {
packages = rec {
probe-bundled = let
# libprobe is a "private" package
# It is only used in probe-bundled
# TODO: The only public package should probably be probe-bundled and probe-py.
libprobe = pkgs.stdenv.mkDerivation rec {
pname = "libprobe";
version = "0.1.0";
src = ./probe_src/libprobe;
makeFlags = [ "INSTALL_PREFIX=$(out)" "SOURCE_VERSION=${version}" ];
buildInputs = [
(pkgs.python312.withPackages (pypkgs: [
pypkgs.pycparser
]))
];
};
in pkgs.stdenv.mkDerivation rec {
pname = "probe-bundled";
version = "0.1.0";
dontUnpack = true;
version = pkg.version;
buildInputs = [pkg];
buildPhase =
builtins.concatStringsSep
"\n"
(builtins.map
(pairs: "install -D ${pkg}/${builtins.elemAt pairs 0} $out/${builtins.elemAt pairs 1}")
file-pairs);
dontBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase = ''
mkdir $out $out/bin
makeWrapper \
${self.packages.${system}.probe-cli}/bin/probe \
$out/bin/probe \
--set __PROBE_LIB ${libprobe}/lib
'';
};
in {
packages = {
python-dbg = python312-debug;
};
probe-py-manual = python.pkgs.buildPythonPackage rec {
pname = "probe_py.manual";
version = "0.1.0";
pyproject = true;
build-system = [
python.pkgs.flit-core
];
src = ./probe_src/python;
propagatedBuildInputs = [
self.packages.${system}.probe-py-generated
python.pkgs.networkx
python.pkgs.pygraphviz
python.pkgs.pydot
python.pkgs.rich
python.pkgs.typer
];
pythonImportsCheck = [ pname ];
};
default = probe-bundled;
} // frontend.packages;
# TODO: Run pytest tests in Nix checks
checks = self.packages.${system} // frontend.checks;
devShells = {
default = pkgs.mkShell {
default = frontend.devShells.default.overrideAttrs (oldAttrs: rec {
shellHook = ''
pushd $(git rev-parse --show-toplevel)
source ./setup_devshell.sh
popd
'';
buildInputs =
[
(pkgs.python312.withPackages (pypkgs: [
pypkgs.psutil
oldAttrs.buildInputs ++ [
(python.withPackages (pypkgs: [
# probe_py.manual runtime requirements
pypkgs.networkx
pypkgs.pygraphviz
pypkgs.pydot
pypkgs.rich
pypkgs.typer
pypkgs.pycparser

# probe_py.manual "dev time" requirements
pypkgs.psutil
pypkgs.pytest
pypkgs.mypy
pypkgs.pygraphviz
pypkgs.networkx
pypkgs.ipython
pypkgs.pydot
pypkgs.rich

# libprobe build time requirement
pypkgs.pycparser
]))
# (export-and-rename python312-debug [["bin/python" "bin/python-dbg"]])
pkgs.which
Expand All @@ -67,12 +143,12 @@
)
++ (
# while xdot isn't marked as linux only, it has a dependency (xvfb-run) that is
if builtins.elem system lib.platforms.linux
if builtins.elem system pkgs.lib.platforms.linux
then [pkgs.xdot]
else []
);
};
});
};
}
}
);
}
5 changes: 0 additions & 5 deletions probe_src/PROBE

This file was deleted.

Loading

0 comments on commit 3db6ca0

Please sign in to comment.