Tools for removing the tedious nature of creating nixpkgs derivations
Project description
python nixpkgs tools
These are scripts written to remove the tedious nature of creating nix package derivations for nixpkgs. The goal of these scripts is not to create a perfect package derivation but complete as much as possible and guide the user on necessary changes.
python-package-init
usage: python-package-init [-h] [--version VERSION] [--filename FILENAME] [--stdout] [--nixpkgs-root NIXPKGS_ROOT] [-f] package
positional arguments:
package pypi package name
optional arguments:
-h, --help show this help message and exit
--version VERSION pypi package version (stable if not specified)
--filename FILENAME filename for nix derivation
--stdout Print the nix derivation to stdout
--nixpkgs-root NIXPKGS_ROOT
Root directory of nixpkgs
-f, --force Force creation of file, overwriting when it already exists
python-package-init now has the ability to create a <package-name> = callPackages ../...<package-name> { }; in
pkgs/top-level/python-modules.nix and write the default.nix to
pkgs/development/python-modules/<package-name>/default.nix with a
nearly complete derivation.
Example lets add nixpkgs-pytools to nixpkgs. It is already in
nixpkgs so you would need to provide the -f (force) option to force
it to be written to nixpkgs.
nix-shell -p nixpkgs-pytools
python-package-init nixpkgs-pytools --nixpkgs-root=<path to nixpkgs>
Creates a default.nix derivation to go into
nixpkgs/pkgs/development/python-modules/<pypi-name>/default.nix. This
script is overly verbose so that you don't have to remember the name
of attributes. Delete the ones that you don't need.
python-rewrite-imports
usage: python-rewrite-imports [-h] --path PATH [--replace REPLACE REPLACE]
optional arguments:
-h, --help show this help message and exit
--path PATH path to refactor imports
--replace REPLACE REPLACE
module import to replace
example rewriting airflow imports
nix-shell -p nixpkgs-pytools
cd /tmp
wget https://github.com/apache/airflow/archive/master.tar.gz
tar -xf master.tar.gz
python-rewrite-imports --path /tmp/airflow-master \
--replace flask_appbuilder flask_appbuilder_1_13_6237336a2b92fa6ba5f7f14dda56c08af6c0a76a \
--replace pendulum pendulum_1_4_4_55011d302b80c60360e2cc9f3a5ace7336c727c7
grep -R pendulum /tmp/airflow-master
You'll notice that all imports have been rewritten. Rewrites are done via rope a robust refactoring library used by many text editors.
Hacking on these tools
nix-shell will load the correct environment for your usage:
nix-shell
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nixpkgs-pytools-1.3.0.tar.gz.
File metadata
- Download URL: nixpkgs-pytools-1.3.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29585690d2fd1d09d218bbb28b9f5f0b4e75c97271c622d36638391ae2625387
|
|
| MD5 |
69ed281210c9c4e9e1ab76ec8abf6829
|
|
| BLAKE2b-256 |
ec1a3f01a58ee79d657e6f083b5a351742338db77926035a7f896c6ee57bf61b
|
File details
Details for the file nixpkgs_pytools-1.3.0-py3-none-any.whl.
File metadata
- Download URL: nixpkgs_pytools-1.3.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f1a200b7de80cc0951179ceca37489d7a6078989b06fb4eb28108087b1bbc8
|
|
| MD5 |
fd25b12927aa1c33159dcd2a7866a5b5
|
|
| BLAKE2b-256 |
7a26a16adc8e2e8ed4e02cbe0b0e6a860eed8d0554c4fdf234c4c0a6e8291dfb
|