Navigation Menu

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

Python: merge expressions of interpreters #53123

Merged
merged 5 commits into from Jan 4, 2019
Merged

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Dec 31, 2018

  • Merge CPython expressions
  • Merge PyPy expressions
  • Improve cross-compilation of Python packages
  • Drop python.majorVersion attribute
  • Introduce derivations for prebuilt PyPy binaries.
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-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)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

pkgs/top-level/python-packages.nix Outdated Show resolved Hide resolved
pkgs/development/interpreters/python/default.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@FRidh FRidh force-pushed the singlecpython branch 2 times, most recently from e09dcd7 to baf965e Compare December 31, 2018 13:43
@FRidh
Copy link
Member Author

FRidh commented Dec 31, 2018

cc @LnL7 for Darwin
cc @Mic92 for cross

@FRidh FRidh force-pushed the singlecpython branch 3 times, most recently from 5fa8ca8 to 4a8932b Compare December 31, 2018 17:54
@Mic92
Copy link
Member

Mic92 commented Jan 2, 2019

I will have a look at cross-compiling once the conflict is resolved.

@FRidh
Copy link
Member Author

FRidh commented Jan 2, 2019

@Mic92 not sure whether to trust this function:

$(nix-build -A pkgsCross.musl64.python3)/bin/python -c "import platform; print(platform.python_compiler())"
GCC 7.4.0

@Mic92
Copy link
Member

Mic92 commented Jan 2, 2019

@FRidh what's wrong with the output? Afaik we build with gcc for musl.

@FRidh
Copy link
Member Author

FRidh commented Jan 2, 2019

yes, I mixed host and build up when I wrote that.

@Ericson2314
Copy link
Member

Very glad this is happening! I started something like the once, but it appears I lost it haha.

@FRidh FRidh added 8.has: clean-up 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on 1.severity: mass-rebuild labels Jan 3, 2019
@FRidh FRidh force-pushed the singlecpython branch 2 times, most recently from e4eca87 to 99faaf7 Compare January 3, 2019 17:50
@FRidh FRidh changed the title WIP: CPython: merge expressions of interpreters into single expression Python: merge expressions of interpreters Jan 3, 2019
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking really good!

@@ -10,7 +9,7 @@
, ... } @ attrs:

attrs // {
buildInputs = buildInputs ++ [ bootstrapped-pip ];
buildInputs = buildInputs ++ [ python.pythonForBuild.pkgs.bootstrapped-pip ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bootstrapped pip is used at build time and so should be a nativeBuildInput.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, since you use it explicitly below, maybe it doesn't need to be any sort of imput.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I don't think we actually need it as a build input. We call it already from the store path, and Python packages should never call or import from pip. Doesn't mean they won't do it though...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we do need it as *buildInput. While it is indeed supposed to be nativeBuildInput, putting it there breaks cross-compilation for me, likely because at the moment something wrong is happening yet it looks alright. I'll keep this issue for another day.

@@ -24,7 +23,7 @@ attrs // {
export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"

pushd dist
${bootstrapped-pip}/bin/pip install *.whl --no-index --prefix=$out --no-cache ${toString installFlags} --build tmpbuild
${python.pythonForBuild.pkgs.bootstrapped-pip}/bin/pip install *.whl --no-index --prefix=$out --no-cache ${toString installFlags} --build tmpbuild
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B. this is fine, but won't need it once bootstrapped-pip is a nativeBuildInput.

pushd $out
ls -l .
find {lib,lib_pypy*} -name "*.so" -exec patchelf --replace-needed "libbz2.so.1.0" "libbz2.so.1" {} \;
find {lib,lib_pypy*} -name "*.so" -exec patchelf --set-rpath ${stdenv.lib.makeLibraryPath deps} {} \;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future autoPatchelfHook could make this process easier and less error-prone.

Each time a new major/minor version of CPython was released, a new
expression would be written, typically copied from the previous release.
Often fixes are only made in the current/latest release. By merging the
expressions it's more likely that modifications end up in all versions,
as is likely intended.

This commit introduces one expression for Python 3, and another for 2.7.
These two may also be merged, but it will result in a lot of extra
conditionals making the expression harder to follow.

A common passthru is introduced for CPython and PyPy.

python 2.7: use common passthru
This commit merges the two expressions in a single one, using
the passthru function that is shared with CPython.
This changeset allows for cross-compilation of Python packages. Packages
built with buildPythonPackage are not allowed to refer to the build
machine. Executables that have shebangs will refer to the host.
Drop `python.majorVersion`. For Python language version, use `python.pythonVersion`.
For implementation version, use `python.sourceVersion`.

Some expressions were broken. Those that were identified were fixed.

fixup major
These interpreters are prebuilt by upstream and patched using patchelf.
They are primarily added for testing purposes and development on the
non-prebuilt PyPy interpreters as it can speed up translation
significantly.
@FRidh FRidh merged commit 29ee864 into NixOS:staging Jan 4, 2019
@FRidh FRidh deleted the singlecpython branch January 4, 2019 11:23
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

5 participants