https://github.com/nix-community/nixpkgs-pytools
Tools for removing the tedious nature of creating nixpkgs derivations [maintainer=@costrouc]
https://github.com/nix-community/nixpkgs-pytools
nix nixpkgs python
Last synced: 6 months ago
JSON representation
Tools for removing the tedious nature of creating nixpkgs derivations [maintainer=@costrouc]
- Host: GitHub
- URL: https://github.com/nix-community/nixpkgs-pytools
- Owner: nix-community
- License: mit
- Created: 2018-10-12T18:39:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-08T18:46:45.000Z (7 months ago)
- Last Synced: 2025-04-03T05:26:05.039Z (7 months ago)
- Topics: nix, nixpkgs, python
- Language: Python
- Homepage:
- Size: 91.8 KB
- Stars: 47
- Watchers: 9
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# python nixpkgs tools
[](https://travis-ci.org/nix-community/nixpkgs-pytools)
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] packagepositional arguments:
package pypi package nameoptional 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 `
= callPackages ../... { };` in
`pkgs/top-level/python-modules.nix` and write the `default.nix` to
`pkgs/development/python-modules//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.```shell
nix-shell -p nixpkgs-pytools
python-package-init nixpkgs-pytools --nixpkgs-root=
```Creates a `default.nix` derivation to go into
`nixpkgs/pkgs/development/python-modules//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
```shell
nix-shell -p nixpkgs-pytoolscd /tmp
wget https://github.com/apache/airflow/archive/master.tar.gz
tar -xf master.tar.gzpython-rewrite-imports --path /tmp/airflow-master \
--replace flask_appbuilder flask_appbuilder_1_13_6237336a2b92fa6ba5f7f14dda56c08af6c0a76a \
--replace pendulum pendulum_1_4_4_55011d302b80c60360e2cc9f3a5ace7336c727c7grep -R pendulum /tmp/airflow-master
```You'll notice that all imports have been rewritten. Rewrites are done
via [rope](https://github.com/python-rope/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
```