Skip to content

Commit

Permalink
update python packages
Browse files Browse the repository at this point in the history
  • Loading branch information
zupo committed Jul 16, 2023
1 parent 708a905 commit e4dd7de
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 376 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,3 @@ jobs:
- run: nix-shell --run "make dist"

- uses: ./.github/actions/uncommitted-changes

# yamllint disable
# TODO: publishing workflow
# steps:
# - checkout

# - configure_nix

# - run:
# name: Authenticate with registry
# command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/salarycalc/.npmrc

# - run:
# name: Publish the package to NPM
# command: nix-shell --run "npm version --no-git-tag-version prerelease --preid $(date +%Y-%m-%dT%H-%M-%S) && make dist && npm publish"
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ lock:
@elm2nix snapshot > registry.dat
@nix-shell --run true
@direnv reload
@echo "-e ." >> requirements.txt
@nix-build shell.nix -A inputDerivation | cachix push niteo
@nix-build shell.nix -A inputDerivation | cachix push niteo-public
@rm result

# Build distribution files and place them where they are expected
Expand Down
69 changes: 14 additions & 55 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
{ pkgs ? import ./nix { }
# Allows CI to override this to an empty directory to determine dependencies
# Which then can get cached without the source code itself
, buildSrc ? ./.
}:
{ pkgs ? import ./nix { } }:
let

buildableShell = import ./nix/buildableShell.nix {
inherit pkgs;
# We reimport this file with buildSrc set to /var/empty such that the dev env to
# upload to cachix doesn't depend on where the project is located in the filesystem
drv = (import ./. { buildSrc = "/var/empty"; }).devShell;
};

# The development shell definition
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
# common tooling
devEnv
gitAndTools.pre-commit
niv
vim
Expand All @@ -36,6 +24,7 @@ let
# Python helper scripts
geckodriver
poetry
poetryEnv

]

Expand All @@ -53,7 +42,7 @@ let
pre-commit install -f --hook-type pre-push
fi
dest=${toString buildSrc}/node_modules
dest=./node_modules
${copyGeneratedFiles}
'';
};
Expand All @@ -80,54 +69,24 @@ let
'';

# Python stuff
removePytestRunner = pkg: pkg.overrideAttrs (old: {
postPatch = old.postPatch or "" + ''
substituteInPlace setup.py \
--replace "'pytest-runner'," "" \
--replace "'pytest-runner'" "" \
--replace '"pytest-runner",' "" \
--replace '"pytest-runner"' ""
'';
});

poetryOverrides = self: super: {
# Fails when trying to update Nix packages. Research Done here: https://github.com/teamniteo/kai/issues/238
flake8-debugger = removePytestRunner super.flake8-debugger;
flake8-mutable = removePytestRunner super.flake8-mutable;
flake8-print = removePytestRunner super.flake8-print;

isort = super.isort.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.poetry ];
});

flake8-assertive = super.flake8-assertive.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
});

};

commonPoetryArgs = {
projectDir = ./.;
poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
python = pkgs.python311;
overrides = [
pkgs.poetry2nix.defaultPoetryOverrides
poetryOverrides
];
};

# All dev and non-dev dependencies with knowledge of the salarycalc module in the source
devEnv = pkgs.poetry2nix.mkPoetryEnv (commonPoetryArgs // {
projectDir = ./.;
editablePackageSources = {
salarycalc = buildSrc + "./";
salarycalc = ./.;
};
});
overrides = pkgs.poetry2nix.defaultPoetryOverrides.extend(self: super: {

flake8-assertive = super.flake8-assertive.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
});

});
};

in {
inherit devShell;
inherit buildableShell;

# Used to install dependencies for CI and Heroku
inherit pkgs;
Expand Down
5 changes: 5 additions & 0 deletions elm-srcs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
version = "2.1.1";
};

"elm/bytes" = {
sha256 = "02ywbf52akvxclpxwj9n04jydajcbsbcbsnjs53yjc5lwck3abwj";
version = "1.0.8";
};

"elm/random" = {
sha256 = "138n2455wdjwa657w6sjq18wx2r0k60ibpc4frhbqr50sncxrfdl";
version = "1.0.0";
Expand Down
8 changes: 0 additions & 8 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{ sources ? import ./sources.nix
}:

# currently using the fork at
# https://github.com/Infinisil/yarn2nix/tree/yarnnix which includes
# https://github.com/NixOS/nixpkgs/pull/92856 (the current yarn2nix Nix code
# comes from the yarn2nix module, but it's included in nixpkgs in the future)
# yarn2nix = import sources.yarn2nix {
# inherit pkgs;
# nodejs = pkgs.nodejs-10_x;
# };
let
overlay = final: pkgs: {
gitignoreSource = (import sources.gitignore { inherit (pkgs) lib; }).gitignoreSource;
Expand Down
Loading

0 comments on commit e4dd7de

Please sign in to comment.