Package: pdm-pep517
PDM-PEP517This project has been renamed and re-published aspdm-backendYet anotherPEP 517backend.This is the backend forPDMprojects, while you can also use it alone.
It reads the metadata ofPEP 621format and coverts it toCore metadata.Use as PEP 517 build backendEdit yourpyproject.tomlas follows:[build-system]requires=["pdm-pep517"]build-backend="pdm.pep517.api"Tool specific settingsBesides of the standard fields specified in PEP 621, PDM-PEP517 honors some other settings to change the build behavior. They should be defined under[tool.pdm.build]table:[tool.pdm.build]# Specify where the Python packages live.package-dir="src"# File patterns to include, the paths are relative to the project root.includes=[]# File patterns to exclude, the paths are relative to the project root.excludes=[]# File patterns to include in source distribution and exclude in wheel distribution.source-includes=[]# An extra script to populate the arguments of `setup()`, one can build C extensions with this script. Or a custom build() function to generate files.setup-script="build.py"# If true, the setup-script will run in a generated `setup.py` file.run-setuptools=false# Override the Is-Purelib value in the wheel.is-purelib=true# Change the editable-backend: path(default) or editableseditable-backend="editables"You don't have to specify all of them, PDM-PEP517 can also derive these fields smartly, based on some best practices of Python packaging.Dynamic project versionpdm-pep517can also determine the version of the project dynamically. To do this, you need to leave theversionfield out from yourpyproject.tomland adddynamic = ["version"]:[project]
...- version = "0.1.0" remove this line+ dynamic = ["version"]Then in[tool.pdm.version]table, specify how to get the version info. There are two ways supported:Read from a static string in the given file path:[tool.pdm.version]source="file"path="mypackage/__init__.py"In this way, the file MUST contain a line like:__version__="0.1.0"# Single quotes and double quotes are both OK, comments are allowed.Read from SCM tag, supportinggitandhg:[tool.pdm.version]source="scm"When building from a source tree where SCM is not available, you can use the env varPDM_PEP517_SCM_VERSIONto pretend the version is set.PDM_PEP517_SCM_VERSION=0.1.0python-mbuildWriting SCM version to fileYou can instruct PDM-PEP517 to write back the dynamic version fetched from SCM to a file:[tool.pdm.version]source="scm"write_to="foo/version.txt"By default, PDM-PEP517 will just write the SCM version itself.
You can provide a template as a Python-formatted string to create a syntactically correct Python assignment:[tool.pdm.version]source="scm"write_to="foo/_version.py"write_template="__version__ = '{}'"Note that PDM-PEP517 will rewrite the whole file each time, so you can't have additional contents in that file.Custom Build ScriptWith custom build script, you can call other tools to generates files to be included in the wheel.
Just set thesetup-scriptfield under[tool.pdm.build]table to the path of the script.In the script, you expose a function namedbuild, which takes two arguments:src(str): the path of the source directorydst(str): the path of the destination directoryExample:defbuild(src,dst):withopen(os.path.join(dst,"myfile.txt"),"w")asf:# Put a file in the wheelf.write("Hello World!")Note that the generated file hierarchy will be preserved in the wheel:$dst/myfile.txt->$wheel_root/myfile.txt.Whenrun-setuptoolsistrue, thebuildfunction will be called in a generatedsetup.pyfile, with the setup parameters as the only argument.Example:defbuild(setup_params):# add ext_modules to the setup() argumentssetup_parms.update(ext_modules=[Extension("myextension",["myextension.c"])])The will result in asetup()call like following:setup(name="mypackage",# Other metadata fieldsext_modules=[Extension("myextension",["myextension.c"])],)By default, whensetup-scriptis set, the resulted wheel will be platform-specific, but you can override this behavior by settingis-purelibtofalseSupported config settingspdm-pep517allows passingconfig_settingsto modify the build behavior. It use the same option convention aspython setup.py bdist_wheel.--python-tag
    Override the python implementation compatibility tag(e.g. cp37, py3, pp3)
--py-limited-api
    Python tag (cp32|cp33|cpNN) for abi3 wheel tag
--plat-name
    Override the platform name(e.g. win_amd64, manylinux2010_x86_64)For example, you can supply these options withbuild:python-mbuild--sdist--wheel--outdirdist/--config-setting="--python-tag=cp37"--config-setting="--plat-name=win_amd64"pipdoesn't support passingconfig_settingsyet, please stick tobuildas the recommended frontend.LicenseThis project is licensed underMIT license.