Browse Source

Merge pull request #11759 from jefferyto/python2-remove-interpreter

python: Remove package
lilik-openwrt-22.03
Hannu Nyman 4 years ago
committed by GitHub
parent
commit
1460e34d95
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 82 additions and 2190 deletions
  1. +82
    -170
      lang/python/README.md
  2. +0
    -95
      lang/python/python-host.mk
  3. +0
    -153
      lang/python/python-package.mk
  4. +0
    -15
      lang/python/python-version.mk
  5. +0
    -7
      lang/python/python/Config-python-light.in
  6. +0
    -380
      lang/python/python/Makefile
  7. +0
    -12
      lang/python/python/files/config.site
  8. +0
    -80
      lang/python/python/files/python-config.in
  9. +0
    -23
      lang/python/python/files/python-package-codecs.mk
  10. +0
    -16
      lang/python/python/files/python-package-compiler.mk
  11. +0
    -18
      lang/python/python/files/python-package-ctypes.mk
  12. +0
    -18
      lang/python/python/files/python-package-db.mk
  13. +0
    -16
      lang/python/python/files/python-package-decimal.mk
  14. +0
    -27
      lang/python/python/files/python-package-dev.mk
  15. +0
    -16
      lang/python/python/files/python-package-distutils.mk
  16. +0
    -16
      lang/python/python/files/python-package-email.mk
  17. +0
    -16
      lang/python/python/files/python-package-gdbm.mk
  18. +0
    -18
      lang/python/python/files/python-package-lib2to3.mk
  19. +0
    -16
      lang/python/python/files/python-package-logging.mk
  20. +0
    -17
      lang/python/python/files/python-package-multiprocessing.mk
  21. +0
    -18
      lang/python/python/files/python-package-ncurses.mk
  22. +0
    -17
      lang/python/python/files/python-package-openssl.mk
  23. +0
    -30
      lang/python/python/files/python-package-pip.mk
  24. +0
    -28
      lang/python/python/files/python-package-pkg-resources.mk
  25. +0
    -18
      lang/python/python/files/python-package-pydoc.mk
  26. +0
    -31
      lang/python/python/files/python-package-setuptools.mk
  27. +0
    -17
      lang/python/python/files/python-package-sqlite3.mk
  28. +0
    -16
      lang/python/python/files/python-package-unittest.mk
  29. +0
    -20
      lang/python/python/files/python-package-xml.mk
  30. +0
    -16
      lang/python/python/patches-setuptools/001-reproducible.patch
  31. +0
    -16
      lang/python/python/patches-setuptools/002-sorted-requires.patch
  32. +0
    -14
      lang/python/python/patches-setuptools/003-PKG-INFO-output-reproducible.patch
  33. +0
    -20
      lang/python/python/patches/001-enable-zlib.patch
  34. +0
    -12
      lang/python/python/patches/002-do-not-add-include-dirs-when-cross-compiling.patch
  35. +0
    -18
      lang/python/python/patches/003-do-not-compile-tests-at-build.patch
  36. +0
    -11
      lang/python/python/patches/004-do-not-write-bytes-codes.patch
  37. +0
    -57
      lang/python/python/patches/005-fix-bluetooth-support.patch
  38. +0
    -16
      lang/python/python/patches/006-remove-multi-arch-and-local-paths.patch
  39. +0
    -10
      lang/python/python/patches/007-distutils-do-not-adjust-path.patch
  40. +0
    -50
      lang/python/python/patches/008-distutils-use-python-sysroot.patch
  41. +0
    -32
      lang/python/python/patches/009-do-not-use-dblib_dir-when-cross-compiling.patch
  42. +0
    -13
      lang/python/python/patches/010-do-not-add-rt-lib-dirs-when-cross-compiling.patch
  43. +0
    -10
      lang/python/python/patches/012-add-support-source-date-epoch-pyc.patch
  44. +0
    -28
      lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch
  45. +0
    -31
      lang/python/python/patches/021-compileall-add-recursion-option.patch
  46. +0
    -74
      lang/python/python/patches/024-musl-find_library.patch
  47. +0
    -11
      lang/python/python/patches/025-utime.patch
  48. +0
    -209
      lang/python/python/patches/026-bpo-34585-Dont-do-runtime-test-to-get-float-byte-order-GH-9085.patch
  49. +0
    -218
      lang/python/python/patches/027-bpo-34585-run-autoconf-GH-9411-edited.patch

+ 82
- 170
lang/python/README.md View File

