Questions tagged [python-pex]

python-pex refers to the pex tool and the .pex files it creates. PEX is a set of packaging and distributions libraries formerly available though twitter commons and its most notable component is the .pex file format. .pex files are effectively self-contained executable Python virtual environments.

pex is a set of packaging and distributions libraries split out of twitter commons. pex most notable components are .pex (Python EXecutable) format and the pex tool used to build .pex files.

.pex files allows the distribution of a python program and all its dependencies as a single, self-contained and executable file. Deploying a .pex file can be done with a single scp, while still keeping all the benefits of a virtualenv.

Under the hood, .pex files are specially crafted zip files with #!/usr/bin/env python shebang and a special __main__.py. More details about the inner workings of pex can be found at the docs.

14 questions
11
votes
1 answer

Creating a PEX of a small flask website

I am attempting to create a PEX file of a simple 3 page flask website. The website works with Gunicorn on python3, the client wants the site compiled to a encapsulated pex file. pex -r zb1/requirements.txt -e zb1/run -o zb1.pex also tried pex -r…
user6759394
8
votes
3 answers

Packaging local module with pex

I'm trying to package my local module with pex and I can't seem to manage to. I've created a simple project: → python --version Python 2.7.10 → pex --version pex 1.1.15 → tree . . ├── bla │   ├── __init__.py │   └── main.py └──…
charly
  • 956
  • 13
  • 23
4
votes
0 answers

Importing from python PEX files

Python PEX files (https://pex.readthedocs.io/en/latest/) allow one to bundle an application with all its dependencies into a single executable. It is also possible to bundle up the dependencies into a python interpreter. I would like, however, to…
Sergey Orshanskiy
  • 6,794
  • 1
  • 46
  • 50
3
votes
1 answer

How to build pex or shiv package from pyproject-compliant project?

I have a Python project which I would like to distribute as a Pex or shiv self-contained Python-executable package, in the spirit of the Python Packaging Guide, "Depending on a pre-installed Python" section. My project is structured in the spirit of…
Jim DeLaHunt
  • 10,960
  • 3
  • 45
  • 74
3
votes
1 answer

Can't Display Version of a Python Binary PEX with Click Entry Points

Python Click CLI Application When you use a Click library to build a Python CLI Application you can do this: @click.version_option() def cli(): ''' Main Entry Point to Click Interface ''' to be able to do this: [user@host]$ clickapp…
3
votes
2 answers

pip install errors out: SyntaxError: invalid syntax

pip install does not work when trying to install virtualenv, requests or pex on CentOS6. I am on python2.6 and pip 9.0.1. Can anyone tell me why is this happening? (pex_build)[root@pex pex_build]# pip install virtualenv Output: Traceback (most…
Anjana Shivangi
  • 397
  • 2
  • 5
  • 19
2
votes
1 answer

Use pex with poetry pyproject.toml

I'm trying to figure out how to do automated(ish) deployment for a python project with pex. I currently have the following process: $ poetry run pip freeze > requirements.txt manually remove this-project line from requirements.txt $ poetry run pex…
Trashtalk
  • 331
  • 1
  • 11
2
votes
3 answers

Packaging PySpark with PEX environment on dataproc

I'm trying to package a pyspark job with PEX to be run on google cloud dataproc, but I'm getting a Permission Denied error. I've packaged my third party and local dependencies into env.pex and an entrypoint that uses those dependencies into main.py.…
1
vote
1 answer

SpaCy Pex can't find model?

I'm trying to bundle SpaCy into a pex file as detailed in their docs here. I have successfully built the pex file, and am now trying to run a simple python script that runs SpaCy against a passed in text file. I import SpaCy and try to load the…
Cagrosso
  • 195
  • 1
  • 12
1
vote
0 answers

How to add properties file inside a pex package?

I have this project: project_folder/ main.py setup.py requirements.text properties.ini I build my pex file with this command: pex . -r requirements.txt -c main.py -o mypex.pex Q: How do I add properties.ini into my final pex…
payloc91
  • 3,724
  • 1
  • 17
  • 45
1
vote
1 answer

Importing json resources inside .pex (Python Executable (format by Twitter))

I'm using a Twitter engineered build tool pants to manage many projects inside my monorepo. It outputs .pex files when I complete a build, this is a binary that packages the bare minimum dependencies I need for each project and makes them a "binary"…
Gdfelt
  • 161
  • 15
0
votes
1 answer

Is there a way to include extra files when building a PEX (i.e. with MANIFEST.in)?

I have a directory structure similar to the following: ├── myproj │ ├── utils.py │ ├── __init__.py │ ├── routes │ │ ├── __init__.py │ │ ├── auth.py │ │ └── stuff.py ├── html │ ├── index.html │ └── about.html ├── MANIFEST.in ├──…
Gary Howe
  • 103
  • 2
  • 6
0
votes
2 answers

How to resolve Python Pex binary file location

Using the pex tool to package python proyects (https://pex.readthedocs.io/en/v2.1.55/); is there a way to know where the original Pex file is located?. Until now I just have been able to see where the "unzipped" files are located but need to…
Alexis
  • 23
  • 1
  • 4
0
votes
1 answer

Is it possible to create a pex with a JAR included as dependency?

I'm not much of a Python dev, so I'm sorry if there is not much sense in this question.. I'm currently working in a project that contains a py script that communicates with a server written in Java. A considerable part of the script is dedicated to…
Humble Student
  • 3,755
  • 4
  • 20
  • 35