Installer scripts#

make_dist script#

Script to create a new distribution.

The following options are supported:

pywikibot The pywikibot repository to build (default)

scripts The pywikibot-scripts repository to build

-help

Print documentation of this file and of setup.py

-local

Install the distribution as a local site-package. If a Pywikibot package is already there, it will be uninstalled first. Clears old dist folders first.

-remote

Upload the package to pypi. This cannot be done if the Pywikibot version is a development release. Clears old dist folders first.

-clear

Clear old dist folders and leave. Does not create a distribution.

-upgrade

Upgrade pip first; upgrade or install distribution packages build and twine first.

Usage:

[pwb] make_dist [repo] [options]

Added in version 7.3.

Changed in version 7.4:

  • updates pip, setuptools, wheel and twine packages first

  • installs pre-releases over stable versions

  • also creates built distribution together with source distribution

  • -upgrade option was added

Changed in version 7.5:

  • clear option was added

  • nodist option was added

Changed in version 8.1: nodist option was removed, clear option does not create a distribution. local and remote option clears old distributions first.

Changed in version 8.2: Build frontend was changed from setuptools to build. -upgrade option also installs packages if necessary.

Changed in version 9.4: The pywikibot-scripts distribution can be created.

class make_dist.SetupBase(local, remote, clear, upgrade)[source]#

Bases: ABC

Setup distribution base class.

Added in version 8.0.

Changed in version 8.1: dataclass is used.

Parameters:
  • local (bool)

  • remote (bool)

  • clear (bool)

  • upgrade (bool)

build()[source]#

Build the packages.

Added in version 9.3.

Return type:

bool

build_opt: str#
abstract cleanup()[source]#

Cleanup copied files.

Return type:

None

clear: bool#
clear_old_dist()[source]#

Delete old dist folders.

Added in version 7.5.

Return type:

None

abstract copy_files()[source]#

Copy files.

Return type:

None

folder: Path#
local: bool#
remote: bool#
run()[source]#

Run the installer script.

Returns:

True if no error occurs, else False

Return type:

bool

upgrade: bool#
class make_dist.SetupPywikibot(*args)[source]#

Bases: SetupBase

Setup for Pywikibot distribution.

Added in version 8.0.

Set source and target directories.

build_opt: str = ''#
cleanup()[source]#

Remove all copied files from pywikibot scripts folder.

Return type:

None

copy_files()[source]#

Copy i18n files to pywikibot.scripts folder.

Pywikibot i18n files are used for some translations. They are copied to the pywikibot scripts folder.

Return type:

None

package = 'pywikibot'#
class make_dist.SetupScripts(local, remote, clear, upgrade)[source]#

Bases: SetupBase

Setup pywikibot-scripts distribution.

Added in version 9.4.

Parameters:
  • local (bool)

  • remote (bool)

  • clear (bool)

  • upgrade (bool)

build_opt: str = '-w'#
cleanup()[source]#

Ignore cleanup yet.

Return type:

None

copy_files()[source]#

Ignore copy files yet.

Return type:

None

package = 'pywikibot_scripts'#
replace = ('MANIFEST.in', 'pyproject.toml', 'setup.py')#
make_dist.handle_args()[source]#

Handle arguments and print documentation if requested.

Returns:

Return whether dist is to be installed locally or to be uploaded

Return type:

tuple[bool, bool, bool, bool]

make_dist.main()[source]#

Script entry point.

Return type:

None

setup script#

Installer script for Pywikibot framework.

How to create a new distribution:

  • replace the developmental version string in pywikibot.__metadata__.py by the corresponding final release

  • create the package with:

    make_dist -remote
    
  • create a new tag with the version number of the final release

  • synchronize the local tags with the remote repositoy

  • merge current master branch to stable branch

  • push new stable branch to Gerrit and merge it the stable repository

  • prepare the next master release by increasing the version number in pywikibot.__metadata__.py and adding developmental identifier

  • upload this patchset to Gerrit and merge it.

Warning

do not upload a development release to pypi.

setup.get_packages(name)[source]#

Find framework packages.

Parameters:

name (str)

Return type:

list[str]

setup.get_validated_version(name)[source]#

Get a validated pywikibot module version string.

The version number from pywikibot.__metadata__.__version__ is used. setup.py with ‘sdist’ option is used to create a new source distribution. In that case the version number is validated: Read tags from git. Verify that the new release is higher than the last repository tag and is not a developmental release.

Returns:

pywikibot module version string

Parameters:

name (str)

Return type:

str

setup.main()[source]#

Setup entry point.

Return type:

None

setup.read_desc(filename)[source]#

Read long description.

Combine included restructured text files which must be done before uploading because the source isn’t available after creating the package.

Return type:

str

setup.read_project()[source]#

Read the project name from toml file.

tomllib was introduced with Python 3.11. To support earlier versions configparser is used. Therefore the tomlfile must be readable as config file until the first comment.

Added in version 9.0.

Return type:

str

entry point#

pwb caller script to invoke the pywikibot.scripts.wrapper script.

Added in version 8.0.

pwb.main()[source]#

Entry point for tests.utils.execute_pwb().

pwb.python_is_supported()[source]#

Check that Python is supported.