Preheat the oven to 425°F. Remove the filo from the freezer and thaw at room temperature 1 hour.
Meanwhile, trim off both ends of the squash. Cut it in half crosswise where the neck joins the rounded body. Working with the neck end, peel off the tough skin with a vegetable peeler (or stand it on end and cut off the skin with a large knife). Cut into 3-inch chunks. Cut the rounded end in half and scoop out and discard the seeds with a spoon. Peel with a vegetable peeler or a knife and cut into 3-inch chunks.
Put the squash chunks, onions, and red pepper halves on a baking sheet so that the vegetables are as much in a single layer as possible. Sprinkle with 1 teaspoon salt and 3 tablespoons oil. Toss to coat the vegetables with the oil. Roast 30 minutes, turning the vegetables once with a spatula. Remove the pepper halves and turn everything again. Roast 10 more minutes, or until the vegetables are tender and lightly browned. Dump the squash into a large bowl. Quarter the onion slices and cut the pepper into 1-inch cubes; dump them both into the bowl. Sprinkle the vegetables with the ginger, cumin, cinnamon, cilantro, 1/2 teaspoon salt, and the pepper. Add the raisins and toss gently; set aside.
Turn the oven temperature down to 375°F. Put the walnuts on a baking sheet and toast in the oven, shaking the pan twice for even cooking, until lightly browned, 5 to 7 minutes. Remove from the oven and chop; dump them into the bowl with the vegetables and stir gently.
Meanwhile, heat the remaining 2 tablespoons olive oil with the garlic in a large frying pan over medium heat. Cook, stirring occasionally, for 2 minutes to flavor the oil. Add about one-third of the spinach and cook, turning it in the oil with tongs, until wilted, about 1 minute. Add more spinach and cook, turning as before, and then add the remaining spinach. Sprinkle with the remaining 1/2 teaspoon salt and cook until all the spinach is wilted, 2 to 3 minutes total.
To assemble the pie, have ready a 9x13-inch baking dish and a pastry brush. Pour 1/3 cup olive oil into a small bowl. Set that on a work area with the filo and the vegetables. Open the package of thawed filo and unroll the pastry sheets so that they lie flat. Brush the baking dish with olive oil. Arrange the dish so that one long side faces you. Starting at the left edge of the dish, lay one sheet of filo in the dish crosswise so that it covers about half of the bottom, and half of the sheet hangs over the side facing you. Brush the part that covers the bottom with olive oil. Now lay a second sheet along the right-hand side of the dish, overlapping the first sheet in the middle of the dish and overhanging the side facing you. Brush with olive oil. Repeat with 2 more sheets but this time arrange them in the dish so that they overhang the other long side of the dish (at the top). Continue in the same way until you've used 14 sheets of filo. (As you're working, you'll come across some sheets of pastry that stick together and rip. Discard them if you need toyou have more sheets than you need.)
Line the bottom of the dish with about half of the spinach, using your hands to open up the leaves and spread them out. Spoon the squash mixture on top and gently flatten with the spoon. Cover with the rest of the spinach. Working with the side of the dish facing you, fold one of the filo sheets over the filling and brush with oil. Fold the sheet next to it over and brush with oil. Do the same for 2 sheets on the opposing side of the dish. Continue in this way until all of the filo is folded over the filling. Then cover with 2 more sheets of filo, brushing each with more oil. (You may run out of oil. That's fine, just pour more into the dish.)
Put the baking dish in the oven and bake until the pastry is golden brown, 30 to 35 minutes. Let stand 15 minutes before serving, or let cool to room temperature. Cut pie into squares and serve.