Skip to main content

Create python sdists from tags

Project description

Tags2sdists creates python sdists from tags into a structure that can serve as a company-internal pypi (python package index).

Basic operation

Tags2sdists looks at two directories:

  • A source directory (“CHECKOUTDIR”) with checkouts. Every checkout (svn trunk checkout, git/hg clone) is examined for tags according to that version control system.

  • A target directory (“SDISTDIR”) where per-package directories are made with sdists named like PACKAGENAME-1.2.tar.gz in it.

Those two directories are kept in sync by checking for packages/tags that are available in the version control system but that are missing in the target directory. If missing, an “sdist” (.tar.gz source distribution) is generated and placed in the target directory.

Usage

Tags2sdists provides the tags2sdists command:

Usage: tags2sdists CHECKOUTDIR SDISTDIR
    CHECKOUTDIR: directory with checkouts
    SDISTDIR: directory with sdist package directories

Options:
  -h, --help            show this help message and exit
  -v, --verbose         Show debug output
  -q, --quiet           Show minimal output
  -a, --build-all       Build all releases (=don't stop if the newest tag is
                        found)
  -p, --allow-prereleases
                        Allow prereleases (=tags like 0.1b1 or 2.0a3)

With --build-all, all the tags are build. The default behaviour helps with mis-behaving old tags, but if all the packages are clean, --build-all is a good choice as also bugfix releases for older versions are build.

And --allow-prereleases builds alpha/beta/rc packages instead of skipping them.

Setup

Installing tags2sdists itself is as simple as pip install tags2sdists.

Next you need the CHECKOUTDIR and SDISTDIR directories.

CHECKOUTDIR: you need a directory with checkouts. So doing it by hand is fine, but checkoutmanager is the thing I’d use. Make a config file (checkoutmanager.cfg) looking like this:

[internalprojects]
vcs = git
basedir = /srv/packages/var/checkouts/
checkouts =
    git@github.com:lizardsystem/nensskel.git
    git@github.com:lizardsystem/lizard-ui.git
    git@github.com:lizardsystem/tags2sdists.git

And set up a cron job that runs checkoutmanager --configfile=YOURCONFIGFILE, it’ll update the checkouts in the base dir you configured. (In that same cronjob, fire up tags2sdists afterwards).

SDISTDIR: just a directory somewhere will do. You’ll get a pypi-like directory structure in there.

A structure like generated with tags2sdists is a perfect index for easy_install and buildout if you let apache host it. Only problem: you can only have one index (note: pip apparently supports multiple indexes). You can solve this problem by having apache redirect you to pypi when something is not found.

Here’s an example apache config snippet:

# Allow indexing
Options +Indexes
IndexOptions FancyIndexing VersionSort

# Start of rewriterules to use our own var/private/* packages
# when available and to redirect to pypi if not.
RewriteEngine On
# Use our robots.txt:
RewriteRule ^/robots.txt - [L]
# Use our apache's icons:
RewriteRule ^/icons/.* - [L]
# We want OUR index.  Specified in a weird way as apache
# searches in a weird way for index.htm index.html index.php etc.
RewriteRule ^/index\..* - [L]

# Use our var/private/PROJECTNAME if available,
# redirect to pypi otherwise:
RewriteCond /path/on/server/var/private/$1 !-f
RewriteCond /path/on/server/var/private/$1 !-d
RewriteRule ^/([^/]+)/?$ http://pypi.python.org/pypi/$1/ [P,L]

# Use our var/private/PROJECTNAME/project-0.1.tar.gz if available,
# redirect to pypi otherwise:
RewriteCond /path/on/server/var/private/$1 !-d
RewriteRule ^/([^/]+)/([^/]+)$ http://pypi.python.org/pypi/$1/$2 [P,L]

Using the apache-served index

You can use such a custom apache-served index in two ways. Pip has a -i option for passing along an index:

$ pip install -i http://packages.my.server/ zest.releaser

In buildout, you can set it like this:

[buildout]
index = http://packages.my.server/
parts =
    ...

Development

For local testing, install it with uv:

$ uv sync
$ uv run pytest
$ pre-commit run --all

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tags2sdists-2.6.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tags2sdists-2.6.0-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file tags2sdists-2.6.0.tar.gz.

File metadata

  • Download URL: tags2sdists-2.6.0.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tags2sdists-2.6.0.tar.gz
Algorithm Hash digest
SHA256 b685248a432c31c5c782d3dce92a499f39ec0561bac801bee5fbee55702a5466
MD5 e02863140d4c6543af16d2e91adc4985
BLAKE2b-256 f4952154fecee95c66095b33105a0d7f1b9abc759ad5fe54e6596404ef32b52c

See more details on using hashes here.

File details

Details for the file tags2sdists-2.6.0-py3-none-any.whl.

File metadata

  • Download URL: tags2sdists-2.6.0-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for tags2sdists-2.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4086c4ba543b0af13da6eaa07560855a8d17e5fdcdffafaea6e766f33da7fa93
MD5 5ad7bcb8eda5e6ff6e7dfa849b5890b3
BLAKE2b-256 f8c065df4f3c1b599ba0d401a1fddb431af86105fbf01a12c35ec5d42ae8d59c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page