1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

Add pre-installed python packages within rootfs overlay

TODO: This is just a quick fix and need to be changed to
buildroot packages in the upcoming days/weeks/months.
This commit is contained in:
j1nx
2022-12-08 21:02:30 +01:00
parent ce2443f753
commit 37d97e1551
36609 changed files with 7287696 additions and 0 deletions

View File

@ -0,0 +1,135 @@
#ifndef PYTHONIC_ITERTOOLS_COMBINATIONS_HPP
#define PYTHONIC_ITERTOOLS_COMBINATIONS_HPP
#include "pythonic/include/itertools/combinations.hpp"
#include "pythonic/types/dynamic_tuple.hpp"
#include "pythonic/utils/functor.hpp"
#include <numeric>
PYTHONIC_NS_BEGIN
namespace itertools
{
namespace details
{
template <class T>
template <class Iter>
combination_iterator<T>::combination_iterator(Iter &&pool, long r)
: pool(pool.begin(), pool.end()), indices(r), r(r),
stopped(r > long(this->pool.size()))
{
assert(r >= 0 && "r must be non-negative");
if (!stopped) {
std::iota(indices.begin(), indices.end(), 0);
result = std::vector<typename T::value_type>(this->pool.begin(),
this->pool.begin() + r);
}
}
template <class T>
combination_iterator<T>::combination_iterator(bool)
: stopped(true)
{
}
template <class T>
types::dynamic_tuple<typename T::value_type> combination_iterator<T>::
operator*() const
{
assert(!stopped && "! stopped");
return {result.begin(), result.end()};
}
template <class T>
combination_iterator<T> &combination_iterator<T>::operator++()
{
/* Scan indices right-to-left until finding one that is !
at its maximum (i + n - r). */
long i, n = pool.size();
for (i = r - 1; i >= 0 && indices[i] == i + n - r; i--)
;
/* If i is negative, then the indices are all at
their maximum value && we're done. */
if (i < 0)
stopped = true;
else {
/* Increment the current index which we know is ! at its
maximum. Then move back to the right setting each index
to its lowest possible value (one higher than the index
to its left -- this maintains the sort order invariant). */
indices[i]++;
for (long j = i + 1; j < r; j++)
indices[j] = indices[j - 1] + 1;
/* Update the result tuple for the new indices
starting with i, the leftmost index that changed */
for (; i < r; i++) {
result[i] = pool[indices[i]];
}
}
return *this;
}
template <class T>
bool combination_iterator<T>::
operator!=(combination_iterator const &other) const
{
assert(stopped || other.stopped);
return !(*this == other);
}
template <class T>
bool combination_iterator<T>::
operator==(combination_iterator const &other) const
{
assert(stopped || other.stopped);
return other.stopped == stopped;
}
template <class T>
bool combination_iterator<T>::
operator<(combination_iterator const &other) const
{
return stopped != other.stopped;
}
template <class T>
template <class Iter>
combination<T>::combination(Iter &&iter, long elts)
: iterator(std::forward<Iter>(iter), elts), num_elts(elts)
{
}
template <class T>
typename combination<T>::iterator const &combination<T>::begin() const
{
return *this;
}
template <class T>
typename combination<T>::iterator combination<T>::begin()
{
return *this;
}
template <class T>
typename combination<T>::iterator combination<T>::end() const
{
return {true};
}
}
template <typename T0>
details::combination<
typename std::remove_cv<typename std::remove_reference<T0>::type>::type>
combinations(T0 &&iter, long num_elts)
{
return {std::forward<T0>(iter), num_elts};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,6 @@
#ifndef PYTHONIC_ITERTOOLS_COMMON_HPP
#define PYTHONIC_ITERTOOLS_COMMON_HPP
#include "pythonic/include/itertools/common.hpp"
#endif

View File

@ -0,0 +1,104 @@
#ifndef PYTHONIC_ITERTOOLS_COUNT_HPP
#define PYTHONIC_ITERTOOLS_COUNT_HPP
#include "pythonic/include/itertools/count.hpp"
#include "pythonic/utils/functor.hpp"
#include <limits>
PYTHONIC_NS_BEGIN
namespace itertools
{
namespace details
{
template <class T>
count_iterator<T>::count_iterator(T value, T step)
: value(value), step(step)
{
}
template <class T>
T count_iterator<T>::operator*() const
{
return value;
}
template <class T>
count_iterator<T> &count_iterator<T>::operator++()
{
value += step;
return *this;
}
template <class T>
count_iterator<T> &count_iterator<T>::operator+=(long n)
{
value += step * n;
return *this;
}
template <class T>
bool count_iterator<T>::operator!=(count_iterator const &other) const
{
return value != other.value;
}
template <class T>
bool count_iterator<T>::operator==(count_iterator const &other) const
{
return value == other.value;
}
template <class T>
bool count_iterator<T>::operator<(count_iterator const &other) const
{
return value < other.value;
}
template <class T>
long count_iterator<T>::operator-(count_iterator const &other) const
{
return (value - other.value) / step;
}
template <class T>
count<T>::count(T value, T step)
: count_iterator<T>(value, step)
{
}
template <class T>
typename count<T>::iterator &count<T>::begin()
{
return *this;
}
template <class T>
typename count<T>::iterator const &count<T>::begin() const
{
return *this;
}
template <class T>
typename count<T>::iterator count<T>::end() const
{
return {std::numeric_limits<T>::max(), count_iterator<T>::step};
}
}
template <typename T0, typename T1>
details::count<typename __combined<T0, T1>::type> count(T0 start, T1 step)
{
using return_t = typename __combined<T0, T1>::type;
return {static_cast<return_t>(start), static_cast<return_t>(step)};
}
details::count<long> count()
{
return {0, 1};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,129 @@
#ifndef PYTHONIC_ITERTOOLS_IFILTER_HPP
#define PYTHONIC_ITERTOOLS_IFILTER_HPP
#include "pythonic/include/itertools/ifilter.hpp"
#include "pythonic/utils/iterator.hpp"
#include "pythonic/itertools/common.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace itertools
{
namespace details
{
template <typename Operator, typename List0>
bool ifilter_iterator<Operator, List0>::test_filter(std::false_type)
{
return op(*iter);
}
template <typename Operator, typename List0>
bool ifilter_iterator<Operator, List0>::test_filter(std::true_type)
{
return *iter;
}
template <typename Operator, typename List0>
ifilter_iterator<Operator, List0>::ifilter_iterator(Operator _op,
List0 &_seq)
: op(_op), iter(_seq.begin()), iter_end(_seq.end())
{
if (!test_filter(std::is_same<types::none_type, Operator>()))
next_value();
}
template <typename Operator, typename List0>
ifilter_iterator<Operator, List0>::ifilter_iterator(npos, Operator _op,
List0 &_seq)
: op(_op), iter(_seq.end()), iter_end(_seq.end())
{
}
template <typename Operator, typename List0>
typename List0::value_type ifilter_iterator<Operator, List0>::
operator*() const
{
return *iter;
}
template <typename Operator, typename List0>
ifilter_iterator<Operator, List0> &ifilter_iterator<Operator, List0>::
operator++()
{
next_value();
return *this;
}
template <typename Operator, typename List0>
void ifilter_iterator<Operator, List0>::next_value()
{
while (++iter != iter_end) {
if (test_filter(std::is_same<types::none_type, Operator>()))
return;
}
}
template <typename Operator, typename List0>
bool ifilter_iterator<Operator, List0>::
operator==(ifilter_iterator const &other) const
{
return !(iter != other.iter);
}
template <typename Operator, typename List0>
bool ifilter_iterator<Operator, List0>::
operator!=(ifilter_iterator const &other) const
{
return iter != other.iter;
}
template <typename Operator, typename List0>
bool ifilter_iterator<Operator, List0>::
operator<(ifilter_iterator const &other) const
{
return iter != other.iter;
}
template <typename Operator, typename List0>
ifilter<Operator, List0>::ifilter(Operator _op, List0 const &_seq)
: utils::iterator_reminder<false, List0>(_seq),
iterator(_op, this->values), end_iter(npos(), _op, this->values)
{
}
template <typename Operator, typename List0>
typename ifilter<Operator, List0>::iterator &
ifilter<Operator, List0>::begin()
{
return *this;
}
template <typename Operator, typename List0>
typename ifilter<Operator, List0>::iterator const &
ifilter<Operator, List0>::begin() const
{
return *this;
}
template <typename Operator, typename List0>
typename ifilter<Operator, List0>::iterator const &
ifilter<Operator, List0>::end() const
{
return end_iter;
}
}
template <typename Operator, typename List0>
details::ifilter<typename std::remove_cv<
typename std::remove_reference<Operator>::type>::type,
typename std::remove_cv<
typename std::remove_reference<List0>::type>::type>
ifilter(Operator &&_op, List0 &&_seq)
{
return {std::forward<Operator>(_op), std::forward<List0>(_seq)};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,128 @@
#ifndef PYTHONIC_ITERTOOLS_ISLICE_HPP
#define PYTHONIC_ITERTOOLS_ISLICE_HPP
#include "pythonic/include/itertools/islice.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/itertools/common.hpp"
#include "pythonic/builtins/range.hpp"
#include <iterator>
PYTHONIC_NS_BEGIN
namespace itertools
{
template <typename Iterable>
islice_iterator<Iterable>::islice_iterator()
{
}
template <typename Iterable>
islice_iterator<Iterable>::islice_iterator(Iterable const &iterable,
builtins::range const &xr)
: iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr),
state(xr_ref.begin()), prev(*state)
{
std::advance(this->iterable, *state);
}
template <typename Iterable>
islice_iterator<Iterable>::islice_iterator(npos const &n,
Iterable const &iterable,
builtins::range const &xr)
: iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr),
state(xr_ref.end()), prev(0)
{
}
template <typename Iterable>
typename Iterable::value_type islice_iterator<Iterable>::operator*() const
{
return *iterable;
}
template <typename Iterable>
islice_iterator<Iterable> &islice_iterator<Iterable>::operator++()
{
++state;
std::advance(this->iterable, *state - prev);
prev = *state;
return *this;
}
template <typename Iterable>
bool islice_iterator<Iterable>::
operator==(islice_iterator<Iterable> const &other) const
{
return (state == other.state);
}
template <typename Iterable>
bool islice_iterator<Iterable>::
operator!=(islice_iterator<Iterable> const &other) const
{
return state != other.state;
}
template <typename Iterable>
bool islice_iterator<Iterable>::
operator<(islice_iterator<Iterable> const &other) const
{
return state != other.state;
}
template <typename Iterable>
int islice_iterator<Iterable>::
operator-(islice_iterator<Iterable> const &other) const
{
return state - other.state;
}
template <typename Iterable>
_islice<Iterable>::_islice()
{
}
template <typename Iterable>
_islice<Iterable>::_islice(Iterable const &iterable,
builtins::range const &xr)
: iterator(iterable, xr), end_iter(npos(), iterable, xr)
{
}
template <typename Iterable>
typename _islice<Iterable>::iterator &_islice<Iterable>::begin()
{
return *this;
}
template <typename Iterable>
typename _islice<Iterable>::iterator const &_islice<Iterable>::begin() const
{
return *this;
}
template <typename Iterable>
typename _islice<Iterable>::iterator _islice<Iterable>::end() const
{
return end_iter;
}
template <typename Iterable>
_islice<typename std::remove_cv<
typename std::remove_reference<Iterable>::type>::type>
islice(Iterable &&iterable, long start, long stop, long step)
{
return {iterable, builtins::range(start, stop, step)};
}
template <typename Iterable>
_islice<typename std::remove_cv<
typename std::remove_reference<Iterable>::type>::type>
islice(Iterable &&iterable, long stop)
{
return {iterable, builtins::range(0, stop, 1)};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,143 @@
#ifndef PYTHONIC_ITERTOOLS_PERMUTATIONS_HPP
#define PYTHONIC_ITERTOOLS_PERMUTATIONS_HPP
#include "pythonic/include/itertools/permutations.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/types/dynamic_tuple.hpp"
#include "pythonic/builtins/range.hpp"
#include <algorithm>
PYTHONIC_NS_BEGIN
namespace itertools
{
template <class T>
permutations_iterator<T>::permutations_iterator()
{
}
template <class T>
permutations_iterator<T>::permutations_iterator(
std::vector<typename T::value_type> const &iter, size_t num_elts,
bool end)
: pool(iter), curr_permut(pool.size()), _size(num_elts), end(end)
{
std::iota(curr_permut.begin(), curr_permut.end(), 0);
if (num_elts > iter.size()) {
end = true;
}
}
template <class T>
types::dynamic_tuple<typename T::value_type> permutations_iterator<T>::
operator*() const
{
std::vector<typename T::value_type> res(_size);
for (size_t i = 0; i < _size; i++)
res[i] = pool[curr_permut[i]]; // Ok because types::dynamic_tuple is
// indeed a vector
return {res.begin(), res.end()};
}
template <class T>
permutations_iterator<T> &permutations_iterator<T>::operator++()
{
if (_size != pool.size()) {
// Slow path, the iterator is a "view" of a prefix smaller
// than the the pool size
// FIXME a better implementation would be to avoid
// std::next_permutation, but only in the slow path
types::dynamic_tuple<long> prev_permut(curr_permut.begin(),
curr_permut.begin() + _size);
while ((end = std::next_permutation(curr_permut.begin(),
curr_permut.end()))) {
// Check if the prefix of the new permutation is
// different of the previous one
types::dynamic_tuple<long> new_permut(curr_permut.begin(),
curr_permut.begin() + _size);
if (!(prev_permut == new_permut))
break;
}
} else
end = std::next_permutation(curr_permut.begin(), curr_permut.end());
return *this;
}
template <class T>
bool permutations_iterator<T>::
operator!=(permutations_iterator<T> const &other) const
{
return !(*this == other);
}
template <class T>
bool permutations_iterator<T>::
operator==(permutations_iterator<T> const &other) const
{
if (other.end != end)
return false;
return std::equal(curr_permut.begin(), curr_permut.end(),
other.curr_permut.begin());
}
template <class T>
bool permutations_iterator<T>::
operator<(permutations_iterator<T> const &other) const
{
if (end != other.end)
return end > other.end;
for (long i = 0; i < pool.size(); i++)
if (other.curr_permut[i] < curr_permut[i])
return false;
else if (other.curr_permut[i] > curr_permut[i])
return true;
return false;
}
template <class T>
_permutations<T>::_permutations()
{
}
template <class T>
_permutations<T>::_permutations(T iter, long elts)
: iterator(std::vector<typename T::value_type>(iter.begin(), iter.end()),
elts, true)
{
}
template <class T>
typename _permutations<T>::iterator const &_permutations<T>::begin() const
{
return *this;
}
template <class T>
typename _permutations<T>::iterator _permutations<T>::begin()
{
return *this;
}
template <class T>
typename _permutations<T>::iterator _permutations<T>::end() const
{
return iterator(iterator::pool, iterator::_size, false);
}
template <typename T0>
_permutations<T0> permutations(T0 iter, long num_elts)
{
return _permutations<T0>(iter, num_elts);
}
template <typename T0>
_permutations<T0> permutations(T0 iter)
{
return _permutations<T0>(iter, std::distance(iter.begin(), iter.end()));
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,144 @@
#ifndef PYTHONIC_ITERTOOLS_PRODUCT_HPP
#define PYTHONIC_ITERTOOLS_PRODUCT_HPP
#include "pythonic/include/itertools/product.hpp"
#include "pythonic/utils/int_.hpp"
#include "pythonic/utils/seq.hpp"
#include "pythonic/utils/iterator.hpp"
#include "pythonic/itertools/common.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace itertools
{
namespace details
{
/// product iterator implementation
template <typename... Iters>
template <size_t... I>
product_iterator<Iters...>::product_iterator(
std::tuple<Iters...> &_iters, utils::index_sequence<I...> const &)
: it_begin(std::get<I>(_iters).begin()...),
it_end(std::get<I>(_iters).end()...),
it(std::get<I>(_iters).begin()...), end(it_begin == it_end)
{
}
template <typename... Iters>
template <size_t... I>
product_iterator<Iters...>::product_iterator(
npos, std::tuple<Iters...> &_iters, utils::index_sequence<I...> const &)
: it_begin(std::get<I>(_iters).end()...),
it_end(std::get<I>(_iters).end()...),
it(std::get<I>(_iters).end()...), end(true)
{
}
template <typename... Iters>
template <size_t... I>
types::make_tuple_t<typename Iters::value_type...>
product_iterator<Iters...>::get_value(
utils::index_sequence<I...> const &) const
{
return types::make_tuple(*std::get<I>(it)...);
}
template <typename... Iters>
types::make_tuple_t<typename Iters::value_type...>
product_iterator<Iters...>::operator*() const
{
return get_value(utils::make_index_sequence<sizeof...(Iters)>{});
}
template <typename... Iters>
template <size_t N>
void product_iterator<Iters...>::advance(utils::int_<N>)
{
if (++std::get<N>(it) == std::get<N>(it_end)) {
std::get<N>(it) = std::get<N>(it_begin);
advance(utils::int_<N - 1>());
}
}
template <typename... Iters>
void product_iterator<Iters...>::advance(utils::int_<0>)
{
if (++std::get<0>(it) == std::get<0>(it_end))
end = true;
}
template <typename... Iters>
product_iterator<Iters...> &product_iterator<Iters...>::operator++()
{
advance(utils::int_<sizeof...(Iters)-1>{});
return *this;
}
template <typename... Iters>
bool product_iterator<Iters...>::
operator==(product_iterator<Iters...> const &other) const
{
return end == other.end;
}
template <typename... Iters>
bool product_iterator<Iters...>::
operator!=(product_iterator<Iters...> const &other) const
{
return end != other.end;
}
template <typename... Iters>
bool product_iterator<Iters...>::
operator<(product_iterator<Iters...> const &other) const
{
return end != other.end;
}
/// details product implementation
// FIXME: Iterators need to be evaluated as they may be used multiple
// times
template <typename... Iters>
product<Iters...>::product(Iters const &... _iters)
: utils::iterator_reminder<true, Iters...>(_iters...),
iterator(this->values,
utils::make_index_sequence<sizeof...(Iters)>{}),
end_iter(npos(), this->values,
utils::make_index_sequence<sizeof...(Iters)>{})
{
}
template <typename... Iters>
typename product<Iters...>::iterator &product<Iters...>::begin()
{
return *this;
}
template <typename... Iters>
typename product<Iters...>::iterator const &product<Iters...>::begin() const
{
return *this;
}
template <typename... Iters>
typename product<Iters...>::iterator const &product<Iters...>::end() const
{
return end_iter;
}
}
template <typename... Iter>
details::product<typename std::remove_cv<
typename std::remove_reference<Iter>::type>::type...>
product(Iter &&... iters)
{
return {std::forward<Iter>(iters)...};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,82 @@
#ifndef PYTHONIC_ITERTOOLS_REPEAT_HPP
#define PYTHONIC_ITERTOOLS_REPEAT_HPP
#include "pythonic/include/itertools/repeat.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/types/list.hpp"
PYTHONIC_NS_BEGIN
namespace itertools
{
template <class T, bool Endless>
repeat_iterator<T, Endless>::repeat_iterator(T value, long count)
: value_(value), count_(count)
{
}
template <class T, bool Endless>
repeat_iterator<T, Endless> &repeat_iterator<T, Endless>::operator++()
{
++count_;
return *this;
}
template <class T, bool Endless>
T repeat_iterator<T, Endless>::operator*()
{
return value_;
}
template <class T, bool Endless>
bool repeat_iterator<T, Endless>::
operator!=(repeat_iterator<T, Endless> const &other) const
{
return Endless || count_ != other.count_;
}
template <class T, bool Endless>
bool repeat_iterator<T, Endless>::
operator==(repeat_iterator<T, Endless> const &other) const
{
return !Endless && count_ == other.count_;
}
template <class T, bool Endless>
bool repeat_iterator<T, Endless>::
operator<(repeat_iterator<T, Endless> const &other) const
{
return !Endless && count_ < other.count_;
}
template <class T, bool Endless>
_repeat<T, Endless>::_repeat(T value, long count)
: repeat_iterator<T, Endless>(value, count)
{
}
template <class T, bool Endless>
typename _repeat<T, Endless>::iterator _repeat<T, Endless>::begin() const
{
return {_repeat<T, Endless>::iterator::value_, 0};
}
template <class T, bool Endless>
typename _repeat<T, Endless>::iterator _repeat<T, Endless>::end() const
{
return *this;
}
template <typename T>
_repeat<T, false> repeat(T value, long count)
{
return {value, count};
}
template <typename T>
_repeat<T, true> repeat(T value)
{
return {value, -1};
}
}
PYTHONIC_NS_END
#endif