Commit Graph

203 Commits

Author SHA1 Message Date
Po-Chuan Hsieh
94235dd8c0 Mk/Uses/python.mk: Update PY_TOMLI
devel/py-pyproject-fmt 2.3.0 requires textproc/py-tomli 2.0.2+.
2024-10-14 13:26:25 +08:00
Po-Chuan Hsieh
180cd7365c Mk/Uses/python.mk: Introduce PY_TOMLI
- Convert ports to use PY_TOMLI to simplify Makefile.

The minimal version is set to 2.0.1 because it is required by multiple ports such as devel/py-poetry.
The upper bound of version is set to 3 because it is limited by devel/py-poetry.

With hat:	python
2024-07-22 00:55:40 +08:00
Po-Chuan Hsieh
485b9da942 Mk/Uses/python.mk: Update CRYPTOGRAPHY_DEPENDS 2024-07-21 21:04:18 +08:00
Wen Heping
d3e0e547ee math/py-numpy: Update to 1.26.4
PR:		277689
Reported by:	wen@
Exp-run by:	antoine@
2024-06-15 14:23:11 +00:00
Ruslan Makhmatkhanov
62a23ef093 Mk/Uses/python.mk: Switch to Python 3.11 as default
The switch is a collective effort of Wen Heping, Alastair Hogge,
Muhammad Moinur Rahman, Antoine Brodin, Vladimir Druzenko,
Thomas Zander, Daniel Engberg et al.

PR:		275494
Tested by:	antoine (multiple exp-runs)
With hat:   python
2024-05-29 16:51:35 +03:00
Po-Chuan Hsieh
0a4260b3a1 Mk/Uses/python.mk: Introduce PY_EXCEPTIONGROUP
The minimal version is set to 1.1.1 because it is required by devel/py-cattrs.
Convert ports to use PY_EXCEPTIONGROUP to simplify Makefile.

With hat:	python
2024-04-08 20:37:28 +08:00
Po-Chuan Hsieh
719c503257 Mk/Uses/python.mk: Update CRYPTOGRAPHY_DEPENDS
Changes:	https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst
		https://cryptography.io/en/latest/changelog/
