• Stars
    star
    224
  • Rank 177,792 (Top 4 %)
  • Language
    Python
  • License
    BSD 2-Clause "Sim...
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert Python packages into a single script

stickytape: Convert Python packages into a single script

Stickytape can be used to convert a Python script and any Python modules it depends on into a single-file Python script. There are likely better alternatives depending on what you're trying to do. For instance:

  • If you want to create a single file that can be executed by a Python interpreter, use zipapp.
  • If you need to create a standalone executable from your Python script, I recommend using an alternative such as PyInstaller.

Since Stickytape relies on correctly analysing both your script and any dependent modules, it may not work correctly in all circumstances. I bodged together the code a long time ago for a specific use case I had, so many normal uses of Python imports are not properly supported.

Installation

pip install stickytape

Usage

You can tell stickytape which directories to search using the --add-python-path argument. For instance:

stickytape scripts/blah --add-python-path . > /tmp/blah-standalone

Or to output directly to a file:

stickytape scripts/blah --add-python-path . --output-file /tmp/blah-standalone

You can also point stickytape towards a Python binary that it should use sys.path from, for instance the Python binary inside a virtualenv:

stickytape scripts/blah --python-binary _virtualenv/bin/python --output-file /tmp/blah-standalone

Stickytape cannot automatically detect dynamic imports, but you can use --add-python-module to explicitly include modules:

stickytape scripts/blah --add-python-module blah.util

By default, stickytape will ignore the shebang in the script and use "#!/usr/bin/env python" in the output file. To copy the shebang from the original script, use --copy-shebang:

stickytape scripts/blah --copy-shebang --output-file /tmp/blah-standalone

As you might expect with a program that munges source files, there are a few caveats:

  • Due to the way that stickytape generates the output file, your script source file should be encoded using UTF-8. If your script doesn't declare its encoding in its first two lines, then it will be UTF-8 by default as of Python 3.
  • Your script shouldn't have any from __future__ imports.
  • Anything that relies on the specific location of files will probably no longer work. In other words, __file__ probably isn't all that useful.
  • Any files that aren't imported won't be included. Static data that might be part of your project, such as other text files or images, won't be included.

More Repositories

1

mammoth.js

Convert Word documents (.docx files) to HTML
JavaScript
4,903
star
2

python-mammoth

Convert Word documents (.docx files) to HTML
Python
785
star
3

jq.py

Python bindings for jq
Python
360
star
4

spur.py

Run commands and manipulate files locally or over SSH using the same interface
Python
266
star
5

java-mammoth

Convert Word documents to simple and clean HTML
Java
248
star
6

python-precisely

Matcher library for Python
Python
237
star
7

dotnet-mammoth

Convert Word documents to simple and clean HTML (C#/.NET)
C#
145
star
8

python-vendorize

Vendorize packages from PyPI
Python
95
star
9

whack

Compile and run relocatable Linux programs
Python
86
star
10

node-graphjoiner

Implementing GraphQL with joins to avoid the N+1 problem
JavaScript
47
star
11

python-graphjoiner

Implementing GraphQL with joins to avoid the N+1 problem
Python
45
star
12

python-makefile

Standard makefile for my Python projects
Makefile
36
star
13

python-graphlayer

Python
26
star
14

node-options

The option type, also known as the maybe type, for JavaScript
JavaScript
23
star
15

locket.py

File-based locks for Python on Linux and Windows
Python
23
star
16

mammoth-wordpress-plugin

WordPress plugin to convert docx files into posts
JavaScript
21
star
17

node-license-sniffer

Detect the license of node.js projects and their dependencies
JavaScript
18
star
18

mintaka

Mintaka: Run long-running processes in parallel, automatically focus on problems
Rust
10
star
19

http-api-proxy

A proxy for APIs to allow rate-limiting and caching
JavaScript
8
star
20

sdmx.py

Read SDMX XML files using Python
Python
7
star
21

lop

Parsing for JavaScript
JavaScript
7
star
22

setup-wabt-action

JavaScript
6
star
23

python-cobble

Create Python data objects
Python
5
star
24

farthing

Python
5
star
25

node-sql-gen

A SQL query builder for node.js, inspired by SQLAlchemy
TypeScript
5
star
26

ttrpg-map-sketcher

TypeScript
4
star
27

java-couscous

Convert Java source code to other languages. C# and Python currently supported.
Java
4
star
28

node-rate-limit

Simple rate limited queues for node.js
JavaScript
4
star
29

peachtree

Python library to interact with qemu/kvm
Python
4
star
30

setup-wasmtime-action

GitHub action for wasmtime
JavaScript
4
star
31

node-dough

Simple dependency injection for node.js
JavaScript
4
star
32

mayo

Download source control URIs in Python
Python
3
star
33

dingbat-to-unicode

Mapping from Dingbat fonts, such as Symbol, Webdings and Wingdings, to Unicode code points
TypeScript
3
star
34

clunk

Java
3
star
35

whack-package-python-virtualenv-env

Create relocatable (aka path-independent) Python virtualenvs using Whack
Shell
2
star
36

chembl-graphql

Python
2
star
37

node-glimpse-connect

Glimpse for Connect on node.js
JavaScript
2
star
38

python-tempman

Create and clean up temporary directories
Python
2
star
39

duck.js

Rich matchers for JavaScript, inspired by Hamcrest
JavaScript
2
star
40

dodge.py

Python
1
star
41

vde

C
1
star
42

web-widgets-knockout

Use generic JavaScript widgets in Knockout, and create generic widgets using Knockout
JavaScript
1
star
43

beach

Python
1
star
44

conan-bdwgc

Conan recipe for Boehm-Demers-Weiser garbage collector
Python
1
star
45

node-fs-in-memory

An in-memory implementation of the fs module in node.js, intended for testing purposes
JavaScript
1
star
46

starboard.py

Utilities to help with networking
Python
1
star
47

patter

Utilities for iterating through arrays using promises
JavaScript
1
star
48

whack-run

C
1
star
49

funk

A mocking framework for Python, influenced by JMock
Python
1
star
50

nope

Python
1
star
51

windows-make-demo

Makefile
1
star