Skip to content

Commit 5b04901

Browse files
author
nix
committed
improve setup py
1 parent 4b7e82f commit 5b04901

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

flake.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
pyyaml
3434
scipy
3535
screeninfo
36+
GitPython
3637
]))
3738
];
3839
libPath = pkgs.lib.makeLibraryPath mtfgDependencies;
@@ -64,7 +65,7 @@
6465
pkgs.python39.override { inherit packageOverrides; self = customPythonPackages; };
6566
in
6667
{
67-
packages.${system}.mtfg = pkgs.stdenv.mkDerivation {
68+
packages.${system}.mtfg = pkgs.python39Packages.buildPythonPackage {
6869
pname = "MTFG";
6970
version = "0.5.3";
7071
src = pkgs.fetchgit {
@@ -74,6 +75,11 @@
7475
};
7576
buildInputs = mtfgDependencies;
7677
QT_QPA_PLATFORM = "xcb";
78+
postInstall = ''
79+
mkdir -p "$out/bin"
80+
cp -rfv "$src" "$out/bin/"
81+
'';
82+
7783
};
7884
defaultPackage.${system} = self.packages.x86_64-linux.mtfg;
7985
formatter.${system} = pkgs.nixpkgs-fmt;

setup.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@
1111
INCLUDE_REQUIREMENTS = False
1212
DOCS = ['docs/app/site', 'docs/code/_build/html']
1313

14-
TAGS = sorted(git.Repo('.').tags, key=lambda x: x.commit.committed_datetime) if os.path.exists('.git') else []
14+
try:
15+
TAGS = sorted(git.Repo('.').tags, key=lambda x: x.commit.committed_datetime) if os.path.exists('.git') else []
16+
except:
17+
print("Warning: not a git repository")
18+
TAGS = []
1519
VERSION = str(TAGS[-1]) if len(TAGS) > 0 else "0.0.0"
1620

17-
src = [os.path.join('..', x) \
18-
for x in git.Git('.').ls_files().splitlines() \
19-
if x.startswith(PACKAGE+os.sep) \
20-
and os.path.exists(x)]
21+
try:
22+
src = [os.path.join('..', x) \
23+
for x in git.Git('.').ls_files().splitlines() \
24+
if x.startswith(PACKAGE+os.sep) \
25+
and os.path.exists(x)]
26+
except:
27+
# TODO untested
28+
print("Warning fallback to glob")
29+
src = [f for f in glob.glob(PACKAGE+os.sep+"*")]
2130

2231
docs = []
2332
for docs_dir in DOCS:

0 commit comments

Comments
 (0)