Skip to content

Commit

Permalink
Rewrite CLI in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
domenkozar committed Jul 21, 2023
1 parent eccc6e6 commit f395c91
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Nix & devenv
result
.env*
/.env*
.devenv*
/.cache
/.pre-commit-config.yaml
Expand Down
4 changes: 4 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{ pkgs, inputs }:

let
python = pkgs.python3Minimal.override { openssl = true; self = python; };
in
(inputs.poetry2nix.legacyPackages.${pkgs.stdenv.system}.mkPoetryApplication {
projectDir = ./.;
inherit python;
}).overrideAttrs (old: {
propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
++ [ inputs.nix.packages.${pkgs.stdenv.system}.nix ];
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/cachix/devenv"
packages = [{include = "devenv", from = "src"}]
include = [
{ path = "src", format = ["sdist", "wheel"] },
{ path = "examples", format = ["sdist", "wheel"] }
{ path = "examples/simple", format = ["sdist", "wheel"] }
]

[tool.poetry.dependencies]
Expand Down
11 changes: 7 additions & 4 deletions src/devenv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"warn-dirty",
"false",
]

SRC_DIR = Path(pkgutil.get_loader(__package__).load_module(__package__).__file__, '..', '..')
FILE = pkgutil.get_loader(__package__).load_module(__package__).__file__
if 'site-packages' in FILE:
SRC_DIR = Path(FILE, '..', '..', 'src')
else:
SRC_DIR = Path(FILE, '..', '..')
MODULES_DIR = (SRC_DIR / 'modules').resolve()
FLAKE_FILE_TEMPL = os.path.join(MODULES_DIR, "flake.tmpl.nix")
FLAKE_FILE = ".devenv.flake.nix"
Expand Down Expand Up @@ -360,7 +363,7 @@ def init(target):
return

example = "simple"
examples_path = Path(MODULES_DIR, "..", "..", "examples")
examples_path = Path(MODULES_DIR / ".." / ".." / "examples").resolve()

for filename in required_files:
full_filename = Path(target, filename)
Expand Down Expand Up @@ -417,4 +420,4 @@ def print_dev_env():

def get_version():
with open(Path(MODULES_DIR, "latest-version")) as f:
return f.read().strip()
return f.read().strip()

0 comments on commit f395c91

Please sign in to comment.