@ -1,18 +1,15 @@
# Python packages folder
:warning: **Python 2 will soon be unsupported and removed from the feed - [see below](#python-2-end-of-life)** :warning:
## Table of contents
1. [Description](#description)
2. [Python 2 end-of-life](#python-2-end-of-life)
1. [Transition policy / schedule](#transition-policy--schedule)
3. [Introduction](#introduction)
4. [Using Python[3] in external/other package feeds](#using-python3-in-externalother-package-feeds)
2. [Introduction](#introduction)
3. [Python 2 end-of-life](#python-2-end-of-life)
4. [Using Python in external/other package feeds](#using-python-in-externalother-package-feeds)
5. [Build considerations](#build-considerations)
6. [General folder structure](#general-folder-structure)
7. [Building a Python[3] package](#building-a-python3-package)
1. [Include python[3]-package.mk](#include-python3-packagemk)
7. [Building a Python package](#building-a-python-package)
1. [Include python3-package.mk](#include-python3-packagemk)
2. [Add Package/<PKG_NAME> OpenWrt definitions](#add-packagepkg_name-openwrt-definitions)
3. [Wrapping things up so that they build](#wrapping-things-up-so-that-they-build)
4. [Customizing things](#customizing-things)
@ -22,49 +19,21 @@
This section describes specifics for the Python packages that are present in this repo, and how things are structured.
In terms of license, contributing guide, etc, all of that information is described in the top [README.md](README.md) file, and it applies here as well. This document attempts to cover only technical aspects of Python/Python3 packages, and maybe some explanations about how things are (and why they are as they are).
## Python 2 end-of-life
Python 2 will not be maintained past [1 January 2020](https://pythonclock.org/). As such, we will be transitioning Python 2 programs and libraries to Python 3, and Python 2 packages will be removed in early 2020.
(Discussion for how to handle this transition can be found in [#8520](https://github.com/openwrt/packages/issues/8520).)
### Transition policy / schedule
A mass removal event ("The Snap") will occur on 31 March 2020, or 2 weeks before the freeze for a 20.x release, whichever is sooner. The exact date will be confirmed when the 20.x release schedule is known, or by 15 March 2020.
All Python 2 packages (the Python 2 interpreter, programs that depend on Python 2, and Python 2-only libraries) will be removed during this event.
Leading up to "The Snap":
* In general, new Python 2 packages are no longer accepted
* Exceptions can be made on a case-by-case basis, given extraordinary circumstances or reasons, until 31 May 2019
* From 31 May 2019 onward, absolutely no new Python 2 packages will be accepted
* The Python 2 interpreter will remain in the feed until "The Snap"
* The interpreter will continue to be updated, including the last release in January 2020 (if there is one)
* Programs that depend on Python 2 will be transitioned to Python 3 (see [#8893](https://github.com/openwrt/packages/issues/8893))
* If a program cannot be transitioned, a suitable replacement will be found
* If a replacement cannot be found, the program will be removed during "The Snap"
* Python 2 libraries will remain in the feed until "The Snap"
* For any Python 2-only libraries, a Python 3 version will be added (or a suitable replacement found), if its Python 3 version is a dependency of another package in the feed
* Python 2 libraries will receive normal updates until 31 October 2019
* From 31 October 2019 onward:
* Python 2-only libraries will receive security updates only
* Python 2 libraries that share the same Makefile as their Python 3 version will continue to receive normal updates
In terms of license, contributing guide, etc, all of that information is described in the top [README.md](README.md) file, and it applies here as well. This document attempts to cover only technical aspects of Python packages, and maybe some explanations about how things are (and why they are as they are).
## Introduction
This sub-tree came to exist after a number of contributions (Python packages) were made to this repo, and the [lang](lang) subtree grew to a point where a decision was made to move all Python packages under [lang/python](lang/python).
It contains the 2 Python interpreters (Python & Python3) and Python packages. Most of the Python packages are downloaded from [pypi.org](https://pypi.org/). Python packages from [pypi.org](https://pypi.org/) are typically preferred when adding new packages.
It contains the Python 3 interpreter and Python packages. Most of the Python packages are downloaded from [pypi.org](https://pypi.org/). Python packages from [pypi.org](https://pypi.org/) are typically preferred when adding new packages.
If more packages (than the ones packaged here) are needed, they can be downloaded via [pip](https://pip.pypa.io). Note that the versions of `pip` & `setuptools` [available in this repo] are the ones that are packaged inside the Python package (yes, Python comes packaged with `pip` & `setuptools`).
If more packages (than the ones packaged here) are needed, they can be downloaded via [pip or pip3](https://pip.pypa.io). Note that the versions of `pip` & `setuptools` [available in this repo] are the ones that are packaged inside the Python & Python3 packages (yes, Python & Python3 come packaged with `pip` & `setuptools`).
## Python 2 end-of-life
Python 2 [will not be maintained past 2020](https://www.python.org/dev/peps/pep-0373/). All Python 2 packages have been removed from the packages feed (this repo) and archived in the [abandoned packages feed](https://github.com/openwrt/packages-abandoned).
## Using Python[3] in external/other package feeds
## Using Python in external/other package feeds
In the feeds.conf (or feeds.conf.default file, whatever is preferred), the packages repo should be present.
@ -79,14 +48,12 @@ src-git telephony https://git.openwrt.org/feed/telephony.git
src-git someotherfeed https://github.com/<github-user>/<some-other-package>
```
Assuming that there are Python packages in the `<some-other-package>`, they should include `python[3]-package.mk` like this:
Assuming that there are Python packages in the `<some-other-package>`, they should include `python3-package.mk` like this:
```
include $(TOPDIR)/feeds/packages/lang/python/python-package.mk
include $(TOPDIR)/feeds/packages/lang/python/python3-package.mk
```
Same rules apply for `python[3]-package.mk` as the Python packages in this repo.
And if only 1 of `python-package.mk` or `python3-package.mk` is needed, then only the needed mk file should be included (though it's not an issue if both are included).
Same rules apply for `python3-package.mk` as the Python packages in this repo.
**One important consideration:**: if the local name is not `packages`, it's something else, like `openwrt-packages`. And in `feeds.conf[.default]` it's:
```
@ -95,7 +62,6 @@ src-git openwrt-packages https://git.openwrt.org/feed/packages.git
Then, the inclusions also change:
```
include $(TOPDIR)/feeds/openwrt-packages/lang/python/python-package.mk
include $(TOPDIR)/feeds/openwrt-packages/lang/python/python3-package.mk
```
@ -104,86 +70,73 @@ Each maintainer[s] of external packages feeds is responsible for the local name,
In case there is a need/requirement such that the local package feed is named something else than `packages`, one approach to make the package flexible to change is:
```
PYTHON_PACKAGE_MK:=$(wildcard $(TOPDIR)/feeds/*/lang/python/python-package.mk)
PYTHON3_PACKAGE_MK:=$(wildcard $(TOPDIR)/feeds/*/lang/python/python3-package.mk)
# verify that there is only one single file returned
ifneq (1,$(words $(PYTHON_PACKAGE_MK)))
ifeq (0,$(words $(PYTHON_PACKAGE_MK)))
$(error did not find python-package.mk in any feed)
ifneq (1,$(words $(PYTHON3_PACKAGE_MK)))
ifeq (0,$(words $(PYTHON3_PACKAGE_MK)))
$(error did not find python3-package.mk in any feed)
else
$(error found multiple python-package.mk files in the feeds)
$(error found multiple python3-package.mk files in the feeds)
endif
else
$(info found python-package.mk at $(PYTHON_PACKAGE_MK))
$(info found python3-package.mk at $(PYTHON3_PACKAGE_MK))
endif
include $(PYTHON_PACKAGE_MK)
include $(PYTHON3_PACKAGE_MK)
```
Same can be done for `python3-package.mk`.
This should solve the corner-case where the `python[3]-package.mk` can be in some other feed, or if the packages feed will be named something else locally.
This should solve the corner-case where the `python3-package.mk` can be in some other feed, or if the packages feed will be named something else locally.
## Build considerations
In order to build the Python[3] interpreters, a host Python/Python3 interpreter needs to be built, in order to process some of the build for the target Python/Python3 build. The host Python[3] interpreters are also needed so that Python bytecodes are generated, so the host interpreters need to be the exact versions as on the target. And finally, the host Python[3] interpreters also provide pip & pip3, so that they may be used to install some Python[3] packages that are required to build other Python[3] packages.
That's why you'll also see a Python/Python3 build & staging directories.
In order to build the Python interpreter, a host Python interpreter needs to be built, in order to process some of the build for the target Python build. The host Python interpreter is also needed so that Python bytecodes are generated, so the host interpreter needs to be the exact version as on the target. And finally, the host Python interpreter also provides pip, so that it may be used to install some Python packages that are required to build other Python packages.
That's why you'll also see a Python build & staging directories.
As you're probably thinking, this sounds [and is] somewhat too much complication [just for packaging], but the status of things is-as-it-is, and it's probably much worse than what's currently visible on the surface [with respect to packaging Python[3] & packages].
As you're probably thinking, this sounds [and is] somewhat too much complication [just for packaging], but the status of things is-as-it-is, and it's probably much worse than what's currently visible on the surface [with respect to packaging Python & packages].
As mentioned earlier, Python[3] packages are shipped with bytecodes, and the reason for this is simply performance & size.
As mentioned earlier, Python packages are shipped with bytecodes, and the reason for this is simply performance & size.
The thought/discussion matrix derives a bit like this:
* shipping both Python source-code & bytecodes takes too much space on some devices ; Python source code & byte-code take about similar disk-size
* shipping only Python source code has a big performance penalty [on some lower end systems] ; something like 500 msecs (Python source-only) -> 70 msecs (Python byte-codes) time reduction for a simple "Hello World" script
* shipping only Python byte-codes seems like a good trade-off, and this means that `python-src` & `python3-src` can be provided for people that want the source code
* shipping only Python byte-codes seems like a good trade-off, and this means that `python3-src` can be provided for people that want the source code
By default, automatic Python[3] byte-code generation is disabled when running a Python script, in order to prevent a disk from accidentally filling up. Since some disks reside in RAM, this also means not filling up the RAM. If someone wants to convert Python source to byte-code then he/she is free to compile it [directly on the device] manually via the Python interpreter & library.
By default, automatic Python byte-code generation is disabled when running a Python script, in order to prevent a disk from accidentally filling up. Since some disks reside in RAM, this also means not filling up the RAM. If someone wants to convert Python source to byte-code then he/she is free to compile it [directly on the device] manually via the Python interpreter & library.
## General folder structure
The basis of all these packages are:
* [lang/python/python](lang/python/python) - The Python 2.7.y interpreter (supposedly, there won't ever by a 2.8.y)
The basis of all these packages is:
* [lang/python/python3](lang/python/python3) - The Python 3.x.y interpreter
These 2 are normal OpenWrt packages, which will build the Python interpreters. They also provide `python[3]-pip` & `python[3]-setuptools`. Each Python or Python3 package is actually split into multiple sub-packages [e.g. python-email, python-sqlite3, etc]. This can be viewed inside [lang/python/python/files](lang/python/python/files) & [lang/python/python3/files](lang/python/python3/files).
The reason for this splitting, is purely to offer a way for some people to package Python/Python3 in as-minimal-as-possible-and-still-runable way, and also to be somewhat maintainable when packaging. A standard Python[3] installation can take ~20-30 MBs of disk, which can be somewhat big for some people, so there are the `python[3]-base` packages which bring that down to ~5 MBs. This seems to be good enough (and interesting) for a number of people.
This is a normal OpenWrt package, which will build the Python interpreter. This also provides `python3-pip` & `python3-setuptools`. Each Python package is actually split into multiple sub-packages [e.g. python3-email, python3-sqlite3, etc]. This can be viewed inside [lang/python/python3/files](lang/python/python3/files).
The Python[3] interpreters are structured like this:
* `python-base` (and `python3-base`), which is just the minimal package to startup Python[3] and run basic commands
* `python` (and `python3`) are meta-packages, which install almost everything (python[3]-base [plus] Python[3] library [minus] some unit-tests & some windows-y things)
* `python-light` (and `python3-light`) are `python` (and `python3`) [minus] packages that are in [lang/python/python/files](lang/python/python/files) or [lang/python/python3/files](lang/python/python3/files) ; the size of these 2 packages may be sensible (and interesting) to another group of people
The reason for this splitting, is purely to offer a way for some people to package Python in as-minimal-as-possible-and-still-runable way, and also to be somewhat maintainable when packaging. A standard Python installation can take ~20-30 MBs of disk, which can be somewhat big for some people, so there is the `python3-base` package which brings that down to ~5 MBs. This seems to be good enough (and interesting) for a number of people.
All other Python & Python3 packages (aside from the 2 intepreters) typically use these files:
* **python[3]-host.mk** - this file contains paths and build rules for running the Python[3] interpreters on the host-side; they also provide paths to host interprete, host Python lib-dir & so on
* **python[3]-package.mk**
* includes **python[3]-host.mk**
* contains all the default build rules for Python[3] packages; these will be detailed below in the [Building a Python[3] package](#Building a Python[3] package) section
The Python interpreter is structured like this:
* `python3-base`, which is just the minimal package to startup Python and run basic commands
* `python3` is a meta-package, which installs almost everything (python3-base [plus] Python library [minus] some unit-tests & some windows-y things)
* `python3-light` is `python3` [minus] packages that are in [lang/python/python3/files](lang/python/python3/files) ; the size of this package may be sensible (and interesting) to another group of people
**Note** that Python/Python3 packages don't need to use these files (i.e. `python[3]-package.mk` & `python[3]-host.mk`), but they do provide some ease-of-use & reduction of duplicate code, especially when packaging for both Python & Python3. And they do contain some learned-lessons about packaging Python/Python3 packages, so it's a good idea to use them.
All other Python packages (aside from the intepreter) typically use these files:
* **python3-host.mk** - this file contains paths and build rules for running the Python interpreter on the host-side; they also provide paths to host interprete, host Python lib-dir & so on
* **python3-package.mk**
* includes **python3-host.mk**
* contains all the default build rules for Python packages; these will be detailed below in the [Building a Python package](#Building a Python package) section
## Building a Python[3] package
**Note** that Python packages don't need to use these files (i.e. `python3-package.mk` & `python3-host.mk`), but they do provide some ease-of-use & reduction of duplicate code. And they do contain some learned-lessons about packaging Python packages, so it's a good idea to use them.
A Python package can be packaged for either Python or Python3 or both.
## Building a Python package
This section will describe both, and then it can be inferred which is for which.
Packaging for Python uses the `VARIANT` mechanism for packaging inside OpenWrt. (#### FIXME: find a link for this later if it exists)
Packaging for both Python & Python3 uses the `VARIANT` mechanism for packaging inside OpenWrt. (#### FIXME: find a link for this later if it exists)
### Include python3-package.mk
### Include python[3]-package.mk
If packaging for Python, add this after `include $(INCLUDE_DIR)/package.mk`
```
include ../python-package.mk
```
If packaging for Python3, add this after `include $(INCLUDE_DIR)/package.mk`
Add this after `include $(INCLUDE_DIR)/package.mk`
```
include ../python3-package.mk
```
Order doesn't matter between `python-package.mk` & `python3-package.mk`.
These will make sure that build rules for Python or Python3 can be specified and picked up for build.
This will make sure that build rules for Python can be specified and picked up for build.
### Include pypi.mk (optional)
@ -225,98 +178,58 @@ The `PYPI_SOURCE_*` variables allow this default `PKG_SOURCE` value to be custom
### Add Package/<PKG_NAME> OpenWrt definitions
This part is similar to default OpenWrt packages.
It's usually recommended to have a `Package/<PKG_NAME>/Default` section that's common for both Python & Python3.
Example:
```
define Package/python-lxml/Default
define Package/python3-lxml
SECTION:=lang
CATEGORY:=Languages
SUBMENU:=Python
TITLE:=Pythonic XML processing library
URL:=https://lxml.de
DEPENDS:=+libxml2 +libxslt +libexslt
endef
```
Then for each variant do something like:
```
define Package/python-lxml
$(call Package/python-lxml/Default)
TITLE:=python-lxml
DEPENDS+=+PACKAGE_python-lxml:python-light +PACKAGE_python-lxml:python-codecs
VARIANT:=python
endef
define Package/python3-lxml
$(call Package/python-lxml/Default)
TITLE:=python3-lxml
DEPENDS+=+PACKAGE_python3-lxml:python3-light
DEPENDS:=+python3-light +libxml2 +libxslt +libexslt
VARIANT:=python3
endef
```
Some considerations here (based on the example above):
* be sure to make sure that `DEPENDS` are correct for both variants; as seen in the example above, `python-codecs` is needed only for `python-lxml` (see **[note-encodings](#note-encodings)**)
* consider adding conditional DEPENDS for each variant ; so for each Python[3] package add `+PACKAGE_python-lxml:<dep>` as seen in the above example ; the reason for this is build-time reduction ; if you want to build Python3 only packages, this won't build Python & Python packages + dependencies ; this is a known functionality of OpenWrt build deps
* this should not happen anymore, but if adding `+PACKAGE_python-lxml` conditional deps creates circular dependencies, then open an issue so this can be resolved again.
* `VARIANT=python` or `VARIANT=python3` must be added
* typically each variant package is named `Package/python-<something>` & `Package/python3-<something>` ; this convention makes things easier to follow, though it could work without naming things this way
* `TITLE` can be something a bit more verbose/neat ; typically the name is short as seen above
<a name="note-encodings">**note-encodings**</a>: That's because some character encodings are needed, which are present in `python3-base` but not in `python-light` (but are present in `python-codecs`) ; this is because Python3 is designed to be more Unicode friendly than Python2 (it's one of the fundamental differences between the 2), and Python3 won't start without those encodings being present.
Following these, 2 more definitions are required:
```
define Package/python-lxml/description
The lxml XML toolkit is a Pythonic binding
for the C libraries libxml2 and libxslt.
endef
define Package/python3-lxml/description
$(call Package/python-lxml/description)
.
(Variant for Python3)
The lxml XML toolkit is a Pythonic binding
for the C libraries libxml2 and libxslt.
endef
```
Typically, the description is the same for both, so just mentioning that one is a variant of the other is sufficient.
Some considerations here (based on the example above):
* `VARIANT=python3` must be added
* typically the package is named `Package/python3-<something>` ; this convention makes things easier to follow, though it could work without naming things this way
* `TITLE` can be something a bit more verbose/neat ; typically the name is short as seen above
### Wrapping things up so that they build
If all the above prerequisites have been met, all that's left is:
```
$(eval $(call PyPackage,python-lxml))
$(eval $(call BuildPackage,python-lxml))
$(eval $(call Py3Package,python3-lxml))
$(eval $(call BuildPackage,python3-lxml))
```
The `$(eval $(call PyPackage,python-lxml))` part will instantiate all the default Python build rules so that the final Python package is packaged into an OpenWrt.
And `$(eval $(call BuildPackage,python-lxml))` will bind all the rules generated with `$(eval $(call PyPackage,python-lxml))` into the OpenWrt build system.
The `$(eval $(call Py3Package,python3-lxml))` part will instantiate all the default Python build rules so that the final Python package is packaged into an OpenWrt.
And `$(eval $(call BuildPackage,python3-lxml))` will bind all the rules generated with `$(eval $(call Py3Package,python3-lxml))` into the OpenWrt build system.
These packages will contain byte-codes and binaries (shared libs & other stuff).
If a user wishes to ship source code, adding 2 more lines creates 2 more packages that ship Python source code:
If a user wishes to ship source code, adding one more line creates one more package that ship Python source code:
```
$(eval $(call PyPackage,python-lxml))
$(eval $(call BuildPackage,python-lxml))
$(eval $(call BuildPackage,python-lxml-src))
$(eval $(call Py3Package,python3-lxml))
$(eval $(call BuildPackage,python3-lxml))
$(eval $(call BuildPackage,python3-lxml-src))
```
The name `*-src` must be the Python package name; so for `python-lxml-src` a equivalent `python-lxml` name must exist.
The name `*-src` must be the Python package name; so for `python3-lxml-src` a equivalent `python3-lxml` name must exist.
### Customizing things
Some packages need custom build rules (because they do).
The default package build and install processes are defined in `python[3]-package.mk`.
The default package build and install processes are defined in `python3-package.mk`.
#### Building
@ -324,35 +237,35 @@ The default build process calls `setup.py install` inside the directory where th
There are several Makefile variables that can be used to customize this process (all optional):
* `PYTHON_PKG_SETUP_DIR` / `PYTHON3_PKG_SETUP_DIR`: Path where `setup.py` can be found, relative to the package directory (`PKG_BUILD_DIR`).
* `PYTHON3_PKG_SETUP_DIR`: Path where `setup.py` can be found, relative to the package directory (`PKG_BUILD_DIR`).
Default: empty value (`setup.py` is in the package directory)
* `PYTHON_PKG_SETUP_VARS` / `PYTHON3_PKG_SETUP_VARS`: Additional environment variables to set for the call to `setup.py`. Should be in the form of `VARIABLE1=value VARIABLE2=value ...`.
* `PYTHON3_PKG_SETUP_VARS`: Additional environment variables to set for the call to `setup.py`. Should be in the form of `VARIABLE1=value VARIABLE2=value ...`.
Default: empty value
* `PYTHON_PKG_SETUP_GLOBAL_ARGS` / `PYTHON3_PKG_SETUP_GLOBAL_ARGS`: Additional command line arguments to pass to `setup.py`, before / in front of the `install` command.
* `PYTHON3_PKG_SETUP_GLOBAL_ARGS`: Additional command line arguments to pass to `setup.py`, before / in front of the `install` command.
Default: empty value
* `PYTHON_PKG_SETUP_ARGS` / `PYTHON3_PKG_SETUP_ARGS`: Additional command line arguments to pass to `setup.py`, after the `install` command.
* `PYTHON3_PKG_SETUP_ARGS`: Additional command line arguments to pass to `setup.py`, after the `install` command.
Default: `--single-version-externally-managed`
Conceptually, these variables are used in this way (using a Python 2 package as an example):
Conceptually, these variables are used in this way:
```
cd $(PKG_BUILD_DIR)/$(PYTHON_PKG_SETUP_DIR)
$(PYTHON_PKG_SETUP_VARS) python setup.py $(PYTHON_PKG_SETUP_GLOBAL_ARGS) install $(PYTHON_PKG_SETUP_ARGS)
cd $(PKG_BUILD_DIR)/$(PYTHON3_PKG_SETUP_DIR)
$(PYTHON3_PKG_SETUP_VARS) python3 setup.py $(PYTHON3_PKG_SETUP_GLOBAL_ARGS) install $(PYTHON3_PKG_SETUP_ARGS)
```
The default build process can be completely overridden by defining custom `PyBuild/Compile` & `Py3Build/Compile` rules in the package Makefile.
The default build process can be completely overridden by defining a custom `Py3Build/Compile` rule in the package Makefile.
#### Installing
The default install process copies some/all of the files from `PKG_INSTALL_DIR`, placed there by the build process, to a location passed to the install rule as the first argument (`$(1)`). The OpenWrt build system will then take those files and create the actual .ipk package archives.
This default process uses 2 build rules:
* `PyPackage/<package>/filespec` & `Py3Package/<package>/filespec` which are Python library files relative to `/usr/lib/pythonX.Y` ; by default this is `/usr/lib/python$(PYTHON[3]_VERSION)/site-packages` (`PYTHON[3]_PKG_DIR`) ; most Python[3] packages generate files that get installed in this sub-folder
* `PyPackage/<package>/install` & `Py3Package/<package>/install` is similar to `Package/<package>/install` ; these allow binary (or other files) to be installed on the target
* `Py3Package/<package>/filespec` which are Python library files relative to `/usr/lib/pythonX.Y` ; by default this is `/usr/lib/python$(PYTHON3_VERSION)/site-packages` (`PYTHON3_PKG_DIR`) ; most Python packages generate files that get installed in this sub-folder
* `Py3Package/<package>/install` is similar to `Package/<package>/install` ; this allows binary (or other files) to be installed on the target
Both the 2 above rules generate a `Package/<package>/install` build rule, which gets picked up by the build system. Both can be used together (they are not mutually exclusive), and provide a good enough flexibility for specifying Python[3] packages.
Both the 2 above rules generate a `Package/<package>/install` build rule, which gets picked up by the build system. Both can be used together (they are not mutually exclusive), and provide a good enough flexibility for specifying Python packages.
The `PyPackage/<package>/filespec` & `Py3Package/<package>/filespec` rules contain one or more lines of the following format (whitespace added for clarity):
The `Py3Package/<package>/filespec` rule contains one or more lines of the following format (whitespace added for clarity):
```
<one of: +-=> | <file/directory path> | <file permissions>
@ -366,21 +279,21 @@ The initial character controls the action that will be taken:
* File permissions is not used / ignored in this case.
* `=`: Assign the given file permissions to the given path. File permissions is required in this case.
As mentioned, the default `PyPackage/<package>/filespec` & `Py3Package/<package>/filespec` install `PYTHON[3]_PKG_DIR`:
As mentioned, the default `Py3Package/<package>/filespec` installs `PYTHON3_PKG_DIR`:
```
define PyPackage/python-example/filespec
+|$(PYTHON_PKG_DIR)
define Py3Package/python3-example/filespec
+|$(PYTHON3_PKG_DIR)
endef
```
If the package installs a `example_package` directory inside `PYTHON_PKG_DIR`, and there is an `examples` directory and `test_*.py` files that can be omitted to save space, this can be specified as:
If the package installs a `example_package` directory inside `PYTHON3_PKG_DIR`, and there is an `examples` directory and `test_*.py` files that can be omitted to save space, this can be specified as:
```
define PyPackage/python-example/filespec
+|$(PYTHON_PKG_DIR)
-|$(PYTHON_PKG_DIR)/example_package/examples
-|$(PYTHON_PKG_DIR)/example_package/test_*.py
define Py3Package/python3-example/filespec
+|$(PYTHON3_PKG_DIR)
-|$(PYTHON3_PKG_DIR)/example_package/examples
-|$(PYTHON3_PKG_DIR)/example_package/test_*.py
endef
```
@ -390,9 +303,8 @@ These can be installed via pip and ideally they should only be installed like th
Which is why [for example] if you need python cffi on the host build, it's easier to just add it via:
```
HOST_PYTHON_PACKAGE_BUILD_DEPENDS:="cffi==$(PKG_VERSION)"
HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:="cffi==$(PKG_VERSION)"
```
[cffi is one of those packages that needs a host-side package installed for both Python & Python3].
[cffi is one of those packages that needs a host-side package installed].
This works reasonably well in the current OpenWrt build system, as binaries get built for this package and get installed in the staging-dir `$(STAGING_DIR)/usr/lib/pythonX.Y/site-packages`.

+ 0
- 95
lang/python/python-host.mk View File

@ -1,95 +0,0 @@
#
# Copyright (C) 2015-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
# if `python-package.mk` is included, this will already be included
ifneq ($(__python_host_mk_inc),1)
__python_host_mk_inc=1
# For PYTHON_VERSION
python_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
include $(python_mk_path)python-version.mk
HOST_PYTHON_DIR:=$(STAGING_DIR_HOSTPKG)
HOST_PYTHON_INC_DIR:=$(HOST_PYTHON_DIR)/include/python$(PYTHON_VERSION)
HOST_PYTHON_LIB_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)
HOST_PYTHON_PKG_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)/site-packages
HOST_PYTHON_BIN:=$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION)
HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(HOST_PYTHON_PKG_DIR)
define HostPython
if [ "$(strip $(3))" == "HOST" ]; then \
export PYTHONPATH="$(HOST_PYTHONPATH)"; \
export PYTHONDONTWRITEBYTECODE=0; \
else \
export PYTHONPATH="$(PYTHONPATH)"; \
export PYTHONDONTWRITEBYTECODE=1; \
export _python_sysroot="$(STAGING_DIR)"; \
export _python_prefix="/usr"; \
export _python_exec_prefix="/usr"; \
fi; \
export PYTHONOPTIMIZE=""; \
$(1) \
$(HOST_PYTHON_BIN) $(2);
endef
define host_python_settings
ARCH="$(HOST_ARCH)" \
CC="$(HOSTCC)" \
CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
CXX="$(HOSTCXX)" \
LD="$(HOSTCC)" \
LDSHARED="$(HOSTCC) -shared" \
CFLAGS="$(HOST_CFLAGS)" \
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
_PYTHON_HOST_PLATFORM=linux2
endef
# $(1) => commands to execute before running pythons script
# $(2) => python script and its arguments
# $(3) => additional variables
define Build/Compile/HostPyRunHost
$(call HostPython, \
$(if $(1),$(1);) \
$(call host_python_settings) \
$(3) \
, \
$(2) \
, \
HOST \
)
endef
# Note: I shamelessly copied this from Yousong's logic (from python-packages);
HOST_PYTHON_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON_VERSION)
# $(1) => packages to install
define Build/Compile/HostPyPipInstall
$(call host_python_settings) \
$(HOST_PYTHON_PIP) \
--disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \
install \
$(1)
endef
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(3) => additional variables
define Build/Compile/HostPyMod
$(call Build/Compile/HostPyRunHost, \
cd $(HOST_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(3))
endef
endif # __python_host_mk_inc

+ 0
- 153
lang/python/python-package.mk View File

@ -1,153 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
python_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
include $(python_mk_path)python-host.mk
PYTHON_DIR:=$(STAGING_DIR)/usr
PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
PYTHON:=python$(PYTHON_VERSION)
PYTHONPATH:=$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
# These configure args are needed in detection of path to Python header files
# using autotools.
CONFIGURE_ARGS += \
_python_sysroot="$(STAGING_DIR)" \
_python_prefix="/usr" \
_python_exec_prefix="/usr"
PKG_USE_MIPS16:=0
# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
# flags are inherited from the Python base package (via sysconfig module)
ifdef CONFIG_USE_MIPS16
TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
endif
define PyShebang
$(SED) "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python2," -i --follow-symlinks $(1)
endef
define PyPackage
define Package/$(1)-src
$(call Package/$(1))
DEPENDS:=
CONFLICTS:=
PROVIDES:=
EXTRA_DEPENDS:=
TITLE+= (sources)
USERID:=
MENU:=
endef
define Package/$(1)-src/description
$(call Package/$(1)/description).
(Contains the Python sources for this package).
endef
# Add default PyPackage filespec none defined
ifndef PyPackage/$(1)/filespec
define PyPackage/$(1)/filespec
+|$(PYTHON_PKG_DIR)
endef
endif
ifndef PyPackage/$(1)/install
define PyPackage/$(1)/install
if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
$(INSTALL_DIR) $$(1)/usr/bin ; \
$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
fi
endef
endif
ifndef Package/$(1)/install
$(call shexport,PyPackage/$(1)/filespec)
define Package/$(1)/install
$$(call PyPackage/$(1)/install,$$(1))
$(SHELL) $(python_mk_path)python-package-install.sh "2" \
"$(PKG_INSTALL_DIR)" "$$(1)" \
"$(HOST_PYTHON_BIN)" "$$(2)" \
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" && \
if [ -d "$$(1)/usr/bin" ]; then \
$(call PyShebang,$$(1)/usr/bin/*) ; \
fi
endef
define Package/$(1)-src/install
$$(call Package/$(1)/install,$$(1),sources)
endef
endif # Package/$(1)/install
endef
# $(1) => commands to execute before running pythons script
# $(2) => python script and its arguments
# $(3) => additional variables
define Build/Compile/HostPyRunTarget
$(call HostPython, \
$(if $(1),$(1);) \
CC="$(TARGET_CC)" \
CCSHARED="$(TARGET_CC) $(FPIC)" \
CXX="$(TARGET_CXX)" \
LD="$(TARGET_CC)" \
LDSHARED="$(TARGET_CC) -shared" \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
_PYTHON_HOST_PLATFORM=linux2 \
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
$(3) \
, \
$(2) \
)
endef
# $(1) => build subdir
# $(2) => additional arguments to setup.py
# $(3) => additional variables
define Build/Compile/PyMod
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
$(call Build/Compile/HostPyRunTarget, \
cd $(PKG_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(3))
endef
PYTHON_PKG_SETUP_DIR ?=
PYTHON_PKG_SETUP_GLOBAL_ARGS ?=
PYTHON_PKG_SETUP_ARGS ?= --single-version-externally-managed
PYTHON_PKG_SETUP_VARS ?=
define PyBuild/Compile/Default
$(if $(HOST_PYTHON_PACKAGE_BUILD_DEPENDS),
$(call Build/Compile/HostPyPipInstall,$(HOST_PYTHON_PACKAGE_BUILD_DEPENDS))
)
$(call Build/Compile/PyMod, \
$(PYTHON_PKG_SETUP_DIR), \
$(PYTHON_PKG_SETUP_GLOBAL_ARGS) \
install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
$(PYTHON_PKG_SETUP_ARGS), \
$(PYTHON_PKG_SETUP_VARS) \
)
endef
PyBuild/Compile=$(PyBuild/Compile/Default)
ifeq ($(BUILD_VARIANT),python)
define Build/Compile
$(call PyBuild/Compile)
endef
endif # python

+ 0
- 15
lang/python/python-version.mk View File

@ -1,15 +0,0 @@
#
# Copyright (C) 2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
PYTHON_VERSION:=2.7
PYTHON_VERSION_MICRO:=17
PYTHON_SETUPTOOLS_PKG_RELEASE:=1
PYTHON_PIP_PKG_RELEASE:=1
PYTHON_SETUPTOOLS_VERSION:=41.2.0
PYTHON_PIP_VERSION:=19.2.3

+ 0
- 7
lang/python/python/Config-python-light.in View File

@ -1,7 +0,0 @@
menu "Configuration"
config PYTHON_BLUETOOTH_SUPPORT
bool "Enable Bluetooth support"
default n
endmenu

+ 0
- 380
lang/python/python/Makefile View File

@ -1,380 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
# For PYTHON_VERSION
include ../python-version.mk
PKG_NAME:=python
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
PKG_RELEASE:=2
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
PKG_HASH:=4d43f033cdbd0aa7b7023c81b0e986fd11e653b5248dac9144d508f11812ba41
PKG_LICENSE:=Python/2.0
PKG_LICENSE_FILES:=LICENSE Doc/copyright.rst Doc/license.rst Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Modules/expat/COPYING
PKG_CPE_ID:=cpe:/a:python:python
PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>, Jeffery To <jeffery.to@gmail.com>
# This file provides the necsessary host build variables
include ../python-host.mk
# For PyPackage
include ../python-package.mk
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
HOST_BUILD_PARALLEL:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_python-pkg-resources \
CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip \
CONFIG_PYTHON_BLUETOOTH_SUPPORT
PKG_BUILD_DEPENDS:=python/host
HOST_BUILD_DEPENDS:=bzip2/host expat/host
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
define Package/python/Default
SUBMENU:=Python
SECTION:=lang
CATEGORY:=Languages
TITLE:=Python $(PYTHON_VERSION) programming language
URL:=https://www.python.org/
endef
define Package/python/Default/description
Python is a dynamic object-oriented programming language that can be used
for many kinds of software development. It offers strong support for
integration with other languages and tools, comes with extensive standard
libraries, and can be learned in a few days. Many Python programmers
report substantial productivity gains and feel the language encourages
the development of higher quality, more maintainable code.
endef
define Package/python-base
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) interpreter
DEPENDS:=+libpthread +zlib
endef
define Package/python-base/description
This package contains only the interpreter and the bare minimum
for the interpreter to start.
endef
define Package/python-light
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) light installation
DEPENDS:=+python-base +libffi +libbz2 +PYTHON_BLUETOOTH_SUPPORT:bluez-libs
endef
define Package/python-light/config
source "$(SOURCE)/Config-python-light.in"
endef
define Package/python-light/description
This package is essentially the python-base package plus
a few of the rarely used (and big) libraries stripped out
into separate packages.
endef
PYTHON_LIB_FILES_DEL:=
PYTHON_PACKAGES:=
PYTHON_PACKAGES_DEPENDS:=
define PyBasePackage
PYTHON_PACKAGES+=$(1)
ifeq ($(3),)
PYTHON_PACKAGES_DEPENDS+=$(1)
endif
PYTHON_LIB_FILES_DEL+=$(2)
define PyPackage/$(1)/filespec
ifneq ($(2),)
$(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
-|/usr/lib/python$(PYTHON_VERSION)/*/test
-|/usr/lib/python$(PYTHON_VERSION)/*/tests
endif
endef
PyPackage/$(1)/install?=:
endef
include ./files/python-package-*.mk
define Package/python
$(call Package/python/Default)
DEPENDS:=+python-light $(foreach package,$(PYTHON_PACKAGES_DEPENDS),+$(package))
endef
define Package/python/description
This package contains the (almost) full Python install.
It's python-light + all other packages.
endef
MAKE_FLAGS+=\
CROSS_COMPILE=yes \
LD="$(TARGET_CC)" \
PGEN=pgen2
EXTRA_CFLAGS+= \
-DNDEBUG -fno-inline
EXTRA_LDFLAGS+= \
-L$(PKG_BUILD_DIR)
ENABLE_IPV6:=
ifeq ($(CONFIG_IPV6),y)
ENABLE_IPV6 += --enable-ipv6
endif
PYTHON_FOR_BUILD:= \
_PYTHON_PROJECT_BASE=$(PKG_BUILD_DIR) \
_PYTHON_HOST_PLATFORM=linux2 \
PYTHONPATH="$(PKG_BUILD_DIR)/Lib:$(PKG_BUILD_DIR)/build/lib.linux2-$(PYTHON_VERSION)" \
_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata \
$(HOST_PYTHON_BIN)
DISABLE_BLUETOOTH:= \
ac_cv_header_bluetooth_bluetooth_h=no \
ac_cv_header_bluetooth_h=no
CONFIGURE_ARGS+= \
--sysconfdir=/etc \
--enable-shared \
--without-cxx-main \
--with-threads \
--with-system-ffi \
--with-ensurepip=no \
--without-pymalloc \
$(if $(CONFIG_PYTHON_BLUETOOTH_SUPPORT),,$(DISABLE_BLUETOOTH)) \
PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
$(ENABLE_IPV6) \
CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
OPT="$(TARGET_CFLAGS)"
define Build/Prepare
$(call Build/Prepare/Default)
$(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
endef
ifdef CONFIG_PACKAGE_python-setuptools
PYTHON_SETUPTOOLS_BUILD:=1
endif
ifdef CONFIG_PACKAGE_python-pkg-resources
PYTHON_SETUPTOOLS_BUILD:=1
endif
ifeq ($(PYTHON_SETUPTOOLS_BUILD),1)
define Build/Compile/python-setuptools
$(HOST_PYTHON_PIP) \
--disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \
install \
--ignore-installed \
--root=$(PKG_BUILD_DIR)/install-setuptools \
--prefix=/usr \
$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON_SETUPTOOLS_VERSION)-py2.py3-none-any.whl
$(call PatchDir,$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages,./patches-setuptools,)
endef
endif # CONFIG_PACKAGE_python-setuptools
ifdef CONFIG_PACKAGE_python-pip
define Build/Compile/python-pip
$(HOST_PYTHON_PIP) \
--disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \
install \
--ignore-installed \
--root=$(PKG_BUILD_DIR)/install-pip \
--prefix=/usr \
$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON_PIP_VERSION)-py2.py3-none-any.whl
$(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON_VERSION)/site-packages,./patches-pip,)
endef
endif # CONFIG_PACKAGE_python-pip
define Build/Compile
$(call Build/Compile/Default)
# Use host pip to install python-setuptools
$(call Build/Compile/python-setuptools)
$(call Build/Compile/python-pip)
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
$(INSTALL_DIR) $(2)/bin
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)-openwrt
$(CP) \
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
$(1)/usr/include/
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION) \
$(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
$(1)/usr/lib/
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
$(1)/usr/lib/pkgconfig
$(INSTALL_BIN) \
./files/python-config.in \
$(2)/bin/python$(PYTHON_VERSION)-config
$(SED) \
's|@EXENAME@|$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION)|' \
-e 's|@TARGET_PREFIX@|$(PYTHON_DIR)|' \
$(2)/bin/python$(PYTHON_VERSION)-config
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
$(1)/usr/lib/python$(PYTHON_VERSION)-openwrt/_sysconfigdatatarget.py
endef
PYTHON_BASE_LIB_FILES:= \
/usr/lib/python$(PYTHON_VERSION)/_abcoll.py \
/usr/lib/python$(PYTHON_VERSION)/_sysconfigdata.py \
/usr/lib/python$(PYTHON_VERSION)/_weakrefset.py \
/usr/lib/python$(PYTHON_VERSION)/abc.py \
/usr/lib/python$(PYTHON_VERSION)/copy_reg.py \
/usr/lib/python$(PYTHON_VERSION)/genericpath.py \
/usr/lib/python$(PYTHON_VERSION)/linecache.py \
/usr/lib/python$(PYTHON_VERSION)/posixpath.py \
/usr/lib/python$(PYTHON_VERSION)/os.py \
/usr/lib/python$(PYTHON_VERSION)/re.py \
/usr/lib/python$(PYTHON_VERSION)/site.py \
/usr/lib/python$(PYTHON_VERSION)/sre_compile.py \
/usr/lib/python$(PYTHON_VERSION)/sre_constants.py \
/usr/lib/python$(PYTHON_VERSION)/sre_parse.py \
/usr/lib/python$(PYTHON_VERSION)/sysconfig.py \
/usr/lib/python$(PYTHON_VERSION)/stat.py \
/usr/lib/python$(PYTHON_VERSION)/traceback.py \
/usr/lib/python$(PYTHON_VERSION)/types.py \
/usr/lib/python$(PYTHON_VERSION)/UserDict.py \
/usr/lib/python$(PYTHON_VERSION)/warnings.py
PYTHON_LIB_FILES_DEL+=$(PYTHON_BASE_LIB_FILES)
define PyPackage/python-base/filespec
+|/usr/bin/python$(PYTHON_VERSION)
$(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_BASE_LIB_FILES),+|$(lib_file)))
endef
define PyPackage/python-light/filespec
+|/usr/lib/python$(PYTHON_VERSION)
-|/usr/lib/python$(PYTHON_VERSION)/distutils/cygwinccompiler.py
-|/usr/lib/python$(PYTHON_VERSION)/distutils/command/wininst*
-|/usr/lib/python$(PYTHON_VERSION)/ensurepip
-|/usr/lib/python$(PYTHON_VERSION)/idlelib
-|/usr/lib/python$(PYTHON_VERSION)/lib-tk
-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_testcapi.so
-|/usr/lib/python$(PYTHON_VERSION)/pdb.doc
-|/usr/lib/python$(PYTHON_VERSION)/test
-|/usr/lib/python$(PYTHON_VERSION)/webbrowser.py
-|/usr/lib/python$(PYTHON_VERSION)/*/test
-|/usr/lib/python$(PYTHON_VERSION)/*/tests
-|/usr/lib/python$(PYTHON_VERSION)/lib-dynload/readline.so
$(subst $(space),$(newline),$(foreach lib_file,$(PYTHON_LIB_FILES_DEL),-|$(lib_file)))
endef
define PyPackage/python-base/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
$(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python
$(LN) python$(PYTHON_VERSION) $(1)/usr/bin/python2
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* $(1)/usr/lib/
endef
PyPackage/python-light/install:=:
PyPackage/python/install:=:
define PyPackage/python/filespec
-|$(PYTHON_PKG_DIR)
endef
HOST_LDFLAGS += \
-Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib
ifeq ($(HOST_OS),Linux)
HOST_LDFLAGS += \
-Wl,--no-as-needed -lrt
endif
ifeq ($(HOST_OS),Darwin)
HOST_CONFIGURE_VARS += \
ac_cv_header_libintl_h=no
endif
HOST_CONFIGURE_ARGS+= \
--without-cxx-main \
--without-pymalloc \
--with-threads \
--prefix=$(HOST_PYTHON_DIR) \
--exec-prefix=$(HOST_PYTHON_DIR) \
--with-system-expat=$(STAGING_DIR_HOSTPKG) \
--with-ensurepip=upgrade \
CONFIG_SITE=
define Host/Configure
$(SED) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR)/Lib/site.py
$(call Host/Configure/Default)
endef
define Host/Compile
$(call Host/Compile/Default,python Parser/pgen sharedmods)
endef
define Host/Install
$(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)),,
rm -rf \
$(HOST_PYTHON_PKG_DIR)/easy_install.py \
$(HOST_PYTHON_PKG_DIR)/pkg_resources \
$(HOST_PYTHON_PKG_DIR)/setuptools \
$(HOST_PYTHON_PKG_DIR)/setuptools-* \
$(HOST_PYTHON_PKG_DIR)/.setuptools-patched* \
$(HOST_PYTHON_PKG_DIR)/.setuptools_installed_*
)
$(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)),,
rm -rf \
$(HOST_PYTHON_PKG_DIR)/pip \
$(HOST_PYTHON_PKG_DIR)/pip-* \
$(HOST_PYTHON_PKG_DIR)/.pip-patched* \
$(HOST_PYTHON_PKG_DIR)/.pip_installed_*
)
$(MAKE) -C $(HOST_BUILD_DIR) install
$(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
$(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
$(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)),,
$(call HostPatchDir,$(HOST_PYTHON_PKG_DIR),./patches-setuptools,)
touch $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)
)
$(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)),,
$(call HostPatchDir,$(HOST_PYTHON_PKG_DIR),./patches-pip,)
touch $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)
)
endef
$(eval $(call HostBuild))
$(foreach package, $(PYTHON_PACKAGES), \
$(eval $(call PyPackage,$(package))) \
$(eval $(call BuildPackage,$(package))) \
$(eval $(call BuildPackage,$(package)-src)) \
)
$(eval $(call PyPackage,python-base))
$(eval $(call PyPackage,python-light))
$(eval $(call PyPackage,python))
$(eval $(call BuildPackage,python-base))
$(eval $(call BuildPackage,python-light))
$(eval $(call BuildPackage,python))
$(eval $(call BuildPackage,python-base-src))
$(eval $(call BuildPackage,python-light-src))

+ 0
- 12
lang/python/python/files/config.site View File

@ -1,12 +0,0 @@
#! /bin/sh
#
# Copyright (C) 2007-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
ac_cv_file__dev_ptmx=yes
ac_cv_file__dev_ptc=no
ac_cv_buggy_getaddrinfo=no

+ 0
- 80
lang/python/python/files/python-config.in View File

@ -1,80 +0,0 @@
#!@EXENAME@
import sys
import os
import getopt
from distutils import sysconfig
# start changes
host_prefix = sysconfig.PREFIX
target_prefix = '@TARGET_PREFIX@'
target_data_dir = os.path.join(target_prefix, 'lib', 'python' + sysconfig.get_config_var('VERSION') + '-openwrt')
sys.path.append(target_data_dir)
try:
from _sysconfigdatatarget import build_time_vars
sysconfig._config_vars = {}
sysconfig._config_vars.update(build_time_vars)
except ImportError:
print >>sys.stderr, "Could not import target data from %s" % (target_data_dir)
sys.exit(1)
# end changes
# plus .replace(host_prefix, target_prefix) below
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
'ldflags', 'help']
def exit_with_usage(code=1):
print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
'|'.join('--'+opt for opt in valid_opts))
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
except getopt.error:
exit_with_usage()
if not opts:
exit_with_usage()
pyver = sysconfig.get_config_var('VERSION')
getvar = sysconfig.get_config_var
opt_flags = [flag for (flag, val) in opts]
if '--help' in opt_flags:
exit_with_usage(code=0)
for opt in opt_flags:
if opt == '--prefix':
#print sysconfig.PREFIX
print target_prefix
elif opt == '--exec-prefix':
#print sysconfig.EXEC_PREFIX
print target_prefix
elif opt in ('--includes', '--cflags'):
flags = ['-I' + sysconfig.get_python_inc(),
'-I' + sysconfig.get_python_inc(plat_specific=True)]
if opt == '--cflags':
flags.extend(getvar('CFLAGS').split())
#print ' '.join(flags)
print ' '.join(flags).replace(host_prefix, target_prefix)
elif opt in ('--libs', '--ldflags'):
libs = ['-lpython' + pyver]
libs += getvar('LIBS').split()
libs += getvar('SYSLIBS').split()
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
if not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
if not getvar('PYTHONFRAMEWORK'):
libs.extend(getvar('LINKFORSHARED').split())
#print ' '.join(libs)
print ' '.join(libs).replace(host_prefix, target_prefix)

+ 0
- 23
lang/python/python/files/python-package-codecs.mk View File

@ -1,23 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-codecs
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) codecs + unicode support
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-codecs, \
/usr/lib/python$(PYTHON_VERSION)/encodings \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_cn.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_hk.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_iso2022.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_jp.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_kr.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_codecs_tw.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/unicodedata.so \
))

+ 0
- 16
lang/python/python/files/python-package-compiler.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-compiler
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) compiler module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-compiler, \
/usr/lib/python$(PYTHON_VERSION)/compiler \
))

+ 0
- 18
lang/python/python/files/python-package-ctypes.mk View File

@ -1,18 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-ctypes
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) ctypes module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-ctypes, \
/usr/lib/python$(PYTHON_VERSION)/ctypes \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_ctypes.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_ctypes_test.so \
))

+ 0
- 18
lang/python/python/files/python-package-db.mk View File

@ -1,18 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-db
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) db module
DEPENDS:=+python-light +libdb47
endef
$(eval $(call PyBasePackage,python-db, \
/usr/lib/python$(PYTHON_VERSION)/bsddb \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_bsddb.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/dbm.so \
))

+ 0
- 16
lang/python/python/files/python-package-decimal.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-decimal
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) decimal module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-decimal, \
/usr/lib/python$(PYTHON_VERSION)/decimal.py \
))

+ 0
- 27
lang/python/python/files/python-package-dev.mk View File

@ -1,27 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-dev
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) development files
DEPENDS:=+python +python-lib2to3
endef
define PyPackage/python-dev/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/bin/python*config $(1)/usr/bin
$(CP) $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config/libpython$(PYTHON_VERSION).a $(1)/usr/lib
endef
$(eval $(call PyBasePackage,python-dev, \
/usr/lib/python$(PYTHON_VERSION)/config \
/usr/include/python$(PYTHON_VERSION) \
/usr/lib/pkgconfig \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 0
- 16
lang/python/python/files/python-package-distutils.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-distutils
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) distutils
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-distutils, \
/usr/lib/python$(PYTHON_VERSION)/distutils \
))

+ 0
- 16
lang/python/python/files/python-package-email.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-email
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) email module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-email, \
/usr/lib/python$(PYTHON_VERSION)/email \
))

+ 0
- 16
lang/python/python/files/python-package-gdbm.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-gdbm
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) gdbm module
DEPENDS:=+python-light +libgdbm
endef
$(eval $(call PyBasePackage,python-gdbm, \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/gdbm.so \
))

+ 0
- 18
lang/python/python/files/python-package-lib2to3.mk View File

@ -1,18 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-lib2to3
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) lib2to3 module
DEPENDS:=+python
endef
$(eval $(call PyBasePackage,python-lib2to3, \
/usr/lib/python$(PYTHON_VERSION)/lib2to3 \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 0
- 16
lang/python/python/files/python-package-logging.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-logging
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) logging module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-logging, \
/usr/lib/python$(PYTHON_VERSION)/logging \
))

+ 0
- 17
lang/python/python/files/python-package-multiprocessing.mk View File

@ -1,17 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-multiprocessing
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) multiprocessing
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-multiprocessing, \
/usr/lib/python$(PYTHON_VERSION)/multiprocessing \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_multiprocessing.so \
))

+ 0
- 18
lang/python/python/files/python-package-ncurses.mk View File

@ -1,18 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-ncurses
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) ncurses module
DEPENDS:=+python-light +libncurses
endef
$(eval $(call PyBasePackage,python-ncurses, \
/usr/lib/python$(PYTHON_VERSION)/curses \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_curses.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_curses_panel.so \
))

+ 0
- 17
lang/python/python/files/python-package-openssl.mk View File

@ -1,17 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-openssl
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) SSL module
DEPENDS:=+python-light +libopenssl
endef
$(eval $(call PyBasePackage,python-openssl, \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_hashlib.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_ssl.so \
))

+ 0
- 30
lang/python/python/files/python-package-pip.mk View File

@ -1,30 +0,0 @@
#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-pip
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) pip module
VERSION:=$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)
LICENSE:=MIT
LICENSE_FILES:=LICENSE.txt
# CPE_ID:=cpe:/a:python:pip # not currently handled this way by uscan
DEPENDS:=+python +python-setuptools +python-pip-conf
endef
define PyPackage/python-pip/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
$(CP) $(PKG_BUILD_DIR)/install-pip/usr/bin/* $(1)/usr/bin
$(CP) \
$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON_VERSION)/site-packages/pip \
$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON_VERSION)/site-packages/pip-$(PYTHON_PIP_VERSION).dist-info \
$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages/
endef
$(eval $(call PyBasePackage,python-pip, \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 0
- 28
lang/python/python/files/python-package-pkg-resources.mk View File

@ -1,28 +0,0 @@
#
# Copyright (C) 2019 Alexandru Ardelean <ardeleanalex@gmail.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-pkg-resources
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) pkg_resources module (part of etuptools)
VERSION:=$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python
endef
define PyPackage/python-pkg-resources/install
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \
$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
endef
$(eval $(call PyBasePackage,python-pkg-resources, \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 0
- 18
lang/python/python/files/python-package-pydoc.mk View File

@ -1,18 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-pydoc
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) pydoc module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-pydoc, \
/usr/lib/python$(PYTHON_VERSION)/doctest.py \
/usr/lib/python$(PYTHON_VERSION)/pydoc.py \
/usr/lib/python$(PYTHON_VERSION)/pydoc_data \
))

+ 0
- 31
lang/python/python/files/python-package-setuptools.mk View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-setuptools
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) setuptools module
VERSION:=$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python +python-pkg-resources
endef
define PyPackage/python-setuptools/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
$(CP) $(PKG_BUILD_DIR)/install-setuptools/usr/bin/* $(1)/usr/bin
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools-$(PYTHON_SETUPTOOLS_VERSION).dist-info \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/easy_install.py \
$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
endef
$(eval $(call PyBasePackage,python-setuptools, \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 0
- 17
lang/python/python/files/python-package-sqlite3.mk View File

@ -1,17 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-sqlite3
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) sqlite3 module
DEPENDS:=+python-light +libsqlite3
endef
$(eval $(call PyBasePackage,python-sqlite3, \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_sqlite3.so \
/usr/lib/python$(PYTHON_VERSION)/sqlite3 \
))

+ 0
- 16
lang/python/python/files/python-package-unittest.mk View File

@ -1,16 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-unittest
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) unittest module
DEPENDS:=+python-light
endef
$(eval $(call PyBasePackage,python-unittest, \
/usr/lib/python$(PYTHON_VERSION)/unittest \
))

+ 0
- 20
lang/python/python/files/python-package-xml.mk View File

@ -1,20 +0,0 @@
#
# Copyright (C) 2006-2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-xml
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) xml libs
DEPENDS:=+python-light +libexpat
endef
$(eval $(call PyBasePackage,python-xml, \
/usr/lib/python$(PYTHON_VERSION)/xml \
/usr/lib/python$(PYTHON_VERSION)/xmllib.py \
/usr/lib/python$(PYTHON_VERSION)/xmlrpclib.py \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/_elementtree.so \
/usr/lib/python$(PYTHON_VERSION)/lib-dynload/pyexpat.so \
))

+ 0
- 16
lang/python/python/patches-setuptools/001-reproducible.patch View File

@ -1,16 +0,0 @@
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=848136
https://sources.debian.org/patches/python-setuptools/40.8.0-1/reproducible.diff/
Index: b/setuptools/command/easy_install.py
===================================================================
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -436,7 +436,7 @@ consider to install to another location,
for spec in self.args:
self.easy_install(spec, not self.no_deps)
if self.record:
- outputs = self.outputs
+ outputs = list(sorted(self.outputs))
if self.root: # strip any package prefix
root_len = len(self.root)
for counter in range(len(outputs)):

+ 0
- 16
lang/python/python/patches-setuptools/002-sorted-requires.patch View File

@ -1,16 +0,0 @@
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804249
https://sources.debian.org/patches/python-setuptools/40.8.0-1/sorted-requires.diff/
Index: b/setuptools/command/egg_info.py
===================================================================
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -621,7 +621,7 @@ def warn_depends_obsolete(cmd, basename,
def _write_requirements(stream, reqs):
lines = yield_lines(reqs or ())
append_cr = lambda line: line + '\n'
- lines = map(append_cr, lines)
+ lines = map(append_cr, sorted(lines))
stream.writelines(lines)

+ 0
- 14
lang/python/python/patches-setuptools/003-PKG-INFO-output-reproducible.patch View File

@ -1,14 +0,0 @@
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894215
https://sources.debian.org/patches/python-setuptools/40.8.0-1/PKG-INFO-output-reproducible.diff/
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -191,7 +191,7 @@ def write_pkg_file(self, file):
self.long_description_content_type
)
if self.provides_extras:
- for extra in self.provides_extras:
+ for extra in sorted(self.provides_extras):
write_field('Provides-Extra', extra)

+ 0
- 20
lang/python/python/patches/001-enable-zlib.patch View File

@ -1,20 +0,0 @@
From 6eeab87bc852481e599325549c854b701bf2e39f Mon Sep 17 00:00:00 2001
From: Alexandru Ardelean <aa@ocedo.com>
Date: Thu, 25 Sep 2014 18:18:29 +0300
Subject: [PATCH] enable zlib
---
Modules/Setup.dist | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/Modules/Setup.dist
+++ b/Modules/Setup.dist
@@ -464,7 +464,7 @@ GLHACK=-Dclear=__GLclear
# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
-#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
+zlib zlibmodule.c -lz
# Interface to the Expat XML parser
# More information on Expat can be found at www.libexpat.org.

+ 0
- 12
lang/python/python/patches/002-do-not-add-include-dirs-when-cross-compiling.patch View File

@ -1,12 +0,0 @@
--- a/setup.py
+++ b/setup.py
@@ -543,7 +543,8 @@ class PyBuildExt(build_ext):
add_dir_to_list(dir_list, directory)
if os.path.normpath(sys.prefix) != '/usr' \
- and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
+ and not sysconfig.get_config_var('PYTHONFRAMEWORK') \
+ and not cross_compiling:
# OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
# (PYTHONFRAMEWORK is set) to avoid # linking problems when
# building a framework with different architectures than

+ 0
- 18
lang/python/python/patches/003-do-not-compile-tests-at-build.patch View File

@ -1,18 +0,0 @@
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1133,6 +1133,7 @@ libinstall: build_all $(srcdir)/Lib/$(PL
done; \
done
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
+ifeq (@COMPILE_ALL_TESTS@,yes)
if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
$(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
$(DESTDIR)$(LIBDEST)/distutils/tests ; \
@@ -1159,6 +1160,7 @@ libinstall: build_all $(srcdir)/Lib/$(PL
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
$(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
+endif
# Create the PLATDIR source directory, if one wasn't distributed..
$(srcdir)/Lib/$(PLATDIR):

+ 0
- 11
lang/python/python/patches/004-do-not-write-bytes-codes.patch View File

@ -1,11 +0,0 @@
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -71,7 +71,7 @@ int Py_InteractiveFlag; /* Needed by Py_
int Py_InspectFlag; /* Needed to determine whether to exit at SystemExit */
int Py_NoSiteFlag; /* Suppress 'import site' */
int Py_BytesWarningFlag; /* Warn on comparison between bytearray and unicode */
-int Py_DontWriteBytecodeFlag; /* Suppress writing bytecode files (*.py[co]) */
+int Py_DontWriteBytecodeFlag = 1; /* Suppress writing bytecode files (*.py[co]) */
int Py_UseClassExceptionsFlag = 1; /* Needed by bltinmodule.c: deprecated */
int Py_FrozenFlag; /* Needed by getpath.c */
int Py_UnicodeFlag = 0; /* Needed by compile.c */

+ 0
- 57
lang/python/python/patches/005-fix-bluetooth-support.patch View File

@ -1,57 +0,0 @@
--- a/configure
+++ b/configure
@@ -7084,7 +7084,7 @@ sys/param.h sys/poll.h sys/random.h sys/
sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h
+linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -7306,6 +7306,24 @@ fi
fi
+# bluetooth/bluetooth.h has been known to not compile with -std=c99.
+# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
+SAVE_CFLAGS=$CFLAGS
+CFLAGS="-std=c99 $CFLAGS"
+for ac_header in bluetooth/bluetooth.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default"
+if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_BLUETOOTH_BLUETOOTH_H 1
+_ACEOF
+
+fi
+
+done
+
+CFLAGS=$SAVE_CFLAGS
+
# On Linux, netlink.h requires asm/types.h
for ac_header in linux/netlink.h
do :
--- a/configure.ac
+++ b/configure.ac
@@ -1739,10 +1739,17 @@ sys/param.h sys/poll.h sys/random.h sys/
sys/termio.h sys/time.h \
sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
-bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
+linux/tipc.h spawn.h util.h alloca.h sys/sysmacros.h)
AC_HEADER_DIRENT
AC_HEADER_MAJOR
+# bluetooth/bluetooth.h has been known to not compile with -std=c99.
+# http://permalink.gmane.org/gmane.linux.bluez.kernel/22294
+SAVE_CFLAGS=$CFLAGS
+CFLAGS="-std=c99 $CFLAGS"
+AC_CHECK_HEADERS(bluetooth/bluetooth.h)
+CFLAGS=$SAVE_CFLAGS
+
# On Linux, netlink.h requires asm/types.h
AC_CHECK_HEADERS(linux/netlink.h,,,[
#ifdef HAVE_ASM_TYPES_H

+ 0
- 16
lang/python/python/patches/006-remove-multi-arch-and-local-paths.patch View File

@ -1,16 +0,0 @@
--- a/setup.py
+++ b/setup.py
@@ -500,13 +500,8 @@ class PyBuildExt(build_ext):
os.unlink(tmpfile)
def detect_modules(self):
- # Ensure that /usr/local is always used
- if not cross_compiling:
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
if cross_compiling:
self.add_gcc_paths()
- self.add_multiarch_paths()
# Add paths specified in the environment variables LDFLAGS and
# CPPFLAGS for header and library files.

+ 0
- 10
lang/python/python/patches/007-distutils-do-not-adjust-path.patch View File

@ -1,10 +0,0 @@
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -89,6 +89,7 @@ class build_scripts (Command):
adjust = 1
post_interp = match.group(1) or ''
+ adjust = 0
if adjust:
log.info("copying and adjusting %s -> %s", script,
self.build_dir)

+ 0
- 50
lang/python/python/patches/008-distutils-use-python-sysroot.patch View File

@ -1,50 +0,0 @@
Adjust library/header paths for cross-compilation
When cross-compiling third-party extensions, the get_python_inc() or
get_python_lib() can be called, to return the path to headers or
libraries. However, they use the sys.prefix of the host Python, which
returns incorrect paths when cross-compiling (paths pointing to host
headers and libraries).
In order to fix this, we introduce the _python_sysroot, _python_prefix
and _python_exec_prefix variables, that allow to override these
values, and get correct header/library paths when cross-compiling
third-party Python modules.
The _python_sysroot variable is also used to prefix the LIBDIR value
taken from the sysconfigdata module.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -19,8 +19,13 @@ import sys
from distutils.errors import DistutilsPlatformError
# These are needed in a couple of spots, so just compute them once.
-PREFIX = os.path.normpath(sys.prefix)
-EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+if "_python_sysroot" in os.environ:
+ _sysroot=os.environ.get('_python_sysroot')
+ PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
+ EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
+else:
+ PREFIX = os.path.normpath(sys.prefix)
+ EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
# Path to the base directory of the project. On Windows the binary may
# live in project/PCBuild9. If we're dealing with an x64 Windows build,
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -240,7 +240,10 @@ class build_ext (Command):
if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
if not sysconfig.python_build:
# building third party extensions
- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
+ libdir = sysconfig.get_config_var('LIBDIR')
+ if "_python_sysroot" in os.environ:
+ libdir = os.environ.get("_python_sysroot") + libdir
+ self.library_dirs.append(libdir)
else:
# building python standard extensions
self.library_dirs.append('.')

+ 0
- 32
lang/python/python/patches/009-do-not-use-dblib_dir-when-cross-compiling.patch View File

@ -1,32 +0,0 @@
--- a/setup.py
+++ b/setup.py
@@ -1129,6 +1129,7 @@ class PyBuildExt(build_ext):
if db_setup_debug: print "db lib: ", dblib, "not found"
except db_found:
+ rt_dblib_dir = None if cross_compiling else dblib_dir
if db_setup_debug:
print "bsddb using BerkeleyDB lib:", db_ver, dblib
print "bsddb lib dir:", dblib_dir, " inc dir:", db_incdir
@@ -1143,7 +1144,7 @@ class PyBuildExt(build_ext):
exts.append(Extension('_bsddb', ['_bsddb.c'],
depends = ['bsddb.h'],
library_dirs=dblib_dir,
- runtime_library_dirs=dblib_dir,
+ runtime_library_dirs=rt_dblib_dir,
include_dirs=db_incs,
libraries=dblibs))
else:
@@ -1354,10 +1355,11 @@ class PyBuildExt(build_ext):
break
elif cand == "bdb":
if db_incs is not None:
+ rt_dblib_dir = None if cross_compiling else dblib_dir
print "building dbm using bdb"
dbmext = Extension('dbm', ['dbmmodule.c'],
library_dirs=dblib_dir,
- runtime_library_dirs=dblib_dir,
+ runtime_library_dirs=rt_dblib_dir,
include_dirs=db_incs,
define_macros=[
('HAVE_BERKDB_H', None),

+ 0
- 13
lang/python/python/patches/010-do-not-add-rt-lib-dirs-when-cross-compiling.patch View File

@ -1,13 +0,0 @@
--- a/setup.py
+++ b/setup.py
@@ -509,8 +509,9 @@ class PyBuildExt(build_ext):
# directly since an inconsistently reproducible issue comes up where
# the environment variable is not set even though the value were passed
# into configure and stored in the Makefile (issue found on OS X 10.3).
+ rt_lib_dirs = [] if cross_compiling else self.compiler.runtime_library_dirs
for env_var, arg_name, dir_list in (
- ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
+ ('LDFLAGS', '-R', rt_lib_dirs),
('LDFLAGS', '-L', self.compiler.library_dirs),
('CPPFLAGS', '-I', self.compiler.include_dirs)):
env_val = sysconfig.get_config_var(env_var)

+ 0
- 10
lang/python/python/patches/012-add-support-source-date-epoch-pyc.patch View File

@ -1,10 +0,0 @@
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -108,6 +108,7 @@ def compile(file, cfile=None, dfile=None
timestamp = long(os.fstat(f.fileno()).st_mtime)
except AttributeError:
timestamp = long(os.stat(file).st_mtime)
+ timestamp = long(os.getenv('SOURCE_DATE_EPOCH', timestamp))
codestring = f.read()
try:
codeobject = __builtin__.compile(codestring, dfile or file,'exec')

+ 0
- 28
lang/python/python/patches/013-getbuildinfo-date-time-source-date-epoch.patch View File

@ -1,28 +0,0 @@
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -634,6 +634,16 @@ regen-all: regen-opcode-targets regen-gr
############################################################################
# Special rules for object files
+DATE_FMT = %b %d %Y
+TIME_FMT = %H:%M:%S
+ifdef SOURCE_DATE_EPOCH
+ BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)")
+ BUILD_TIME ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(TIME_FMT)" 2>/dev/null || date -u "+$(TIME_FMT)")
+else
+ BUILD_DATE ?= $(shell date "+$(DATE_FMT)")
+ BUILD_TIME ?= $(shell date "+$(TIME_FMT)")
+endif
+
Modules/getbuildinfo.o: $(PARSER_OBJS) \
$(OBJECT_OBJS) \
$(PYTHON_OBJS) \
@@ -642,6 +652,8 @@ Modules/getbuildinfo.o: $(PARSER_OBJS) \
$(MODOBJS) \
$(srcdir)/Modules/getbuildinfo.c
$(CC) -c $(PY_CFLAGS) \
+ -DDATE="\"$(BUILD_DATE)\"" \
+ -DTIME="\"$(BUILD_TIME)\"" \
-DGITVERSION="\"`LC_ALL=C $(GITVERSION)`\"" \
-DGITTAG="\"`LC_ALL=C $(GITTAG)`\"" \
-DGITBRANCH="\"`LC_ALL=C $(GITBRANCH)`\"" \

+ 0
- 31
lang/python/python/patches/021-compileall-add-recursion-option.patch View File

@ -1,31 +0,0 @@
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -152,10 +152,10 @@ def main():
"""Script main program."""
import getopt
try:
- opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:i:')
+ opts, args = getopt.getopt(sys.argv[1:], 'lr:fqd:x:i:')
except getopt.error, msg:
print msg
- print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
+ print "usage: python compileall.py [-l] [-r recursion] [-f] [-q] [-d destdir] " \
"[-x regexp] [-i list] [directory|file ...]"
print
print "arguments: zero or more file and directory names to compile; " \
@@ -164,6 +164,7 @@ def main():
print
print "options:"
print "-l: don't recurse into subdirectories"
+ print "-r recursion: control the maximum recursion level"
print "-f: force rebuild even if timestamps are up-to-date"
print "-q: output only error messages"
print "-d destdir: directory to prepend to file paths for use in " \
@@ -187,6 +188,7 @@ def main():
flist = None
for o, a in opts:
if o == '-l': maxlevels = 0
+ if o == '-r': maxlevels = int(a)
if o == '-d': ddir = a
if o == '-f': force = 1
if o == '-q': quiet = 1

+ 0
- 74
lang/python/python/patches/024-musl-find_library.patch View File

@ -1,74 +0,0 @@
https://bugs.python.org/issue21622
Based on the patch from Alpine Linux
https://git.alpinelinux.org/aports/tree/main/python2/musl-find_library.patch
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -86,6 +86,8 @@ if os.name == "posix" and sys.platform =
elif os.name == "posix":
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
import re, tempfile, errno
+ from glob import glob
+ musl_ldso = glob('/lib/ld-musl-*.so.1')
def _findLib_gcc(name):
# Run GCC's linker with the -t (aka --trace) option and examine the
@@ -232,6 +234,57 @@ elif os.name == "posix":
def find_library(name, is64 = False):
return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
+ elif musl_ldso and os.path.isfile(musl_ldso[0]):
+
+ def _is_elf(filepath):
+ try:
+ with open(filepath, 'rb') as fh:
+ return fh.read(4) == b'\x7fELF'
+ except:
+ return False
+
+ def find_library(name):
+ # absolute name?
+ if os.path.isabs(name):
+ if _is_elf(name):
+ return name
+ else:
+ return None
+
+ # special case for unified standard libs
+ stdlibs = ['libcrypt.so', 'libdl.so', 'libm.so', 'libpthread.so', 'libresolv.so', 'librt.so', 'libutil.so', 'libxnet.so']
+ if name in stdlibs:
+ name = 'libc.so'
+ elif ('lib' + name + '.so') in stdlibs:
+ name = 'c'
+
+ paths = []
+ # read path list from /etc/ld-musl-$(ARCH).path
+ path_list = musl_ldso[0].replace('/lib/', '/etc/').replace('.so.1', '.path')
+ try:
+ with open(path_list, 'r') as fh:
+ paths = [path for line in fh for path in line.rstrip('\n').split(':') if path]
+ except:
+ paths = []
+ # default path list if /etc/ld-musl-$(ARCH).path is empty or does not exist
+ if not paths:
+ paths = ['/lib', '/usr/local/lib', '/usr/lib']
+
+ # prepend paths from LD_LIBRARY_PATH
+ if 'LD_LIBRARY_PATH' in os.environ:
+ paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
+
+ for d in paths:
+ f = os.path.join(d, name)
+ if _is_elf(f):
+ return os.path.basename(f)
+
+ prefix = os.path.join(d, 'lib'+name)
+ for suffix in ['.so', '.so.*']:
+ for f in glob('{0}{1}'.format(prefix, suffix)):
+ if _is_elf(f):
+ return os.path.basename(f)
+
else:
def _findSoname_ldconfig(name):

+ 0
- 11
lang/python/python/patches/025-utime.patch View File

@ -1,11 +0,0 @@
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -3070,7 +3070,7 @@ done:
if (arg == Py_None) {
/* optional time values not given */
Py_BEGIN_ALLOW_THREADS
- res = utime(path, NULL);
+ res = utimes(path, NULL);
Py_END_ALLOW_THREADS
}
else if (!PyTuple_Check(arg) || PyTuple_Size(arg) != 2) {

+ 0
- 209
lang/python/python/patches/026-bpo-34585-Dont-do-runtime-test-to-get-float-byte-order-GH-9085.patch View File

@ -1,209 +0,0 @@
From 2a9c3805ddedf282881ef7811a561c70b74f80b1 Mon Sep 17 00:00:00 2001
From: Ross Burton <ross@burtonini.com>
Date: Wed, 19 Sep 2018 07:25:48 +0100
Subject: [PATCH] closes bpo-34585: Don't do runtime test to get float byte
order. (GH-9085)
Currently configure.ac uses AC_RUN_IFELSE to determine the byte order of doubles, but this silently fails under cross compilation and Python doesn't do floats properly.
Instead, steal a macro from autoconf-archive which compiles code using magic doubles (which encode to ASCII) and grep for the representation in the binary.
RFC because this doesn't yet handle the weird ancient ARMv4 OABI 'mixed-endian' encoding properly. This encoding is ancient and I don't believe the union of "Python 3.8 users" and "OABI users" has anything in. Should the support for this just be dropped too? Alternatively, someone will need to find an OABI toolchain to verify the encoding of the magic double.
---
.../2018-09-18-16-28-31.bpo-34585.CGMu0h.rst | 3 +
configure.ac | 76 +++--------------
m4/ax_c_float_words_bigendian.m4 | 83 +++++++++++++++++++
3 files changed, 99 insertions(+), 63 deletions(-)
create mode 100644 Misc/NEWS.d/next/Build/2018-09-18-16-28-31.bpo-34585.CGMu0h.rst
create mode 100644 m4/ax_c_float_words_bigendian.m4
diff --git a/Misc/NEWS.d/next/Build/2018-09-18-16-28-31.bpo-34585.CGMu0h.rst b/Misc/NEWS.d/next/Build/2018-09-18-16-28-31.bpo-34585.CGMu0h.rst
new file mode 100644
index 0000000000000..01318e6e46a32
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2018-09-18-16-28-31.bpo-34585.CGMu0h.rst
@@ -0,0 +1,3 @@
+Check for floating-point byte order in configure.ac using compilation tests
+instead of executing code, so that these checks work in cross-compiled
+builds.
diff --git a/configure.ac b/configure.ac
index 03638f8ae9bc7..96331ec221be2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4206,74 +4206,24 @@ fi
# * Check for various properties of floating point *
# **************************************************
-AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_little_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_little_endian_double=yes],
-[ac_cv_little_endian_double=no],
-[ac_cv_little_endian_double=no])])
-AC_MSG_RESULT($ac_cv_little_endian_double)
-if test "$ac_cv_little_endian_double" = yes
-then
- AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
- [Define if C doubles are 64-bit IEEE 754 binary format, stored
- with the least significant byte first])
-fi
-
-AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_big_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_big_endian_double=yes],
-[ac_cv_big_endian_double=no],
-[ac_cv_big_endian_double=no])])
-AC_MSG_RESULT($ac_cv_big_endian_double)
-if test "$ac_cv_big_endian_double" = yes
+AX_C_FLOAT_WORDS_BIGENDIAN
+if test "$ax_cv_c_float_words_bigendian" = "yes"
then
AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
[Define if C doubles are 64-bit IEEE 754 binary format, stored
with the most significant byte first])
-fi
-
-# Some ARM platforms use a mixed-endian representation for doubles.
-# While Python doesn't currently have full support for these platforms
-# (see e.g., issue 1762561), we can at least make sure that float <-> string
-# conversions work.
-AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_mixed_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_mixed_endian_double=yes],
-[ac_cv_mixed_endian_double=no],
-[ac_cv_mixed_endian_double=no])])
-AC_MSG_RESULT($ac_cv_mixed_endian_double)
-if test "$ac_cv_mixed_endian_double" = yes
+elif test "$ax_cv_c_float_words_bigendian" = "no"
then
+ AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
+ [Define if C doubles are 64-bit IEEE 754 binary format, stored
+ with the least significant byte first])
+else
+ # Some ARM platforms use a mixed-endian representation for doubles.
+ # While Python doesn't currently have full support for these platforms
+ # (see e.g., issue 1762561), we can at least make sure that float <-> string
+ # conversions work.
+ # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
+ # or little, then it must be this?
AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
[Define if C doubles are 64-bit IEEE 754 binary format, stored
in ARM mixed-endian order (byte order 45670123)])
diff --git a/m4/ax_c_float_words_bigendian.m4 b/m4/ax_c_float_words_bigendian.m4
new file mode 100644
index 0000000000000..216b90d803187
--- /dev/null
+++ b/m4/ax_c_float_words_bigendian.m4
@@ -0,0 +1,83 @@
+# ===============================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_c_float_words_bigendian.html
+# ===============================================================================
+#
+# SYNOPSIS
+#
+# AX_C_FLOAT_WORDS_BIGENDIAN([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
+#
+# DESCRIPTION
+#
+# Checks the ordering of words within a multi-word float. This check is
+# necessary because on some systems (e.g. certain ARM systems), the float
+# word ordering can be different from the byte ordering. In a multi-word
+# float context, "big-endian" implies that the word containing the sign
+# bit is found in the memory location with the lowest address. This
+# implementation was inspired by the AC_C_BIGENDIAN macro in autoconf.
+#
+# The endianness is detected by first compiling C code that contains a
+# special double float value, then grepping the resulting object file for
+# certain strings of ASCII values. The double is specially crafted to have
+# a binary representation that corresponds with a simple string. In this
+# implementation, the string "noonsees" was selected because the
+# individual word values ("noon" and "sees") are palindromes, thus making
+# this test byte-order agnostic. If grep finds the string "noonsees" in
+# the object file, the target platform stores float words in big-endian
+# order. If grep finds "seesnoon", float words are in little-endian order.
+# If neither value is found, the user is instructed to specify the
+# ordering.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Daniel Amelang <dan@amelang.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 11
+
+AC_DEFUN([AX_C_FLOAT_WORDS_BIGENDIAN],
+ [AC_CACHE_CHECK(whether float word ordering is bigendian,
+ ax_cv_c_float_words_bigendian, [
+
+ax_cv_c_float_words_bigendian=unknown
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+
+double d = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
+
+]])], [
+
+if grep noonsees conftest.$ac_objext >/dev/null ; then
+ ax_cv_c_float_words_bigendian=yes
+fi
+if grep seesnoon conftest.$ac_objext >/dev/null ; then
+ if test "$ax_cv_c_float_words_bigendian" = unknown; then
+ ax_cv_c_float_words_bigendian=no
+ else
+ ax_cv_c_float_words_bigendian=unknown
+ fi
+fi
+
+])])
+
+case $ax_cv_c_float_words_bigendian in
+ yes)
+ m4_default([$1],
+ [AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
+ [Define to 1 if your system stores words within floats
+ with the most significant word first])]) ;;
+ no)
+ $2 ;;
+ *)
+ m4_default([$3],
+ [AC_MSG_ERROR([
+
+Unknown float word ordering. You need to manually preset
+ax_cv_c_float_words_bigendian=no (or yes) according to your system.
+
+ ])]) ;;
+esac
+
+])# AX_C_FLOAT_WORDS_BIGENDIAN

+ 0
- 218
lang/python/python/patches/027-bpo-34585-run-autoconf-GH-9411-edited.patch View File

@ -1,218 +0,0 @@
From b3b8cb419e496629873fa7dda82a01863f58617a Mon Sep 17 00:00:00 2001
From: Benjamin Peterson <benjamin@python.org>
Date: Tue, 18 Sep 2018 23:49:05 -0700
Subject: [PATCH] run autoconf (GH-9411)
Follow up to 2a9c3805ddedf282881ef7811a561c70b74f80b1 (bpo-34585).
---
aclocal.m4 | 1 +
configure | 146 ++++++++++++++++----------------------------------
pyconfig.h.in | 4 ++
3 files changed, 51 insertions(+), 100 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 6a24d8e6b9c00..030e6877de9f7 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -288,3 +288,4 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR
+m4_include([m4/ax_c_float_words_bigendian.m4])
diff --git a/configure b/configure
index 7b0c734b5e25e..38546d6ca7b40 100755
--- a/configure
+++ b/configure
@@ -13853,131 +13853,77 @@ fi
# * Check for various properties of floating point *
# **************************************************
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are little-endian IEEE 754 binary64" >&5
-$as_echo_n "checking whether C doubles are little-endian IEEE 754 binary64... " >&6; }
-if ${ac_cv_little_endian_double+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether float word ordering is bigendian" >&5
+$as_echo_n "checking whether float word ordering is bigendian... " >&6; }
+if ${ax_cv_c_float_words_bigendian+:} false; then :
$as_echo_n "(cached) " >&6
else
-if test "$cross_compiling" = yes; then :
- ac_cv_little_endian_double=no
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+ax_cv_c_float_words_bigendian=unknown
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
- return 0;
- else
- return 1;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ac_cv_little_endian_double=yes
-else
- ac_cv_little_endian_double=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
+double d = 90904234967036810337470478905505011476211692735615632014797120844053488865816695273723469097858056257517020191247487429516932130503560650002327564517570778480236724525140520121371739201496540132640109977779420565776568942592.0;
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_little_endian_double" >&5
-$as_echo "$ac_cv_little_endian_double" >&6; }
-if test "$ac_cv_little_endian_double" = yes
-then
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
-$as_echo "#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1" >>confdefs.h
+if grep noonsees conftest.$ac_objext >/dev/null ; then
+ ax_cv_c_float_words_bigendian=yes
+fi
+if grep seesnoon conftest.$ac_objext >/dev/null ; then
+ if test "$ax_cv_c_float_words_bigendian" = unknown; then
+ ax_cv_c_float_words_bigendian=no
+ else
+ ax_cv_c_float_words_bigendian=unknown
+ fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are big-endian IEEE 754 binary64" >&5
-$as_echo_n "checking whether C doubles are big-endian IEEE 754 binary64... " >&6; }
-if ${ac_cv_big_endian_double+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
-if test "$cross_compiling" = yes; then :
- ac_cv_big_endian_double=no
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
- return 0;
- else
- return 1;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ac_cv_big_endian_double=yes
-else
- ac_cv_big_endian_double=no
fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_float_words_bigendian" >&5
+$as_echo "$ax_cv_c_float_words_bigendian" >&6; }
-fi
+case $ax_cv_c_float_words_bigendian in
+ yes)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_big_endian_double" >&5
-$as_echo "$ac_cv_big_endian_double" >&6; }
-if test "$ac_cv_big_endian_double" = yes
-then
+$as_echo "#define FLOAT_WORDS_BIGENDIAN 1" >>confdefs.h
+ ;;
+ no)
+ ;;
+ *)
+ as_fn_error $? "
-$as_echo "#define DOUBLE_IS_BIG_ENDIAN_IEEE754 1" >>confdefs.h
+Unknown float word ordering. You need to manually preset
+ax_cv_c_float_words_bigendian=no (or yes) according to your system.
-fi
+ " "$LINENO" 5 ;;
+esac
-# Some ARM platforms use a mixed-endian representation for doubles.
-# While Python doesn't currently have full support for these platforms
-# (see e.g., issue 1762561), we can at least make sure that float <-> string
-# conversions work.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C doubles are ARM mixed-endian IEEE 754 binary64" >&5
-$as_echo_n "checking whether C doubles are ARM mixed-endian IEEE 754 binary64... " >&6; }
-if ${ac_cv_mixed_endian_double+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-if test "$cross_compiling" = yes; then :
- ac_cv_mixed_endian_double=no
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
+if test "$ax_cv_c_float_words_bigendian" = "yes"
+then
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
- return 0;
- else
- return 1;
-}
+$as_echo "#define DOUBLE_IS_BIG_ENDIAN_IEEE754 1" >>confdefs.h
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ac_cv_mixed_endian_double=yes
-else
- ac_cv_mixed_endian_double=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
+elif test "$ax_cv_c_float_words_bigendian" = "no"
+then
-fi
+$as_echo "#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1" >>confdefs.h
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_mixed_endian_double" >&5
-$as_echo "$ac_cv_mixed_endian_double" >&6; }
-if test "$ac_cv_mixed_endian_double" = yes
-then
+else
+ # Some ARM platforms use a mixed-endian representation for doubles.
+ # While Python doesn't currently have full support for these platforms
+ # (see e.g., issue 1762561), we can at least make sure that float <-> string
+ # conversions work.
+ # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
+ # or little, then it must be this?
$as_echo "#define DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1" >>confdefs.h
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 360f79994fafe..41e0479cad2e3 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -30,6 +30,10 @@
/* Define if --enable-ipv6 is specified */
#undef ENABLE_IPV6
+/* Define to 1 if your system stores words within floats with the most
+ significant word first */
+#undef FLOAT_WORDS_BIGENDIAN
+
/* Define if flock needs to be linked with bsd library. */
#undef FLOCK_NEEDS_LIBBSD

Loading…
Cancel
Save