Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

black: make available as application #86365

Merged
merged 1 commit into from Apr 30, 2020

Conversation

das-g
Copy link
Member

@das-g das-g commented Apr 29, 2020

Make Black available as application, but keep it as a lib, too, because some software in NixPkgs imports it as a module. (At least python3Packages.pyls-black 0.4.4 imports it in pyls_black/plugin.py.)

Motivation for this change

Primary use of this Python package is as an application (CLI tool black).

As far as I can see, Black's documentation doesn't even mention the possibility to import it as a module. But it does warn that the exposed internals "are subject to change."

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Result of nixpkgs-review 1

1 package built:
- black

but keep it as a lib, too, because some
software in NixPkgs imports it as a module.
@FRidh
Copy link
Member

FRidh commented Jun 7, 2020

I intend to revert this change.

python-packages.nix is not just about providing importable modules, but it covers all packages that are meant for the development environment bound to a Python version. It's also why e.g. test runners are there (although granted, they typically provide importable modules as well, especially pytest nowadays).

Black is always used in a development environment. If you now create a dev env, and you use the top-level black as input that is going to be problematic. This is the motivation for the split between libraries and dev tools in one hand, and Python programs in the other.

@das-g
Copy link
Member Author

das-g commented Jun 7, 2020

I intend to revert this change.

Thanks for the heads-up!

python-packages.nix is not just about providing importable modules, but it covers all packages that are meant for the development environment bound to a Python version. It's also why e.g. test runners are there (although granted, they typically provide importable modules as well, especially pytest nowadays).

[...] This is the motivation for the split between libraries and dev tools in one hand, and Python programs in the other.

Ah. I wasn't aware of the grouping-together of dev tools with libraries, but I now understand it makes sense for dev tools that must use the same Python version and/or libraries as the project on (or in) which they're used.

By the way, does that go for poetry, too? (Probably not, as the top-level poetry can be used to work with several Python versions within a project, which can be useful.)

Black is always used in a development environment.

I sometimes use black on code I don't otherwise "develop", but I guess that use-case might be somewhat exotic. (And I agree that just using black on that code is, in and of itself, also "development".)

If you now create a dev env, and you use the top-level black as input that is going to be problematic.

Does (or might) black behave differently for different Python versions and / or with different libraries available in the environment? (I guess it could. I recently noticed that isort does, due to how it distinguishes between project-internal imports and third-party imports.) I do agree this PR should be reverted in either case, I just would like to better understand the consequences of using the top-level black it provided.

@FRidh
Copy link
Member

FRidh commented Jun 7, 2020

In principle a build of black can also operate on other Python versions using a flag, but you need to pass that flag then.

Poetry is a bit more complicated. The poetry back-end (build-system) should be in python-packages.nix, but the tool not necessarily, because it is used from the outside to operate on environments. Note also that poetry is maintained using poetry2nix, so its entirely independent from python-packages.nix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants