From f44bab6b2e473a01d3044ab01ee5b589169942e7 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Thu, 18 Jan 2024 15:10:36 -0500 Subject: [PATCH] refac(back): #1171 rm old builtin - Remove makePythonPypiEnvironment - Remove documentation Signed-off-by: Daniel Salazar --- docs/src/api/extensions/python.md | 83 +-------- docs/src/getting-started.md | 6 +- src/args/agnostic.nix | 1 - .../make-python-pypi-environment/builder.sh | 24 --- .../make-python-pypi-environment/default.nix | 165 ------------------ .../sources/numpy-1.24.0/dependencies.yaml | 1 - .../sources/numpy-1.24.0/sources-310.yaml | 19 -- .../sources/numpy-1.24.0/sources-311.yaml | 19 -- .../sources/numpy-1.24.0/sources-312.yaml | 7 - .../sources/numpy-1.24.0/sources-39.yaml | 19 -- 10 files changed, 4 insertions(+), 340 deletions(-) delete mode 100644 src/args/make-python-pypi-environment/builder.sh delete mode 100644 src/args/make-python-pypi-environment/default.nix delete mode 100644 src/args/make-python-pypi-environment/sources/numpy-1.24.0/dependencies.yaml delete mode 100644 src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-310.yaml delete mode 100644 src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-311.yaml delete mode 100644 src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-312.yaml delete mode 100644 src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-39.yaml diff --git a/docs/src/api/extensions/python.md b/docs/src/api/extensions/python.md index 0279d08a..5e81eb29 100644 --- a/docs/src/api/extensions/python.md +++ b/docs/src/api/extensions/python.md @@ -50,91 +50,10 @@ Example: } ``` -## makePythonPypiEnvironment - -Create a virtual environment -where a provided set of Python packages -from [PyPi](https://pypi.org/) -is installed. - -Pre-requisites: -[Generating a sourcesYaml](/api/builtins/utilities/#makepythonlock) - -Types: - -- makePythonPypiEnvironment: `Input -> SourceAble` -- `Input` = `Attrs` - - name: `str` - Custom name to assign to the build step, be creative, it helps in debugging. - - searchPathsBuild: `makeSearchPaths` (Optional Attr) - Arguments here will be passed as-is to `makeSearchPaths` - and used while installing the Python dependencies. - Defaults to `makeSearchPaths`'s defaults. - - searchPathsRuntime: `makeSearchPaths` (Optional Attr) - Arguments here will be passed as-is to `makeSearchPaths` - and propagated to the runtime environment. - Defaults to `makeSearchPaths`'s defaults. - - sourcesYaml: `NixPath` - `sources.yaml` file - computed as explained in the pre-requisites section. - - For building a few special packages you may need to boostrap - dependencies in the build environment. - The following flags are available for convenience: - - - withCython_0_29_24: `bool` (Optional Attr) - Bootstrap cython 0.29.24 to the environment - Defaults to `false`. - - withNumpy_1_24_0: `bool` (Optional Attr) - Bootstrap numpy 1.24.0 to the environment - Defaults to `false`. - - withSetuptools_67_7_2: `bool` (Optional Attr) - Bootstrap setuptools 67.7.2 to the environment - Defaults to `false`. - - withSetuptoolsScm_7_1_0: `bool` (Optional Attr) - Bootstrap setuptools-scm 7.1.0 to the environment - Defaults to `false`. - - withWheel_0_40_0: `bool` (Optional Attr) - Bootstrap wheel 0.40.0 to the environment - Defaults to `false`. - -Example: - -=== "main.nix" - - ```nix - # /path/to/my/project/makes/example/main.nix - { - inputs, - makePythonPypiEnvironment, - projectPath, - ... - }: - makePythonPypiEnvironment { - name = "example"; - # If some packages require compilers to be built, - # you can provide them like this: - searchPathsBuild = { - bin = [ inputs.nixpkgs.gcc ]; - }; - # You can propagate packages to the runtime environment if needed, too - searchPathsRuntime = { - bin = [ inputs.nixpkgs.htop ]; - }; - sourcesYaml = projectPath "/makes/example/sources.yaml"; - # Other packages require a few bootstrapped dependencies, - # enable them like this: - withCython_0_29_24 = true; - withSetuptools_67_7_2 = true; - withSetuptoolsScm_7_1_0 = true; - withWheel_0_40_0 = true; - } - ``` - ???+ tip Refer to [makePythonLock](/api/builtins/utilities/#makepythonlock) - to learn how to generate a `sourcesYaml`. + to learn how to generate a `poetry.lock`. ## makePythonPyprojectPackage diff --git a/docs/src/getting-started.md b/docs/src/getting-started.md index 73428236..6ef199dc 100644 --- a/docs/src/getting-started.md +++ b/docs/src/getting-started.md @@ -127,9 +127,9 @@ let }}/src/args/agnostic.nix" { }; in # Use the framework -makes.makePythonPypiEnvironment { - name = "example"; - sourcesYaml = ./sources.yaml; +makes.makePythonEnvironment { + pythonProjectDir = ./.; + pythonVersion = "3.11"; } ``` diff --git a/src/args/agnostic.nix b/src/args/agnostic.nix index daf42a03..1824b3af 100644 --- a/src/args/agnostic.nix +++ b/src/args/agnostic.nix @@ -82,7 +82,6 @@ makeNodeJsEnvironment = import ./make-node-js-environment/default.nix self; makeNodeJsModules = import ./make-node-js-modules/default.nix self; makeNomadEnvironment = import ./make-nomad-environment/default.nix self; - makePythonPypiEnvironment = import ./make-python-pypi-environment/default.nix self; makePythonEnvironment = import ./make-python-environment/default.nix self; makePythonPyprojectPackage = import ./make-python-pyproject-package/default.nix; makePythonVscodeSettings = import ./make-python-vscode-settings/default.nix self; diff --git a/src/args/make-python-pypi-environment/builder.sh b/src/args/make-python-pypi-environment/builder.sh deleted file mode 100644 index 29df9f38..00000000 --- a/src/args/make-python-pypi-environment/builder.sh +++ /dev/null @@ -1,24 +0,0 @@ -# shellcheck shell=bash - -function main { - local pip=( - python -m pip - ) - local pip_install=( - "${pip[@]}" install - --cache-dir . - --index-url "file://${PWD}/mirror" - --no-deps - ) - - pypi-mirror create \ - --download-dir "${envDownloads}" \ - --mirror-dir mirror \ - && python -m venv "${out}" \ - && source "${out}/bin/activate" \ - && HOME=. "${pip_install[@]}" --upgrade pip \ - && HOME=. "${pip_install[@]}" --requirement "${envClosure}" \ - && HOME=. "${pip[@]}" uninstall -y pip -} - -main "${@}" diff --git a/src/args/make-python-pypi-environment/default.nix b/src/args/make-python-pypi-environment/default.nix deleted file mode 100644 index f6ca6707..00000000 --- a/src/args/make-python-pypi-environment/default.nix +++ /dev/null @@ -1,165 +0,0 @@ -{ - __nixpkgs__, - attrsMapToList, - fromJsonFile, - fromYamlFile, - listOptional, - makeDerivation, - makePythonPypiEnvironment, - makeSearchPaths, - toFileLst, - toFileYaml, - ... -}: { - name, - searchPathsBuild ? {}, - searchPathsRuntime ? {}, - sourcesJson ? null, - sourcesRaw ? null, - sourcesYaml ? null, - withCython_0_29_24 ? false, - withNumpy_1_24_0 ? false, - withSetuptools_67_7_2 ? false, - withSetuptoolsScm_7_1_0 ? false, - withWheel_0_40_0 ? false, -}: -assert builtins.any (_: _) [ - (sourcesJson == null && sourcesRaw != null && sourcesYaml == null) - (sourcesJson != null && sourcesRaw == null && sourcesYaml == null) - (sourcesJson == null && sourcesRaw == null && sourcesYaml != null) -]; let - sources = - if sourcesJson != null - then fromJsonFile sourcesJson - else if sourcesRaw != null - then sourcesRaw - else if sourcesYaml != null - then fromYamlFile sourcesYaml - else abort "sourcesJson, sourcesRaw or sourcesYaml must be set"; - - is39 = sources.python == "3.9"; - is310 = sources.python == "3.10"; - is311 = sources.python == "3.11"; - is312 = sources.python == "3.12"; - python = - { - "3.9" = __nixpkgs__.python39; - "3.10" = __nixpkgs__.python310; - "3.11" = __nixpkgs__.python311; - "3.12" = __nixpkgs__.python312; - } - .${sources.python}; - - bootstraped = builtins.concatLists [ - (listOptional withCython_0_29_24 (makePythonPypiEnvironment { - name = "cython-0.29.24"; - sourcesYaml = toFileYaml "sources.yaml" { - closure.cython = "0.29.24"; - links = [ - { - name = "Cython-0.29.24-py2.py3-none-any.whl"; - sha256 = "11c3fwfhaby3xpd24rdlwjdp1y1ahz9arai3754awp0b2bq12r7r"; - url = "https://files.pythonhosted.org/packages/ec/30/8707699ea6e1c1cbe79c37e91f5b06a6266de24f699a5e19b8c0a63c4b65/Cython-0.29.24-py2.py3-none-any.whl"; - } - ]; - inherit (sources) python; - }; - })) - (listOptional withNumpy_1_24_0 (makePythonPypiEnvironment { - name = "numpy-1.24.0"; - sourcesYaml = - { - "3.9" = ./sources/numpy-1.24.0/sources-39.yaml; - "3.10" = ./sources/numpy-1.24.0/sources-310.yaml; - "3.11" = ./sources/numpy-1.24.0/sources-311.yaml; - "3.12" = ./sources/numpy-1.24.0/sources-312.yaml; - } - .${sources.python}; - withCython_0_29_24 = true; - })) - (listOptional withWheel_0_40_0 (makePythonPypiEnvironment { - name = "wheel-0.40.0"; - sourcesYaml = toFileYaml "sources.yaml" { - closure.wheel = "0.40.0"; - links = [ - { - name = "wheel-0.40.0-py3-none-any.whl"; - sha256 = "0izjbcsxh6nawadg540g34q5q758xralra0g77rdl8mmgh7b4dnj"; - url = "https://pypi.org/packages/py3/w/wheel/wheel-0.40.0-py3-none-any.whl"; - } - ]; - inherit (sources) python; - }; - })) - ]; - - pypiEnvironment = makeDerivation { - builder = ./builder.sh; - env = { - envClosure = - toFileLst "closure.lst" - (attrsMapToList (req: version: "${req}==${version}") sources.closure); - envDownloads = __nixpkgs__.linkFarm name (builtins.map - ({ - name, - sha256, - url, - }: { - inherit name; - path = __nixpkgs__.fetchurl { - inherit name; - inherit sha256; - inherit url; - curlOptsList = ["--retry" "3" "--fail"]; - }; - }) - (builtins.concatLists [ - sources.links - (listOptional withCython_0_29_24 { - name = "Cython-0.29.24-py2.py3-none-any.whl"; - sha256 = "11c3fwfhaby3xpd24rdlwjdp1y1ahz9arai3754awp0b2bq12r7r"; - url = "https://files.pythonhosted.org/packages/ec/30/8707699ea6e1c1cbe79c37e91f5b06a6266de24f699a5e19b8c0a63c4b65/Cython-0.29.24-py2.py3-none-any.whl"; - }) - (listOptional withSetuptools_67_7_2 { - name = "setuptools-67.7.2-py3-none-any.whl"; - sha256 = "0awmhw9a3z21qqhrd0xgaqjpnlbp5pqh69yk06wcwlnahmmziai3"; - url = "https://pypi.org/packages/py3/s/setuptools/setuptools-67.7.2-py3-none-any.whl"; - }) - (listOptional withSetuptoolsScm_7_1_0 { - name = "setuptools_scm-7.1.0-py3-none-any.whl"; - sha256 = "13ix4l2q4w34h1kpalyaryxr55d2dsc8r91a2jpy42c7hinqp63k"; - url = "https://files.pythonhosted.org/packages/py3/s/setuptools_scm/setuptools_scm-7.1.0-py3-none-any.whl"; - }) - (listOptional withWheel_0_40_0 { - name = "wheel-0.40.0-py3-none-any.whl"; - sha256 = "0izjbcsxh6nawadg540g34q5q758xralra0g77rdl8mmgh7b4dnj"; - url = "https://pypi.org/packages/py3/w/wheel/wheel-0.40.0-py3-none-any.whl"; - }) - (listOptional true { - name = "pip-21.2.4-py3-none-any.whl"; - sha256 = "fa9ebb85d3fd607617c0c44aca302b1b45d87f9c2a1649b46c26167ca4296323"; - url = "https://files.pythonhosted.org/packages/ca/31/b88ef447d595963c01060998cb329251648acf4a067721b0452c45527eb8/pip-21.2.4-py3-none-any.whl"; - }) - ])); - }; - inherit name; - searchPaths = { - bin = [__nixpkgs__.pypi-mirror python]; - source = builtins.concatLists [ - bootstraped - [(makeSearchPaths searchPathsBuild)] - ]; - }; - }; -in - makeSearchPaths { - bin = [pypiEnvironment]; - pythonPackage39 = listOptional is39 pypiEnvironment; - pythonPackage310 = listOptional is310 pypiEnvironment; - pythonPackage311 = listOptional is311 pypiEnvironment; - pythonPackage312 = listOptional is312 pypiEnvironment; - source = builtins.concatLists [ - bootstraped - [(makeSearchPaths searchPathsRuntime)] - ]; - } diff --git a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/dependencies.yaml b/src/args/make-python-pypi-environment/sources/numpy-1.24.0/dependencies.yaml deleted file mode 100644 index 03b0728e..00000000 --- a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/dependencies.yaml +++ /dev/null @@ -1 +0,0 @@ -numpy: 1.24.0 diff --git a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-310.yaml b/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-310.yaml deleted file mode 100644 index 9cfb3358..00000000 --- a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-310.yaml +++ /dev/null @@ -1,19 +0,0 @@ -closure: - numpy: 1.24.0 -links: - - name: numpy-1.24.0-cp310-cp310-macosx_10_9_x86_64.whl - sha256: 0dx4yy2044dzcs5mznknhyy8rczid7cb7hjvnnml4jmpypsa2wvf - url: https://files.pythonhosted.org/packages/d5/4b/ee7fc0ade6f54df52ecaf99263961d2693a22590e775730e34f89d910e6a/numpy-1.24.0-cp310-cp310-macosx_10_9_x86_64.whl - - name: numpy-1.24.0-cp310-cp310-macosx_11_0_arm64.whl - sha256: 1bw25y97n147cj6i33fvnlz4nvww3qj39h5zwwqqr3qfspbcg1wk - url: https://files.pythonhosted.org/packages/d6/71/d7125eaa3290ac95a2b7553f559f00daf81616b1db67dad065c4da687df9/numpy-1.24.0-cp310-cp310-macosx_11_0_arm64.whl - - name: numpy-1.24.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - sha256: 0blpklh6v8dkj4cpa8ywp47jrqn0x41cs0mlylc1vriflcja1mks - url: https://files.pythonhosted.org/packages/9c/46/49ba030beef06d8a5d64fd533b9f837078b1a84ddda1a4ef18081ba5fbfb/numpy-1.24.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - - name: numpy-1.24.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - sha256: 1q386bjm7wivj3bgi3ffglbp06a9anclvq68l0h0yi87b9djrkvk - url: https://files.pythonhosted.org/packages/f8/af/d6a4f957a15287faa4f5d47c8f4290fd5fac24649ed8df0e4a6634bc493a/numpy-1.24.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - - name: numpy-1.24.0.tar.gz - sha256: 0lqqa14a380y4iimpd1wkbansah93d6afz28hrg26szy26bpray4 - url: https://files.pythonhosted.org/packages/5f/c7/5ca7c100dcc85b5ef1b176bdf87be5e4392c2c3018e13cc7cdef828c6a09/numpy-1.24.0.tar.gz -python: "3.10" diff --git a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-311.yaml b/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-311.yaml deleted file mode 100644 index 34a74ce2..00000000 --- a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-311.yaml +++ /dev/null @@ -1,19 +0,0 @@ -closure: - numpy: 1.24.0 -links: - - name: numpy-1.24.0-cp311-cp311-macosx_10_9_x86_64.whl - sha256: 00gmi936rjldkzr1cg6c5b50kavsrdgbp7y09i8xdjj6n9rg8ia4 - url: https://files.pythonhosted.org/packages/1e/8a/2e23dd804191f725ff18a30468f316267be41ad07148a97eac5f48aa1d1d/numpy-1.24.0-cp311-cp311-macosx_10_9_x86_64.whl - - name: numpy-1.24.0-cp311-cp311-macosx_11_0_arm64.whl - sha256: 1mdsjmx023m9255p810v2i4i7i1lhi53shp7qbrs99m0fa0mwgpc - url: https://files.pythonhosted.org/packages/6c/90/c4a8a771b87fd7d1c9d6648fd08927825d31d80d98201149df14c9787214/numpy-1.24.0-cp311-cp311-macosx_11_0_arm64.whl - - name: numpy-1.24.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - sha256: 14axq45z7gd0gma7rc2hpm9zgzpyafrlfl6gwgc7m4cz2j88f5pr - url: https://files.pythonhosted.org/packages/f4/e1/2ec4b9476bde1e0a9878fdde5fd122241007bf361eec3fb4ab08be3aecd0/numpy-1.24.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - - name: numpy-1.24.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - sha256: 0wkaca9wpbi6xwdza5haas2wwfmp12jyw78f0bvxmslcc3lw39md - url: https://files.pythonhosted.org/packages/b0/26/8fbdd09f9926dffc272cbb266f7079963f774190ba0b5fddf72097b2c728/numpy-1.24.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - - name: numpy-1.24.0.tar.gz - sha256: 0lqqa14a380y4iimpd1wkbansah93d6afz28hrg26szy26bpray4 - url: https://files.pythonhosted.org/packages/5f/c7/5ca7c100dcc85b5ef1b176bdf87be5e4392c2c3018e13cc7cdef828c6a09/numpy-1.24.0.tar.gz -python: "3.11" diff --git a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-312.yaml b/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-312.yaml deleted file mode 100644 index cc145709..00000000 --- a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-312.yaml +++ /dev/null @@ -1,7 +0,0 @@ -closure: - numpy: 1.24.0 -links: - - name: numpy-1.24.0.tar.gz - sha256: 0lqqa14a380y4iimpd1wkbansah93d6afz28hrg26szy26bpray4 - url: https://files.pythonhosted.org/packages/5f/c7/5ca7c100dcc85b5ef1b176bdf87be5e4392c2c3018e13cc7cdef828c6a09/numpy-1.24.0.tar.gz -python: "3.12" diff --git a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-39.yaml b/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-39.yaml deleted file mode 100644 index a6d70086..00000000 --- a/src/args/make-python-pypi-environment/sources/numpy-1.24.0/sources-39.yaml +++ /dev/null @@ -1,19 +0,0 @@ -closure: - numpy: 1.24.0 -links: - - name: numpy-1.24.0-cp39-cp39-macosx_10_9_x86_64.whl - sha256: 1sppa1bkkx7cd00m584kas60dqvx40w1j29y156fmy1cc2kzc4db - url: https://files.pythonhosted.org/packages/51/5f/65b0a05c28913932dc6e587abed4b1419eaaef90455273a071c67e9dc7fd/numpy-1.24.0-cp39-cp39-macosx_10_9_x86_64.whl - - name: numpy-1.24.0-cp39-cp39-macosx_11_0_arm64.whl - sha256: 1lfbf6y787wiq3d5r2n7nvbha310mvn6kw0z5wgrh6413mbabfqj - url: https://files.pythonhosted.org/packages/da/f6/a35d900170b4d0d9ab798c167ac3ed58aad90af420f22930205e5292bba9/numpy-1.24.0-cp39-cp39-macosx_11_0_arm64.whl - - name: numpy-1.24.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - sha256: 0h8yxkl063pkmr6b4kjivdhr5202afavr7kl3pchfc1d9mwizycs - url: https://files.pythonhosted.org/packages/12/18/396e3b4c796527bd5d0c10d591d077643295604ffebe4602baeff1809659/numpy-1.24.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl - - name: numpy-1.24.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - sha256: 1xa1nbx0a3yhrn21d3b52jxw0s1ckh5wjdllx74g7m42dandy7cb - url: https://files.pythonhosted.org/packages/a8/e7/695aa010663d32e55622fb41fac3e4217b2cfb88a94b7e1c336819e8d4e3/numpy-1.24.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - - name: numpy-1.24.0.tar.gz - sha256: 0lqqa14a380y4iimpd1wkbansah93d6afz28hrg26szy26bpray4 - url: https://files.pythonhosted.org/packages/5f/c7/5ca7c100dcc85b5ef1b176bdf87be5e4392c2c3018e13cc7cdef828c6a09/numpy-1.24.0.tar.gz -python: "3.9"