Skip to content

Commit

Permalink
Upgrade Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Avanov committed Mar 3, 2023
1 parent fdc6157 commit ce706e6
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 56 deletions.
58 changes: 58 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{ pyVersion ? "311"
, isDevEnv ? true
}:

let
commonEnv = import ./nixpkgs {};
pkgs = commonEnv.pkgs;

python = pkgs."python${pyVersion}";
pythonPkgs = pkgs."python${pyVersion}Packages";
devLibs = if isDevEnv then [ pythonPkgs.twine pythonPkgs.wheel ] else [ pythonPkgs.coveralls ];

# Make a new "derivation" that represents our shell
devEnv = pkgs.mkShellNoCC {
name = "typeit";

# The packages in the `buildInputs` list will be added to the PATH in our shell
# Python-specific guide:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
nativeBuildInputs = with pkgs; [
# see https://nixos.org/nixos/packages.html
# Python distribution
python
pythonPkgs.virtualenv
ncurses
libxml2
libxslt
libzip
zlib
which
] ++ devLibs;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=$(date +%s)
export VENV_DIR="$PWD/.venv${pyVersion}"
export PATH=$VENV_DIR/bin:$PATH
export PYTHONPATH=""
export LANG=en_US.UTF-8
# https://python-poetry.org/docs/configuration/
export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}"
# Setup virtualenv
if [ ! -d $VENV_DIR ]; then
virtualenv $VENV_DIR
pip install -r requirements/minimal.txt
pip install -r requirements/test.txt
pip install -r requirements/extras/third_party.txt
fi
'';
};
in

{
inherit devEnv;
}
19 changes: 19 additions & 0 deletions nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{}:

let

common-src = builtins.fetchTarball {
name = "common-2023-03-03";
url = https://github.com/avanov/nix-common/archive/a30f466f3ac73842d111e80f40f287d8aa13e929.tar.gz;
# Hash obtained using `nix-prefetch-url --unpack <url>`
sha256 = "sha256:1dimd334ay4jx4n81n5ms8p4i9kpyn0z7mm8xa0kcy2cpdlbq798";
};

overlays = import ./overlays.nix {};
pkgs = (import common-src { projectOverlays = [ overlays.globalPackageOverlay ]; }).pkgs;

in

{
inherit pkgs;
}
13 changes: 13 additions & 0 deletions nixpkgs/overlays.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{}:

let

globalPackageOverlay = (self: original: rec {
# Place overrides here as described in https://nixos.wiki/wiki/Overlays#Examples_of_overlays
});

in

{
inherit globalPackageOverlay;
}
58 changes: 2 additions & 56 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,58 +1,4 @@
{
pkgs ? (import (builtins.fetchGit {
url = "https://github.com/avanov/nix-common.git";
ref = "master";
rev = "be2dc05bf6beac92fc12da9a2adae6994c9f2ee6";
}) {}).pkgs
, pyVersion ? "310"
, isDevEnv ? true
}:

let

python = pkgs."python${pyVersion}";
pythonPkgs = pkgs."python${pyVersion}Packages";
devLibs = if isDevEnv then [ pythonPkgs.twine pythonPkgs.wheel ] else [ pythonPkgs.coveralls ];
repository = import ./default.nix {};
in

# Make a new "derivation" that represents our shell
pkgs.mkShellNoCC {
name = "typeit";

# The packages in the `buildInputs` list will be added to the PATH in our shell
# Python-specific guide:
# https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md
nativeBuildInputs = with pkgs; [
# see https://nixos.org/nixos/packages.html
# Python distribution
python
pythonPkgs.virtualenv
ncurses
libxml2
libxslt
libzip
zlib
which
] ++ devLibs;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
export SOURCE_DATE_EPOCH=$(date +%s)
export VENV_DIR="$PWD/.venv${pyVersion}"
export PATH=$VENV_DIR/bin:$PATH
export PYTHONPATH=""
export LANG=en_US.UTF-8
# https://python-poetry.org/docs/configuration/
export PIP_CACHE_DIR="$PWD/.local/pip-cache${pyVersion}"
# Setup virtualenv
if [ ! -d $VENV_DIR ]; then
virtualenv $VENV_DIR
pip install -r requirements/minimal.txt
pip install -r requirements/test.txt
pip install -r requirements/extras/third_party.txt
fi
'';
}
repository.devEnv

0 comments on commit ce706e6

Please sign in to comment.