Security:	CVE-2024-26130
2024-03-23 22:50:11 +08:00
Tijl Coosemans
572f236169 Mk/*: Build with a clean environment
Both our make and gmake use the MAKEFLAGS environment variable but the
values aren't compatible and the latest version of gmake complains about
that.  To rule out that any environment variable can cause problems like
this, add a new command SETENVI=/usr/bin/env -i that clears the
environment, and use it to run upstream build systems with a clean
environment.

Introduce a new variable WRK_ENV that contains the environment to use
with SETENVI in all targets that run upstream build commands.  Variables
that are common between CONFIGURE_ENV and MAKE_ENV could be moved to
WRK_ENV but for now it just contains a minimal environment:

HOME=${WRKDIR}: Fixes USES=elixir ports that were using the user's HOME.
OSVERSION: For cross building; determines the output of uname -K and
getosreldate(3); affects net/freebsd-telnetd for example.
PATH: Fixes USES=gem ports that were using the user's PATH.
PWD=$${PWD}: Preserve current working directory; affects USES=go ports.
TERM: To preserve colored output to terminals.
TMPDIR: For users who define that.
UNAME_*: For cross building; determines the output of uname(1); affects
lang/python* for example.

This commit deals with everything under Mk/.  Ports that have their own
targets running upstream build commands can switch to SETENVI later.

The ports tree adds its definition of ARCH to the MAKEFLAGS environment
variable, which is interpreted by sub-makes as command line arguments,
which means that any definition of ARCH in upstream makefiles was
overridden.  The following ports required fixes now that this is no
longer the case.

games/iortcw, games/q3cellshading, games/tremulous:
These use Quake 3 engine code.  Fix use of ARCH.  Reduce diff between
FreeBSD code and Linux code.

games/legesmotus:
Remove ARCH related patches.

lang/ocaml:
Patch configure script so it detects amd64 correctly.  Also make the
powerpc case consistent with the other architectures.  This also affects
other ocaml ports like devel/ocaml-ocamlbuild and math/ocaml-num that
include a Makefile.config installed by lang/ocaml.  While here, use
SETENVI in check-test target.

net/libnatpmp:
Use of upstream definition of ARCH triggers installation in PREFIX/lib64
on amd64.  Disable this.

PR:		276478
Approved by:	portmgr (antoine)
Exp-run by:	antoine
2024-02-29 21:21:37 +01:00
Po-Chuan Hsieh
cb35a216c8 Mk/Uses/python.mk: Update USE_PYTHON=cryptography*
Reference:	https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst#4106---2023-11-27
Security:	CVE-2023-49083
2023-12-02 06:13:29 +08:00
Po-Chuan Hsieh
008c78011e Mk/Uses/python.mk: Update CRYPTOGRAPHY_DEPENDS
py-pyhanko-certvalidator 0.26.2 requires py-cryptography 41.0.5+
2023-11-27 18:30:05 +08:00
Po-Chuan Hsieh
3226ddb8f0 Mk/Uses/python.mk: Update CRYPTOGRAPHY_DEPENDS
py-webauthn 1.11.0 requires py-cryptography 41.0.4+.
2023-10-01 07:31:08 +08:00
Po-Chuan Hsieh
9ef210b6cd Mk/Uses/python.mk: Remove PYTHON3_DEFAULT and use PYTHON_DEFAULT instead
- Remove unnecessary PYTHON3_DEFAULT
- Replace PYTHON3_DEFAULT with PYTHON_DEFAULT

Regarding DEFAULT_VERSIONS, both python and python3 point to the same value
which makes python3 a duplicate. And we do not really support python=2.7.
Therefore, use python for Python 3.x and python2 for legacy Python 2.7.
2023-09-30 08:46:32 +08:00
Po-Chuan Hsieh
3754fc5f19 *: Replace USES=pycryptography* with USE_PYTHON=cryptography{,_build,_test}
- Introduce USE_PYTHON=cryptography{,_build,_test}
- Switch all 96 ports from USES=pycryptography to with USE_PYTHON=cryptography{,_build,_test}
- Remove Mk/Uses/pycryptography.mk

PR:		273727
Approved by:	tcberner (portmgr)
Exp-run by:	antoine
2023-09-29 22:19:56 +08:00
Po-Chuan Hsieh
223c60c5d6 Mk/Uses/python.mk: Cosmetic change 2023-09-12 02:21:54 +08:00
John Hein
aa9736e3e5 python.mk: Improve CMake/Python integration
Suport FindPython.cmake, FindPython3.cmake, FindPython2.cmake modules by
adding Python{,2,3}_EXECUTABLE to CMAKE_ARGS in python.mk.

CMake supports more than one way to search for python.  Currently
python.mk passes -DPython_ADDITIONAL_VERSIONS=${PYTHON_VER} to help
FindPython{Interp,Libs}.cmake modules "find" the version of python that
a port build wants to use.

The FindPython{,2,3}.cmake modules don't know anything about
Python_ADDITIONAL_VERSIONS but use Python{,2,3}_EXECUTABLE as the hint.

PR:		262109
2023-09-05 01:21:35 +08:00
Wen Heping
65c21fd7c9 math/py-numpy: Update to 1.25.0
PR:		272058
Reported by:	wen@
Exp-run by:	antoine@
2023-07-07 20:56:11 +08:00
Po-Chuan Hsieh
12c7567d7d Mk/Uses/python.mk: Clean up after lang/python37 removal 2023-06-30 15:08:05 +08:00
Rene Ladan
c58ef91e06 Mk/Uses: bit more cleanup in USES=python now that 3.7 is sunset 2023-06-27 21:32:09 +02:00
Rene Ladan
53475f525a Mk: unregister expired lang/python3.7 2023-06-27 21:00:27 +02:00
Rene Ladan
e4fee285e6 Mk/Uses/python.mk: update version numbers in some examples 2023-05-20 17:51:18 +02:00
Wen Heping
9414f7024b Mk/Uses/python.mk: Fix a typo
PR:		271265
Reported by:	grahamperrin@freebsd.org
2023-05-08 15:04:14 +08:00
Po-Chuan Hsieh
78d3d0be39 Mk/Uses/python.mk: Fix 34852a28b2
PYTHON3_DEFAULT removal is planned for a PR.
2023-05-08 00:17:26 +08:00
Po-Chuan Hsieh
34852a28b2 Mk/Uses/python.mk: Fix PLIST issue for USE_PYTHON=pep517
Currently "USE_PYTHON=autoplist pep517" generates the PLIST as follows:
- Extract the list of installed files from the RECORD file to the intermediate
  PLIST (_PYTHONPKGLIST)
- Manipulate the intermediate PLIST
- Add list of pycache files to the intermediate PLIST

When the RECORD file contains foo.pyc entry, that file will be counted twice in
the PLIST at the end. It will cause check-plist error. This fix removes *.pyc
entries while manipulating the intermediate PLIST to ensure all pycache files
are only counted once.
2023-05-08 00:05:26 +08:00
Antoine Brodin
378e09115c USE_PYTHON=pep517: package python bytecode
Compile and package python bytecode for python ports using pep517.
This can be revisited in the future with a trigger.

Approved by:	portmgr
2023-04-04 18:27:33 +00:00
Charlie Li
33333715d1 python.mk: use gpep517 as build frontend on Python 3.7
Should start allowing PEP-517 packages to build and unbreaking
circular dependencies, however short a shelf life, due to gpep517's
almost nonexistant Python dependency tree.

(PyPA build will continue as the preferred build frontend otherwise,
due to official stewardship, but does not preclude a DEFAULT_VERSIONS
hook in the future)
2023-03-27 01:03:51 -04:00
Po-Chuan Hsieh
fb46fe4b4c Mk/Uses/python.mk: Add support for post-release version (.postX)
The post-release version is normalized to .postX in PEP440. However, it will be
converted to .pX in FreeBSD which means an older version.

% pkg ver -t 1.2.3 1.2.3.p4
>

If the original release is already in the tree, rather than bumping PORTEPOCH,
you could bump PORTREVISION and add .postX to DISTVERSIONSUFFIX.

This fix allows the port to build in this situation.
2023-03-22 03:22:25 +08:00
Po-Chuan Hsieh
bbd8f02407 Mk/Uses/python.mk: Use long options for easier reading (part of de6965254c) 2023-03-22 03:22:25 +08:00
Matthew Seaman
2b7d76adec Mk/Uses/python.mk: Support PEP440 versioning
The python PEP440 version numbering standard is _mostly_ compatible
with FreeBSD port versioning rules.  Exceptions exist, where the
PORTVERSION can be derived from the upstream DISTVERSION
automatically. For example:

PEP440 DISTVERSION:      FreeBSD PORTVERSION:
2.3.post1                2.3.p1

Now, this interacts badly with PEP517 build setups.  hatchling will
enforce PEP440 complicance, so it isn't practical to modify the ported
code to use exactly the FreeBSD version.

Instead, simply referring to DISTVERSION rather than PORTVERSION will
allow the build process to complete smoothly.

See https://reviews.freebsd.org/D39123 for an example port update
which depends on this change

Approved by:	python (maintainer, vishwin)
Differential Revision:	https://reviews.freebsd.org/D39124
2023-03-18 14:20:02 +00:00
Charlie Li
46a71ea3bf python.mk: introduce PY_SETUPTOOLS
Selects the correct setuptools port based on USE_PYTHON=distutils
or not. devel/py-setuptools58 case currently commented out.
2023-03-09 12:35:49 -05:00
Charlie Li
67de7ad43c strip_RECORD.py: move to Mk/Scripts
Requested by: mat
2023-03-09 06:18:17 -05:00
Charlie Li
a1039fe12a python.mk: add PEP517_BUILD_CONFIG_SETTING
Reference: https://pypa-build.readthedocs.io/en/latest/#python--m-build---config-setting
2023-03-08 23:34:38 -05:00
Charlie Li
8731e33283 python.mk: add USE_PYTHON=cython_test 2023-03-08 23:24:47 -05:00
Charlie Li
43ae3588e6 python.mk: use PYTHON_MAJOR_VER for Python 2/3 conditionals 2023-03-08 23:17:52 -05:00
Charlie Li
97741a0217 python.mk: document individual module variables
...except PY_PILLOW, which has been redundant since Python 3.5 removal
and is slowly being removed.
2023-03-08 23:11:08 -05:00
Charlie Li
b0a6205495 python.mk: move PEP-517 docs above distutils 2023-03-08 22:58:34 -05:00
Charlie Li
16a6fecb4f python.mk: use script to process RECORD for the first pass
RECORD is a CSV file [0] containing more data than our plist format
accepts. The original processing method used sed(1) exclusively,
but paths containing quotes, spaces and commas throw it off. Process
the CSV properly instead for the first pass.

References: https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-record-file [0]
2023-03-08 22:33:57 -05:00
Charlie Li
588237f00b python.mk: add man/ to PEP-517 autoplist 2023-03-08 22:07:19 -05:00
Charlie Li
922e7f4145 lang/python: restore USES=python variables and SUB_LIST (no-op)
Has been a to do item for time. These are independent from but used
by the bytecode trigger.
2023-02-27 18:59:30 -05:00
Matthias Andree
a9d9d3a427 lang/python: Revert "add bytecode trigger"
This reverts commit c17ddfbf66.

This causes breakage on several ports, and the next iteration
requires a full exp-run. See:

Differential Revision: https://reviews.freebsd.org/D34739
2023-02-27 22:04:52 +01:00
Charlie Li
853d0bf6fb python.mk: add etc/ to PEP-517 autoplist
This was mistakenly missed in 18982c467f.

Requested by: yasu
2023-02-26 13:48:04 -05:00
Charlie Li
18982c467f python.mk: PEP-517 data_files support
data_files was not initially supported in the framework under the
guise that PyPA through setuptools deprecated the practice. However,
other build backends like flit still support (and advertise as a
"newer" feature) data_files, and certain packages continue to install
operating system-specific files like man pages using Python's
packaging system.

This expands RECORD parsing to account for any data_files beyond
entry_points installed to bin/. It is limited to certain directories
in hier(7) listed under /usr/local to prevent wheels from installing
files to arbitrary locations.

Tested by: yasu (first pass)
Differential Revision: https://reviews.freebsd.org/D38050
2023-02-25 22:14:17 -05:00
Charlie Li
9fbe5f4d77 python.mk: explicitly pass ${PREFIX} to ${PEP517_INSTALL_CMD}
Otherwise the stage prefix is ${PYTHONBASE} by default.

Reported by: John Hein <jcfyecrayz[at]liamekaens[point]com>
PR: 269472
2023-02-25 12:35:32 -05:00
Charlie Li
c17ddfbf66 lang/python: add bytecode trigger
Facilitates compiling, writing and removing bytecode files (.pyc)
in site-packages after all pkg transactions have been completed.

Technical details: https://wiki.freebsd.org/Python/CompiledPackages

Fixes reports of Python port builds as root failing on filesystem
violations due to bytecode file writes where the port did not include
them in the package.

For those ports/packages that currently package bytecode, some
checksum mismatches on those files may occur. This is harmless and
will be rectified, in large as part of a USE_PYTHON=distutils
overhaul to reduce churn.

While here, implement a long-standing todo item of letting lang/python
ports use python.mk bits. Not only does this obviate duplicate
variables in each Makefile, but SUB_LIST (also added) is used for
these triggers.

Co-authored by: tcberner
Approved by: tcberner (mentor)
Differential Revision: https://reviews.freebsd.org/D34739
2023-02-15 16:35:07 -05:00
Wen Heping
b217a15a96 math/py-numpy: Update to 1.24.1
PR:		268594
Reported by:	wen@
Exp-run by:	antoine@
2023-02-08 09:14:27 +08:00
Charlie Li
f5890bd3cb Revert "Mk/Uses/python.mk: Fix USE_PYTHON=pep517: always compile and install bytecode"
Despite installer's default behaviour to compile and install bytecode,
we are not doing so going forward at stage/package time. [0] During
initial development and qualification of PEP-517 framework support,
compiling and installing bytecode at stage/package time was considered,
but was found problematic, fragile and ultimately unreliable, both
currently and historically (with USE_PYTHON=distutils), due to our
fixed plist requirement. While the living binary distribution format
(wheel) specification [1] says to compile bytecode, that is in the
pure Python package management context (pip, etc); nuance always
exists when interacting with "system" package management.

Additionally, "bytecode is an implementation detail of the CPython
interpreter. No guarantees are made that bytecode will not be added,
removed, or changed between versions of Python," thus "should not
be considered to work across Python VMs or Python releases." [2]
This is important to ensuring correctness for those ports specifying
NO_ARCH.

Instead of compiling and installing bytecode at stage/package time,
there is a WIP, review D34739, that compiles and installs bytecode
at install time instead, using triggers.

The aforementioned build_fs_violations will be investigated.

This reverts commit de6965254c.

With hat:	python
Approved by:	tcberner (mentor, portmgr)
Reference:	https://wiki.freebsd.org/Python/PEP-517 [0]
		https://packaging.python.org/en/latest/specifications/binary-distribution-format/ [1]
		https://docs.python.org/3/library/dis.html [2]
2023-02-05 14:05:02 -05:00
Po-Chuan Hsieh
de6965254c Mk/Uses/python.mk: Fix USE_PYTHON=pep517: always compile and install bytecode
- While I'm here, use long options for easier reading [1][2]
- Bump PORTREVISION of dependent ports (USE_PYTHON=pep517) for package change

It fixes build_fs_violation of dependent ports in poudriere (with -t flag).
It is also the default behavior of installer [2].

from py-sphinx log:
=>> Checking for staging violations... done
=>> Error: Filesystem touched during stage (files must install to ${STAGEDIR}):
extra: usr/local/lib/python3.9/site-packages/importlib_metadata/__pycache__
=>> Cleaning up wrkdir

from installer documentation:
--compile-bytecode
    Possible choices: 0, 1, 2
    generate bytecode for the specified optimization level(s) (default=0, 1)
--no-compile-bytecode
    don’t generate bytecode for installed modules
    Default: False

With hat:	python
Reference:	https://pypa-build.readthedocs.io/en/stable/ [1]
		https://installer.pypa.io/en/stable/cli/installer/ [2]
2023-02-06 02:16:47 +08:00
Charlie Li
fd932c2205 devel/py-setuptools58: add
This port will eventually serve as the one used in USE_PYTHON=distutils,
namely for executing ${PYSETUP}. See
https://wiki.freebsd.org/Python/setuptools for details.

Approved by: fluffy (mentor)
Differential Revision: https://reviews.freebsd.org/D38069
2023-01-15 14:55:02 -05:00
Charlie Li
952e0dba49 python.mk: normalise wheel filename arguments in PEP517_INSTALL_CMD
The living binary distribution format specification derived from
PEP-427 [0] prescribes that:

  In distribution names, any run of -_. characters (HYPHEN-MINUS,
  LOW LINE and FULL STOP) should be replaced with _ (LOW LINE), and
  uppercase characters should be replaced with corresponding lowercase
  ones. This is equivalent to PEP 503 normalisation followed by
  replacing - with _. Tools consuming wheels must be prepared to
  accept . (FULL STOP) and uppercase letters, however, as these
  were allowed by an earlier version of this specification.

This fixes staging for packages built under PEP-517 with dashes
(HYPHEN-MINUS) in their names.

[0] https://packaging.python.org/en/latest/specifications/binary-distribution-format/

Reported by: amdmi3
Tested by: yasu, rhurlin
PR: 268893
With hat: python
Approved by: mentors (implicit)
2023-01-13 20:31:41 -05:00
Charlie Li
cc8a1878e0 python.mk: introduce USE_PYTHON=pep517 for PEP-517 support
USE_PYTHON=pep517 takes no arguments. Operation is similar to
USE_PYTHON=distutils, although the build backend specified in
pyproject.toml is to be specified in BUILD_DEPENDS explicitly. A
usage guide and implementation primer is available at:
	https://wiki.freebsd.org/Python/PEP-517

With hat: python
Approved by: fluffy (mentor)
Co-authored by: yuri
PR: 255722
Differential Revision: https://reviews.freebsd.org/D36290
2023-01-11 00:22:16 -05:00
Charlie Li
7d48381cbd Uses/python.mk: revert unapproved feature addition (and consumers)
Change proposal was in discussion with open questions and additional
documented design requirement [0] for submitter to review and provide
feedback on, which was not provided.

Submitter (and anyone else) is welcome to work with python@ to
produce an appropriately reviewed feature.

[0] https://wiki.freebsd.org/Python/PEP-517

With hat: python (vishwin, koobs)
PR: 255722, 265660, 265692, 265693
Approved by: fluffy (mentor)
2022-08-21 21:39:08 -04:00