1{
2 lib,
3 stdenv,
4 python27,
5 callPackage,
6 fetchFromGitHub,
7 makeWrapper,
8 re2c,
9 # oil deps
10 glibcLocales,
11 file,
12 six,
13 typing,
14}:
15
16{
17 /*
18 Upstream isn't interested in packaging this as a library
19 (or accepting all of the patches we need to do so).
20 This creates one without disturbing upstream too much.
21 */
22 oildev = python27.pkgs.buildPythonPackage rec {
23 pname = "oildev-unstable";
24 version = "2024-02-26";
25 format = "setuptools";
26
27 src = fetchFromGitHub {
28 owner = "oilshell";
29 repo = "oil";
30 # rev == present HEAD of release/0.20.0
31 rev = "f730c79e2dcde4bc08e85a718951cfa42102bd01";
32 hash = "sha256-HBj3Izh1gD63EzbgZ/9If5vihR5L2HhnyCyMah6rMg4=";
33
34 /*
35 It's not critical to drop most of these; the primary target is
36 the vendored fork of Python-2.7.13, which is ~ 55M and over 3200
37 files, dozens of which get interpreter script patches in fixup.
38
39 Note: -f is necessary to keep it from being a pain to update
40 hash on rev updates. Command will fail w/o and not print hash.
41 */
42 postFetch = ''
43 rm -rf $out/{Python-2.7.13,metrics,py-yajl,rfc,gold,web,testdata,services,demo}
44 '';
45 };
46
47 # patch to support a python package, pass tests on macOS, drop deps, etc.
48 patchSrc = fetchFromGitHub {
49 owner = "abathur";
50 repo = "nix-py-dev-oil";
51 rev = "v0.20.0.0";
52 hash = "sha256-qoA54rnzAdnFZ3k4kRzQWEdgtEjraCT5+NFw8AWnRDk=";
53 };
54
55 patches = [
56 "${patchSrc}/0001-add_setup_py.patch"
57 "${patchSrc}/0002-add_MANIFEST_in.patch"
58 "${patchSrc}/0006-disable_failing_libc_tests.patch"
59 "${patchSrc}/0007-namespace_via_init.patch"
60 "${patchSrc}/0009-avoid_nix_arch64_darwin_toolchain_bug.patch"
61 "${patchSrc}/0010-disable-line-input.patch"
62 "${patchSrc}/0011-disable-fanos.patch"
63 "${patchSrc}/0012-disable-doc-cmark.patch"
64 "${patchSrc}/0013-fix-pyverify.patch"
65 "${patchSrc}/0015-fix-compiled-extension-import-paths.patch"
66 ];
67
68 configureFlags = [
69 "--without-readline"
70 ];
71
72 nativeBuildInputs = [
73 re2c
74 file
75 makeWrapper
76 ];
77
78 propagatedBuildInputs = [
79 six
80 typing
81 ];
82
83 doCheck = true;
84
85 preBuild = ''
86 build/py.sh all
87 '';
88
89 postPatch = ''
90 patchShebangs asdl build core doctools frontend pyext oil_lang ysh
91 rm cpp/stdlib.h # keep modules from finding the wrong stdlib?
92 # work around hard parse failure documented in oilshell/oil#1468
93 substituteInPlace osh/cmd_parse.py --replace 'elif self.c_id == Id.Op_LParen' 'elif False'
94 '';
95
96 # See earlier note on glibcLocales TODO: verify needed?
97 LOCALE_ARCHIVE = lib.optionalString (
98 stdenv.buildPlatform.libc == "glibc"
99 ) "${glibcLocales}/lib/locale/locale-archive";
100
101 # not exhaustive; sample what resholve uses as a sanity check
102 pythonImportsCheck = [
103 "oil"
104 "oil.asdl"
105 "oil.core"
106 "oil.frontend"
107 "oil._devbuild"
108 "oil._devbuild.gen.id_kind_asdl"
109 "oil._devbuild.gen.syntax_asdl"
110 "oil.osh"
111 "oil.tools.ysh_ify"
112 ];
113
114 meta = {
115 license = with lib.licenses; [
116 psfl # Includes a portion of the python interpreter and standard library
117 asl20 # Licence for Oil itself
118 ];
119 };
120 };
121}