;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013 Nikita Karetnikov ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge ;;; Copyright © 2014, 2015 Mark H Weaver ;;; Copyright © 2014, 2017, 2019 Eric Bavier ;;; Copyright © 2014, 2015 Federico Beffa ;;; Copyright © 2015 Omar Radwan ;;; Copyright © 2015 Pierre-Antoine Rault ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus ;;; Copyright © 2015, 2016 Christopher Allan Webber ;;; Copyright © 2015 Eric Dvorsak ;;; Copyright © 2015, 2016 David Thompson ;;; Copyright © 2015, 2016, 2017, 2021 Leo Famulari ;;; Copyright © 2015, 2017 Ben Woodcroft ;;; Copyright © 2015, 2016 Erik Edrosa ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Efraim Flashner ;;; Copyright © 2015, 2017 Kyle Meyer ;;; Copyright © 2015, 2016 Chris Marusich ;;; Copyright © 2016 Danny Milosavljevic ;;; Copyright © 2016 Lukas Gradl ;;; Copyright © 2016, 2018 Hartmut Goebel ;;; Copyright © 2016 Daniel Pimentel ;;; Copyright © 2016 Sou Bunnbu ;;; Copyright © 2016, 2017 Troy Sankey ;;; Copyright © 2016, 2017 Nikita ;;; Copyright © 2016 Dylan Jeffers ;;; Copyright © 2016 David Craven ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke ;;; Copyright © 2016, 2017 Stefan Reichör // -*- C++ -*- // Boost general library 'format' --------------------------- // See http://www.boost.org for updates, documentation, and revision history. // (C) Samuel Krempp 2001 // krempp@crans.ens-cachan.fr // Permission to copy, use, modify, sell and // distribute this software is granted provided this copyright notice appears // in all copies. This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // ideas taken from Rüdiger Loos's format class // and Karl Nelson's ofstream // ---------------------------------------------------------------------------- // group.hpp : encapsulates a group of manipulators along with an argument // // group_head : cut the last element of a group out. // (is overloaded below on each type of group) // group_last : returns the last element of a group // (is overloaded below on each type of group) // ---------------------------------------------------------------------------- #ifndef BOOST_FORMAT_GROUP_HPP #define BOOST_FORMAT_GROUP_HPP namespace boost { namespace io { namespace detail { // empty group, but useful even though. struct group0 { group0() {} }; template <class Ch, class Tr> inline BOOST_IO_STD ostream& operator << ( BOOST_IO_STD ostream& os, const group0& ) { return os; } template <class T1> struct group1 { T1 a1_; group1(T1 a1) : a1_(a1) {} }; template <class Ch, class Tr, class T1> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group1<T1>& x) { os << x.a1_; return os; } template <class T1,class T2> struct group2 { T1 a1_; T2 a2_; group2(T1 a1,T2 a2) : a1_(a1),a2_(a2) {} }; template <class Ch, class Tr, class T1,class T2> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group2<T1,T2>& x) { os << x.a1_<< x.a2_; return os; } template <class T1,class T2,class T3> struct group3 { T1 a1_; T2 a2_; T3 a3_; group3(T1 a1,T2 a2,T3 a3) : a1_(a1),a2_(a2),a3_(a3) {} }; template <class Ch, class Tr, class T1,class T2,class T3> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group3<T1,T2,T3>& x) { os << x.a1_<< x.a2_<< x.a3_; return os; } template <class T1,class T2,class T3,class T4> struct group4 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; group4(T1 a1,T2 a2,T3 a3,T4 a4) : a1_(a1),a2_(a2),a3_(a3),a4_(a4) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group4<T1,T2,T3,T4>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_; return os; } template <class T1,class T2,class T3,class T4,class T5> struct group5 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; group5(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group5<T1,T2,T3,T4,T5>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_; return os; } template <class T1,class T2,class T3,class T4,class T5,class T6> struct group6 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; T6 a6_; group6(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group6<T1,T2,T3,T4,T5,T6>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_; return os; } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7> struct group7 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; T6 a6_; T7 a7_; group7(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group7<T1,T2,T3,T4,T5,T6,T7>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_; return os; } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> struct group8 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; T6 a6_; T7 a7_; T8 a8_; group8(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group8<T1,T2,T3,T4,T5,T6,T7,T8>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_; return os; } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> struct group9 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; T6 a6_; T7 a7_; T8 a8_; T9 a9_; group9(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8),a9_(a9) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group9<T1,T2,T3,T4,T5,T6,T7,T8,T9>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_; return os; } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> struct group10 { T1 a1_; T2 a2_; T3 a3_; T4 a4_; T5 a5_; T6 a6_; T7 a7_; T8 a8_; T9 a9_; T10 a10_; group10(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9,T10 a10) : a1_(a1),a2_(a2),a3_(a3),a4_(a4),a5_(a5),a6_(a6),a7_(a7),a8_(a8),a9_(a9),a10_(a10) {} }; template <class Ch, class Tr, class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> inline BOOST_IO_STD ostream& operator << (BOOST_IO_STD ostream& os, const group10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>& x) { os << x.a1_<< x.a2_<< x.a3_<< x.a4_<< x.a5_<< x.a6_<< x.a7_<< x.a8_<< x.a9_<< x.a10_; return os; } template <class T1,class T2> inline group1<T1> group_head( group2<T1,T2> const& x) { return group1<T1> (x.a1_); } template <class T1,class T2> inline group1<T2> group_last( group2<T1,T2> const& x) { return group1<T2> (x.a2_); } template <class T1,class T2,class T3> inline group2<T1,T2> group_head( group3<T1,T2,T3> const& x) { return group2<T1,T2> (x.a1_,x.a2_); } template <class T1,class T2,class T3> inline group1<T3> group_last( group3<T1,T2,T3> const& x) { return group1<T3> (x.a3_); } template <class T1,class T2,class T3,class T4> inline group3<T1,T2,T3> group_head( group4<T1,T2,T3,T4> const& x) { return group3<T1,T2,T3> (x.a1_,x.a2_,x.a3_); } template <class T1,class T2,class T3,class T4> inline group1<T4> group_last( group4<T1,T2,T3,T4> const& x) { return group1<T4> (x.a4_); } template <class T1,class T2,class T3,class T4,class T5> inline group4<T1,T2,T3,T4> group_head( group5<T1,T2,T3,T4,T5> const& x) { return group4<T1,T2,T3,T4> (x.a1_,x.a2_,x.a3_,x.a4_); } template <class T1,class T2,class T3,class T4,class T5> inline group1<T5> group_last( group5<T1,T2,T3,T4,T5> const& x) { return group1<T5> (x.a5_); } template <class T1,class T2,class T3,class T4,class T5,class T6> inline group5<T1,T2,T3,T4,T5> group_head( group6<T1,T2,T3,T4,T5,T6> const& x) { return group5<T1,T2,T3,T4,T5> (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_); } template <class T1,class T2,class T3,class T4,class T5,class T6> inline group1<T6> group_last( group6<T1,T2,T3,T4,T5,T6> const& x) { return group1<T6> (x.a6_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7> inline group6<T1,T2,T3,T4,T5,T6> group_head( group7<T1,T2,T3,T4,T5,T6,T7> const& x) { return group6<T1,T2,T3,T4,T5,T6> (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7> inline group1<T7> group_last( group7<T1,T2,T3,T4,T5,T6,T7> const& x) { return group1<T7> (x.a7_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> inline group7<T1,T2,T3,T4,T5,T6,T7> group_head( group8<T1,T2,T3,T4,T5,T6,T7,T8> const& x) { return group7<T1,T2,T3,T4,T5,T6,T7> (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> inline group1<T8> group_last( group8<T1,T2,T3,T4,T5,T6,T7,T8> const& x) { return group1<T8> (x.a8_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> inline group8<T1,T2,T3,T4,T5,T6,T7,T8> group_head( group9<T1,T2,T3,T4,T5,T6,T7,T8,T9> const& x) { return group8<T1,T2,T3,T4,T5,T6,T7,T8> (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_,x.a8_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> inline group1<T9> group_last( group9<T1,T2,T3,T4,T5,T6,T7,T8,T9> const& x) { return group1<T9> (x.a9_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> inline group9<T1,T2,T3,T4,T5,T6,T7,T8,T9> group_head( group10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> const& x) { return group9<T1,T2,T3,T4,T5,T6,T7,T8,T9> (x.a1_,x.a2_,x.a3_,x.a4_,x.a5_,x.a6_,x.a7_,x.a8_,x.a9_); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> inline group1<T10> group_last( group10<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> const& x) { return group1<T10> (x.a10_); } } // namespace detail // helper functions inline detail::group1< detail::group0 > group() { return detail::group1< detail::group0 > ( detail::group0() ); } template <class T1, class Var> inline detail::group1< detail::group2<T1, Var const&> > group(T1 a1, Var const& var) { return detail::group1< detail::group2<T1, Var const&> > ( detail::group2<T1, Var const&> (a1, var) ); } template <class T1,class T2, class Var> inline detail::group1< detail::group3<T1,T2, Var const&> > group(T1 a1,T2 a2, Var const& var) { return detail::group1< detail::group3<T1,T2, Var const&> > ( detail::group3<T1,T2, Var const&> (a1,a2, var) ); } template <class T1,class T2,class T3, class Var> inline detail::group1< detail::group4<T1,T2,T3, Var const&> > group(T1 a1,T2 a2,T3 a3, Var const& var) { return detail::group1< detail::group4<T1,T2,T3, Var const&> > ( detail::group4<T1,T2,T3, Var const&> (a1,a2,a3, var) ); } template <class T1,class T2,class T3,class T4, class Var> inline detail::group1< detail::group5<T1,T2,T3,T4, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4, Var const& var) { return detail::group1< detail::group5<T1,T2,T3,T4, Var const&> > ( detail::group5<T1,T2,T3,T4, Var const&> (a1,a2,a3,a4, var) ); } template <class T1,class T2,class T3,class T4,class T5, class Var> inline detail::group1< detail::group6<T1,T2,T3,T4,T5, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5, Var const& var) { return detail::group1< detail::group6<T1,T2,T3,T4,T5, Var const&> > ( detail::group6<T1,T2,T3,T4,T5, Var const&> (a1,a2,a3,a4,a5, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6, class Var> inline detail::group1< detail::group7<T1,T2,T3,T4,T5,T6, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6, Var const& var) { return detail::group1< detail::group7<T1,T2,T3,T4,T5,T6, Var const&> > ( detail::group7<T1,T2,T3,T4,T5,T6, Var const&> (a1,a2,a3,a4,a5,a6, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7, class Var> inline detail::group1< detail::group8<T1,T2,T3,T4,T5,T6,T7, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7, Var const& var) { return detail::group1< detail::group8<T1,T2,T3,T4,T5,T6,T7, Var const&> > ( detail::group8<T1,T2,T3,T4,T5,T6,T7, Var const&> (a1,a2,a3,a4,a5,a6,a7, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8, class Var> inline detail::group1< detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, Var const& var) { return detail::group1< detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var const&> > ( detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var const&> (a1,a2,a3,a4,a5,a6,a7,a8, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9, class Var> inline detail::group1< detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var const&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9, Var const& var) { return detail::group1< detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var const&> > ( detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var const&> (a1,a2,a3,a4,a5,a6,a7,a8,a9, var) ); } #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST template <class T1, class Var> inline detail::group1< detail::group2<T1, Var&> > group(T1 a1, Var& var) { return detail::group1< detail::group2<T1, Var&> > ( detail::group2<T1, Var&> (a1, var) ); } template <class T1,class T2, class Var> inline detail::group1< detail::group3<T1,T2, Var&> > group(T1 a1,T2 a2, Var& var) { return detail::group1< detail::group3<T1,T2, Var&> > ( detail::group3<T1,T2, Var&> (a1,a2, var) ); } template <class T1,class T2,class T3, class Var> inline detail::group1< detail::group4<T1,T2,T3, Var&> > group(T1 a1,T2 a2,T3 a3, Var& var) { return detail::group1< detail::group4<T1,T2,T3, Var&> > ( detail::group4<T1,T2,T3, Var&> (a1,a2,a3, var) ); } template <class T1,class T2,class T3,class T4, class Var> inline detail::group1< detail::group5<T1,T2,T3,T4, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4, Var& var) { return detail::group1< detail::group5<T1,T2,T3,T4, Var&> > ( detail::group5<T1,T2,T3,T4, Var&> (a1,a2,a3,a4, var) ); } template <class T1,class T2,class T3,class T4,class T5, class Var> inline detail::group1< detail::group6<T1,T2,T3,T4,T5, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5, Var& var) { return detail::group1< detail::group6<T1,T2,T3,T4,T5, Var&> > ( detail::group6<T1,T2,T3,T4,T5, Var&> (a1,a2,a3,a4,a5, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6, class Var> inline detail::group1< detail::group7<T1,T2,T3,T4,T5,T6, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6, Var& var) { return detail::group1< detail::group7<T1,T2,T3,T4,T5,T6, Var&> > ( detail::group7<T1,T2,T3,T4,T5,T6, Var&> (a1,a2,a3,a4,a5,a6, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7, class Var> inline detail::group1< detail::group8<T1,T2,T3,T4,T5,T6,T7, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7, Var& var) { return detail::group1< detail::group8<T1,T2,T3,T4,T5,T6,T7, Var&> > ( detail::group8<T1,T2,T3,T4,T5,T6,T7, Var&> (a1,a2,a3,a4,a5,a6,a7, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8, class Var> inline detail::group1< detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8, Var& var) { return detail::group1< detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var&> > ( detail::group9<T1,T2,T3,T4,T5,T6,T7,T8, Var&> (a1,a2,a3,a4,a5,a6,a7,a8, var) ); } template <class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9, class Var> inline detail::group1< detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var&> > group(T1 a1,T2 a2,T3 a3,T4 a4,T5 a5,T6 a6,T7 a7,T8 a8,T9 a9, Var& var) { return detail::group1< detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var&> > ( detail::group10<T1,T2,T3,T4,T5,T6,T7,T8,T9, Var&> (a1,a2,a3,a4,a5,a6,a7,a8,a9, var) ); } #endif //end- #ifndef BOOST_NO_OVERLOAD_FOR_NON_CONST } // namespace io } // namespace boost #endif // BOOST_FORMAT_GROUP_HPP '((add-before 'configure 'support-hurd-cross-compile (lambda _ (substitute* "configure" (("\\*-\\*-vxworks.*" all) (string-append "*-*-gnu)\nac_sys_system=GNU\n;;\n" all))) #t))) '()) (add-before 'check 'set-TZDIR (lambda* (#:key inputs native-inputs #:allow-other-keys) ;; test_email requires the Olson time zone database. (setenv "TZDIR" (string-append (assoc-ref (or native-inputs inputs) "tzdata") "/share/zoneinfo")) #t)) ;; Unset SOURCE_DATE_EPOCH while running the test-suite and set it ;; again afterwards. See . (add-before 'check 'unset-SOURCE_DATE_EPOCH (lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t)) (add-after 'check 'reset-SOURCE_DATE_EPOCH (lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t)) (replace 'rebuild-bytecode (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) ;; Disable hash randomization to ensure the generated .pycs ;; are reproducible. (setenv "PYTHONHASHSEED" "0") (for-each (lambda (opt) (format #t "Compiling with optimization level: ~a\n" (if (null? opt) "none" (car opt))) (for-each (lambda (file) (apply invoke `(,,(if (%current-target-system) "python3" '(string-append out "/bin/python3")) ,@opt "-m" "compileall" "-f" ; force rebuild ;; Don't build lib2to3, because it's Python 2 code. "-x" "lib2to3/.*" ,file))) (find-files out "\\.py$"))) (list '() '("-O") '("-OO"))) #t))) ;; XXX: Apply patch on ARM platforms only to avoid a full rebuild. ;; Remove this phase in the next rebuild cycle. ,@(let ((system (or (%current-target-system) (%current-system)))) (if (any (cute string-prefix? <> system) '("arm" "aarch64")) '((add-after 'unpack 'apply-alignment-patch (lambda* (#:key native-inputs inputs #:allow-other-keys) (invoke "patch" "-p1" "--force" "--input" (assoc-ref (or native-inputs inputs) "arm-alignment.patch"))))) '())))))) (native-inputs `(("tzdata" ,tzdata-for-tests) ;; Disable unaligned accesses in the sha3 module on ARM as ;; it causes a test failure when building 32-bit Python on a ;; 64-bit kernel. See . ;; TODO: make this a regular patch in the next rebuild cycle. ,@(let ((system (or (%current-target-system) (%current-system)))) (if (any (cute string-prefix? <> system) '("arm" "aarch64")) `(("arm-alignment.patch" ,(search-patch "python-3-arm-alignment.patch"))) '())) ,@(if (%current-target-system) `(("python3" ,this-package)) '()) ,@(package-native-inputs python-2))) (native-search-paths (list (search-path-specification (variable "PYTHONPATH") (files (list (string-append "lib/python" (version-major+minor version) "/site-packages")))))))) (define-public python-3.9 (package (inherit python-3.8) (name "python-next") (version "3.9.2") (source (origin (method url-fetch) (uri (string-append "https://www.python.org/ftp/python/" version "/Python-" version ".tar.xz")) (patches (search-patches "python-3.9-fix-tests.patch" "python-3-deterministic-build-info.patch" "python-3-search-paths.patch")) (sha256 (base32 "0z94vv5qhlwvcgc4sy9sdiqs0220s84wx3b62vslh5419z2k881w")) (modules '((guix build utils))) (snippet '(begin ;; Delete the bundled copy of libexpat. (delete-file-recursively "Modules/expat") (substitute* "Modules/Setup" ;; Link Expat instead of embedding the bundled one. (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n")) #t)))))) ;; Current 3.x version. (define-public python-3 python-3.8) ;; Current major version. (define-public python python-3) ;; Minimal variants of Python, mostly used to break the cycle between Tk and ;; Python (Tk -> libxcb -> Python.) (define-public python2-minimal (package/inherit python-2 (name "python2-minimal") (outputs '("out")) ;; Keep zlib, which is used by 'pip' (via the 'zipimport' module), which ;; is invoked upon 'make install'. 'pip' also expects 'ctypes' and thus ;; libffi. Expat is needed for XML support which is expected by a lot ;; of libraries out there. (inputs `(("expat" ,expat) ("libffi" ,libffi) ("zlib" ,zlib))))) (define-public python-minimal (package/inherit python (name "python-minimal") (outputs '("out")) ;; Build fails due to missing ctypes without libffi. ;; OpenSSL is a mandatory dependency of Python 3.x, for urllib; ;; zlib is required by 'zipimport', used by pip. Expat is needed ;; for XML support, which is generally expected to be available. (inputs `(("expat" ,expat) ("libffi" ,libffi) ("openssl" ,openssl) ("zlib" ,zlib))))) (define-public python-debug (package/inherit python (name "python-debug") (outputs '("out" "debug")) (build-system gnu-build-system) (arguments (substitute-keyword-arguments (package-arguments python) ((#:configure-flags flags '()) `(cons "--with-pydebug" ,flags)))) (synopsis "High-level, dynamically-typed programming language (for debugging)") (description "This variant of Python provides an interpreter built with @code{--with-pydebug} to help develop and debug extensions. See @url{https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug.html}, for more information."))) (define* (wrap-python3 python #:optional (name (string-append (package-name python) "-wrapper"))) (package/inherit python (name name) (source #f) (build-system trivial-build-system) (outputs '("out")) (inputs `(("bash" ,bash))) (propagated-inputs `(("python" ,python))) (arguments `(#:modules ((guix build utils)) #:builder (begin (use-modules (guix build utils)) (let ((bin (string-append (assoc-ref %outputs "out") "/bin")) (python (string-append (assoc-ref %build-inputs "python") "/bin/"))) (mkdir-p bin) (for-each (lambda (old new) (symlink (string-append python old) (string-append bin "/" new))) `("python3" ,"pydoc3" ,"idle3" ,"pip3") `("python" ,"pydoc" ,"idle" ,"pip")) ;; python-config outputs search paths based upon its location, ;; use a bash wrapper to avoid changing its outputs. (let ((bash (string-append (assoc-ref %build-inputs "bash") "/bin/bash")) (old (string-append python "python3-config")) (new (string-append bin "/python-config"))) (with-output-to-file new (lambda () (format #t "#!~a~%" bash) (format #t "exec \"~a\" \"$@\"~%" old) (chmod new #o755) #t))))))) (synopsis "Wrapper for the Python 3 commands") (description "This package provides wrappers for the commands of Python@tie{}3.x such that they can be invoked under their usual name---e.g., @command{python} instead of @command{python3} or @command{pip} instead of @command{pip3}. To function properly, this package should not be installed together with the @command{python} package."))) (define-public python-wrapper (wrap-python3 python)) (define-public python-minimal-wrapper (wrap-python3 python-minimal)) (define-public micropython (package (name "micropython") (version "1.15") (source (origin (method url-fetch) (uri (string-append "https://github.com/micropython/micropython/" "releases/download/v" version "/micropython-" version ".tar.xz")) (sha256 (base32 "04sfrfcljhfps340l4wh5ffwkhw1ydraday8nv92nv7gmnrj1l2j")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "ports/cc3200/FreeRTOS") (with-directory-excursion "lib" ;; TODO: Unbundle axtls and berkley-db-1.xx (for-each delete-file-recursively '("libffi" "lwip" "stm32lib" "nrfx"))) #t)))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'build 'build-mpy-cross (lambda* (#:key make-flags #:allow-other-keys) (with-directory-excursion "mpy-cross" (apply invoke "make" make-flags)))) (add-after 'build-mpy-cross 'prepare-build (lambda _ (chdir "ports/unix") ;; see: https://github.com/micropython/micropython/pull/4246 (substitute* "Makefile" (("-Os") "-Os -ffp-contract=off")) #t)) (replace 'install-license-files ;; We don't build in the root directory so the file isn't found. (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (dest (string-append out "/share/doc/" ,name "-" ,version "/"))) (install-file "../../LICENSE" dest)) #t)) (delete 'configure)) ; no configure #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) "V=1") #:test-target "test")) (native-inputs `(("pkg-config" ,pkg-config) ("python" ,python-wrapper))) (inputs `(("libffi" ,libffi))) (home-page "https://micropython.org/") (synopsis "Python implementation for microcontrollers and constrained systems") (description "MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments. MicroPython is packed full of advanced features such as an interactive prompt, arbitrary precision integers, closures, list comprehension, generators, exception handling and more. Still it is compact enough to fit and run within just 256k of code space and 16k of RAM. MicroPython aims to be as compatible with normal Python as possible to allow you to transfer code with ease from the desktop to a microcontroller or embedded system.") (license license:expat))) (define-public pypy3 (package (name "pypy3") (version "7.3.1") (source (origin (method url-fetch) (uri (string-append "https://bitbucket.org/pypy/pypy/downloads/" ; "pypy3.6-v" version "-src.tar.bz2")) (sha256 (base32 "10zsk8jby8j6visk5mzikpb1cidvz27qq4pfpa26jv53klic6b0c")) (patches (search-patches "pypy3-7.3.1-fix-tests.patch")))) (build-system gnu-build-system) (native-inputs `(("python-2" ,python-2) ("pkg-config" ,pkg-config) ("tar" ,tar) ; Required for package.py ("python2-pycparser" ,python2-pycparser) ("python2-hypothesis" ,python2-hypothesis) ("nss-certs" ,nss-certs) ; For ssl tests ("gzip" ,gzip))) (inputs `(("libffi" ,libffi) ("zlib" ,zlib) ("ncurses" ,ncurses) ("openssl" ,openssl) ("expat" ,expat) ("bzip2" ,bzip2) ("sqlite" ,sqlite) ("gdbm" ,gdbm) ("tcl" ,tcl) ("tk" ,tk) ("glibc" ,glibc) ("bash-minimal" ,bash-minimal) ; Used as /bin/sh ("xz" ,xz))) ; liblzma (arguments `(#:tests? #f ;FIXME: Disabled for now, there are many tests failing. #:modules ((ice-9 ftw) (ice-9 match) (guix build utils) (guix build gnu-build-system)) #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'patch-source (lambda* (#:key inputs outputs #:allow-other-keys) (substitute* '("rpython/rlib/clibffi.py") ;; find_library does not work for libc (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'")) (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py") ;; Make reproducible (XXX: unused?) (("time\\.localtime\\(\\)") "time.gmtime(0)")) (substitute* '("pypy/module/sys/version.py") ;; Make reproducible (("t\\.gmtime\\(\\)") "t.gmtime(0)")) (substitute* '("lib_pypy/_tkinter/tklib_build.py") ;; Link to versioned libtcl and libtk (("linklibs = \\['tcl', 'tk'\\]") "linklibs = ['tcl8.6', 'tk8.6']") (("incdirs = \\[\\]") (string-append "incdirs = ['" (assoc-ref inputs "tcl") "/include', '" (assoc-ref inputs "tk") "/include']"))) (substitute* '("lib_pypy/_curses_build.py") ;; Find curses (("/usr/local") (assoc-ref inputs "ncurses"))) (substitute* '("lib_pypy/_sqlite3_build.py") ;; Always use search paths (("sys\\.platform\\.startswith\\('freebsd'\\)") "True") ;; Find sqlite3 (("/usr/local") (assoc-ref inputs "sqlite")) (("libname = 'sqlite3'") (string-append "libname = '" (assoc-ref inputs "sqlite") "/lib/libsqlite3.so.0'"))) (substitute* '("lib-python/3/subprocess.py") ;; Fix shell path (("/bin/sh") (string-append (assoc-ref inputs "bash-minimal") "/bin/sh"))) (substitute* '("lib-python/3/distutils/unixccompiler.py") ;; gcc-toolchain does not provide symlink cc -> gcc (("\"cc\"") "\"gcc\"")) #t)) (add-after 'unpack 'set-source-file-times-to-1980 ;; copied from python package, required by zip testcase (lambda _ (let ((circa-1980 (* 10 366 24 60 60))) (ftw "." (lambda (file stat flag) (utime file circa-1980 circa-1980) #t)) #t))) (replace 'build (lambda* (#:key inputs #:allow-other-keys) (with-directory-excursion "pypy/goal" ;; Build with jit optimization. (invoke "python2" "../../rpython/bin/rpython" (string-append "--make-jobs=" (number->string (parallel-job-count))) "-Ojit" "targetpypystandalone")) ;; Build c modules and package everything, so tests work. (with-directory-excursion "pypy/tool/release" (unsetenv "PYTHONPATH") ; Do not use the system’s python libs: ; AttributeError: module 'enum' has no ; attribute 'IntFlag' (invoke "python2" "package.py" "--archive-name" "pypy-dist" "--builddir" (getcwd))))) (replace 'check (lambda* (#:key tests? #:allow-other-keys) (if tests? (begin (setenv "HOME" "/tmp") ; test_with_pip tries to ; access ~/.cache/pip ;; Run library tests only (no interpreter unit ;; tests). This is what Gentoo does. (invoke "python2" "pypy/test_all.py" "--pypy=pypy/tool/release/pypy-dist/bin/pypy3" "lib-python")) (format #t "test suite not run~%")) #t)) (replace 'install (lambda* (#:key inputs outputs #:allow-other-keys) (with-directory-excursion "pypy/tool/release" ;; Delete test data. (for-each (lambda (x) (delete-file-recursively (string-append "pypy-dist/lib-python/3/" x))) '("tkinter/test" "test" "sqlite3/test" "lib2to3/tests" "idlelib/idle_test" "distutils/tests" "ctypes/test" "unittest/test")) ;; Patch shebang referencing python2 (substitute* '("pypy-dist/lib-python/3/cgi.py" "pypy-dist/lib-python/3/encodings/rot_13.py") (("#!.+/bin/python") (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3"))) (with-fluids ((%default-port-encoding "ISO-8859-1")) (substitute* '("pypy-dist/lib_pypy/_md5.py" "pypy-dist/lib_pypy/_sha1.py") (("#!.+/bin/python") (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3")))) (copy-recursively "pypy-dist" (assoc-ref outputs "out"))) #t))))) (home-page "https://www.pypy.org/") (synopsis "Python implementation with just-in-time compilation") (description "PyPy is a faster, alternative implementation of the Python programming language employing a just-in-time compiler. It supports most Python code natively, including C extensions.") (license (list license:expat ; pypy itself; _pytest/ license:psfl ; python standard library in lib-python/ license:asl2.0 ; dotviewer/font/ and some of lib-python/ license:gpl3+ ; ./rpython/rlib/rvmprof/src/shared/libbacktrace/dwarf2.* license:bsd-3 ; lib_pypy/cffi/_pycparser/ply/ (license:non-copyleft "http://www.unicode.org/copyright.html")))))