-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #395 from replit/dstewart/feat/python-module-compo…
…sition feat/python module composition
- Loading branch information
Showing
5 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ pkgs, lib, ... }: | ||
{ | ||
id = "pyright"; | ||
name = "pyright LSP"; | ||
displayVersion = pkgs.pyright.version; | ||
description = '' | ||
Pyright is a full-featured, standards-based static type checker for Python. It is designed for high performance and can be used with large Python source bases. | ||
''; | ||
replit.dev.languageServers.pyright = { | ||
name = "pyright"; | ||
displayVersion = pkgs.pyright.version; | ||
language = "python3"; | ||
start = "${pkgs.pyright}/bin/pyright-langserver --stdio"; | ||
}; | ||
|
||
replit.env = { | ||
PATH = "${pkgs.pyright}/bin"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{ python, pypkgs }: | ||
{ pkgs-unstable, pkgs-23_05, lib, ... }: | ||
let | ||
pythonVersion = lib.versions.majorMinor python.version; | ||
|
||
pkgs = pkgs-unstable; | ||
|
||
pylibs-dir = ".pythonlibs"; | ||
|
||
userbase = "$REPL_HOME/${pylibs-dir}"; | ||
|
||
pythonUtils = import ../../python-utils { | ||
inherit pkgs python pypkgs; | ||
}; | ||
python-ld-library-path = pythonUtils.python-ld-library-path; | ||
|
||
sitecustomize = pkgs.callPackage ../python/sitecustomize.nix { }; | ||
|
||
binary-wrapped-python = pkgs.callPackage ../../python-wrapped { | ||
inherit pkgs python python-ld-library-path; | ||
}; | ||
|
||
in | ||
{ | ||
id = "python-base-${pythonVersion}"; | ||
name = "Python Tools"; | ||
displayVersion = pythonVersion; | ||
description = '' | ||
Basic module for Python. Includes the interpreter and basic Replit | ||
configuration but nothing else. This may be combined with the | ||
pyright-extended module. | ||
''; | ||
|
||
replit.packages = [ | ||
binary-wrapped-python | ||
pypkgs.pip | ||
pkgs.poetry | ||
pkgs.uv | ||
]; | ||
|
||
replit.runners.python = { | ||
name = "Python ${pythonVersion}"; | ||
displayVersion = python.version; | ||
fileParam = true; | ||
language = "python3"; | ||
start = "${python}/bin/python3 $file"; | ||
defaultEntrypoints = [ "main.py" "app.py" "run.py" ]; | ||
}; | ||
|
||
replit.dev.packagers.upmPython = { | ||
name = "Python packager"; | ||
language = "python3"; | ||
ignoredPackages = [ "unit_tests" ]; | ||
ignoredPaths = [ pylibs-dir ]; | ||
features = { | ||
packageSearch = true; | ||
guessImports = true; | ||
enabledForHosting = false; | ||
}; | ||
}; | ||
|
||
replit.env = { | ||
PYTHONUSERBASE = userbase; | ||
PYTHONPATH = "${sitecustomize}"; | ||
REPLIT_PYTHONPATH = "${userbase}/${python.sitePackages}:${pypkgs.setuptools}/${python.sitePackages}"; | ||
UV_PROJECT_ENVIRONMENT = "$REPL_HOME/.pythonlibs"; | ||
# Even though it is set-default in the wrapper, add it to the | ||
# environment too, so that when someone wants to override it, | ||
# they can keep the defaults if they want to. | ||
PYTHON_LD_LIBRARY_PATH = python-ld-library-path; | ||
PATH = "${userbase}/bin"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ pkgs, lib, ... }: | ||
{ | ||
id = "ruff"; | ||
name = "ruff LSP"; | ||
displayVersion = pkgs.ruff.version; | ||
description = '' | ||
A Language Server Protocol implementation for Ruff, an extremely fast Python linter and code formatter, written in Rust. | ||
Ruff can be used to replace Flake8 (plus dozens of plugins), Black, isort, pyupgrade, and more, all while executing tens or hundreds of times faster than any individual tool. | ||
''; | ||
replit.dev.languageServers.ruff = { | ||
name = "ruff"; | ||
displayVersion = pkgs.ruff.version; | ||
language = "python3"; | ||
start = "${pkgs.ruff}/bin/ruff server"; | ||
}; | ||
|
||
replit.env = { | ||
PATH = "${pkgs.ruff}/bin"; | ||
}; | ||
} |