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

python3.7-docutils: build fix on darwin #59758

Merged

Conversation

virusdave
Copy link
Contributor

Motivation for this change

Fix python docutils package for OSX. On a relatively clean new macbook,
with latest OS Mojave 10.14.3, this package failed to build. A bit of
searching led to:
https://coderwall.com/p/-k_93g/mac-os-x-valueerror-unknown-locale-utf-8-in-python
Setting the other environment variable mentioned there (LC_ALL) sufficed to resolve the build failure.

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 nix-review --run "nix-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.

Fix python docutils package for OSX.  On a relatively clean new macbook,
with latest OS Mojave 10.14.3, this package failed to build.  A bit of
searching led to:
https://coderwall.com/p/-k_93g/mac-os-x-valueerror-unknown-locale-utf-8-in-python
@virusdave virusdave requested a review from FRidh as a code owner April 17, 2019 04:47
@GrahamcOfBorg GrahamcOfBorg added the 6.topic: darwin Running or building packages on Darwin label Apr 17, 2019
@virusdave
Copy link
Contributor Author

Notes

Before:

$ nix-channel --list
nixpkgs-19.03-darwin https://nixos.org/channels/nixpkgs-19.03-darwin

$ cat ~/.nix-defexpr/channels/nixpkgs-19.03-darwin/.git-revision 
447923f2c65d9bef54dd3e8e5bb2a1760e1df5f6

$ nix-env -i python3.7-docutils

# snip

running install tests
Traceback (most recent call last):
  File "test3/alltests.py", line 80, in <module>
    suite = suite()
  File "test3/alltests.py", line 69, in suite
    'test_', packages=1)
  File "/private/tmp/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/package_unittest.py", line 101, in loadTestModules
    module = import_module(mod)
  File "/private/tmp/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/package_unittest.py", line 132, in import_module
    mod = __import__(name)
  File "/private/tmp/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/test_command_line.py", line 19, in <module>
    locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
  File "/nix/store/ky86n177vy9h4vi62vjzsv96b4pywiwv-python3-3.7.1/lib/python3.7/locale.py", line 587, in getlocale
    return _parse_localename(localename)
  File "/nix/store/ky86n177vy9h4vi62vjzsv96b4pywiwv-python3-3.7.1/lib/python3.7/locale.py", line 495, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
builder for '/nix/store/0b6g5pa8qmcp5vxn2bip3ca6sji12zax-python3.7-docutils-0.14.drv' failed with exit code 1
error: build of '/nix/store/0b6g5pa8qmcp5vxn2bip3ca6sji12zax-python3.7-docutils-0.14.drv' failed

Googling found this page:
https://coderwall.com/p/-k_93g/mac-os-x-valueerror-unknown-locale-utf-8-in-python
which implied that LC_ALL also needed to be set.

# Use this change locally
$ NIXPKGS="/path/to/local/branch"
$ nix-env -i python3.7-docutils -f $NIXPKGS

# Snip
running install tests
Testing Docutils 0.14 with Python 3.7.3 on 2019-04-17 at 04:30:37
OS: Darwin 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 (darwin, Darwin-18.2.0-x86_64-i386-64bit)
Working directory: /private/tmp/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3
Docutils package: /private/tmp/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/build/lib/docutils
Ran 1337 tests in 8.079s

OK

# Success!

@virusdave
Copy link
Contributor Author

I've since built the jupyterlab packages successfully based on this change, which was my original intention.

@worldofpeace
Copy link
Contributor

@GrahamcOfBorg build python27Packages.docutils python37Packages.docutils

@@ -17,7 +17,7 @@ buildPythonPackage rec {

# Only Darwin needs LANG, but we could set it in general.
# It's done here conditionally to prevent mass-rebuilds.
checkPhase = lib.optionalString (isPy3k && stdenv.isDarwin) ''LANG="en_US.UTF-8" '' + (if isPy3k then ''
checkPhase = lib.optionalString (isPy3k && stdenv.isDarwin) ''LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" '' + (if isPy3k then ''
Copy link
Member

Choose a reason for hiding this comment

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

LANG is set by default now for python packages, I thought that had precedence over LC_*. Does this mean we should perhaps set both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know, to be honest. All I know is what i put above: without LC_ALL the build fails; with it set it succeeds. I just followed the instructions on the website linked above :)

@virusdave virusdave closed this Apr 17, 2019
@virusdave virusdave reopened this Apr 17, 2019
@FRidh FRidh self-assigned this Apr 18, 2019
@FRidh FRidh changed the base branch from master to staging-next April 18, 2019 06:27
@FRidh FRidh merged commit a6a88bf into NixOS:staging-next Apr 18, 2019
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

6 participants