venv-python


Namevenv-python JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/talwrii/venv_python
SummaryCreate a specially named python and pip for use with scripts
upload_time2025-02-16 16:59:06
maintainerNone
docs_urlNone
authorreadwithai
requires_pythonNone
licenseMIT
keywords scripts virtualenv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Venv python

Venv python is a small utility to create python and pip executable along with a virtualenv they used. This is meant to to be used with command line scripts.

# Motivation
Creating command-line tools is a fairly common act when programming or doing sys admin. In Python, the "accepted" way of doing this is to create a Python project with setuptools and add entrypoints which create executables that can be used from the command line and then install it with [pipx](https://github.com/pypa/pipx). However, this can be a hassle for small or numerous scripts. An alternative way of doing things, is to have Python scripts on your $PATH variables, with one big shared Python environment.

This all worked pretty well until new versions of Ubuntu started [preventing you from installing Python packages](https://www.reddit.com/r/learnpython/comments/1338la7/you_cant_use_pip_on_ubuntu_2304_anymore/) with pip. The approaches of having "one big shared virtualenv" used by the system and user tools was probably a bad one - but it often worked quite well.

I'm not going to give up using scripts on the my path, so I need a work around. One approach would to be to have my own version of Python that I use with all scripts. However, this felt a bit too wrong. So instead I have a shared version of Python used by each directory on my path.

This utility is defined to used to create these separate Python's.

# Installation

Use pipx to install venv-python (in it's own virtualenv)

```
pipx install venv-python
```

# Usage
If you have a directory on your path which contains python scripts. You can add a Python to it by cd'ing to it and running

```
venv-python $PREFIX
```

This will then create python called $PREFIX-python and a pip called $PREFIX-pip.

Then in your python scripts set the hashbang to:

```
#!/usr/bin/env $PREFIX-python

```

To install the dependencies of these scripts you can use $PREFIX-pip

# Alternatives and prior works
This is obviously just glue code about python virtualenvs. Pipx maintains a virtualenv for a project. You could instead use a single shared Python for all your scripts.

# About me
I am [@readwithai](http://x.com/readwithai). I write and make tools to do with [reading](https://readwithai.substack.com/p/what-is-reading-broadly-defined), productivity often using [Obsidian](https://readwithai.substack.com/p/what-exactly-is-obsidian)

If you are interested in this tool your might also be interested in:

1. This blog post about [sending code to a virtualenv](https://readwithai.substack.com/p/sending-code-to-a-python-virtualenv) from within Emacs using Ipython; or
2. This command-line tool to use [numpy from the shell](https://github.com/talwrii/npcli/blob/master/README.md)
3. This library that customizes pdb to be [more useable by adding custom commands](https://github.com/talwrii/tomspdb).

You can follow me on [X](https://x.com/readwithai) or my [blog](https://readwithai.substack.com)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/talwrii/venv_python",
    "name": "venv-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "scripts, virtualenv",
    "author": "readwithai",
    "author_email": "talwrii@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bd/ac/b176dc58a42ca80e8d81c5e5ff7c170d4e8a13a066f81a6d022384d9d006/venv-python-1.0.2.tar.gz",
    "platform": null,
    "description": "# Venv python\n\nVenv python is a small utility to create python and pip executable along with a virtualenv they used. This is meant to to be used with command line scripts.\n\n# Motivation\nCreating command-line tools is a fairly common act when programming or doing sys admin. In Python, the \"accepted\" way of doing this is to create a Python project with setuptools and add entrypoints which create executables that can be used from the command line and then install it with [pipx](https://github.com/pypa/pipx). However, this can be a hassle for small or numerous scripts. An alternative way of doing things, is to have Python scripts on your $PATH variables, with one big shared Python environment.\n\nThis all worked pretty well until new versions of Ubuntu started [preventing you from installing Python packages](https://www.reddit.com/r/learnpython/comments/1338la7/you_cant_use_pip_on_ubuntu_2304_anymore/) with pip. The approaches of having \"one big shared virtualenv\" used by the system and user tools was probably a bad one - but it often worked quite well.\n\nI'm not going to give up using scripts on the my path, so I need a work around. One approach would to be to have my own version of Python that I use with all scripts. However, this felt a bit too wrong. So instead I have a shared version of Python used by each directory on my path.\n\nThis utility is defined to used to create these separate Python's.\n\n# Installation\n\nUse pipx to install venv-python (in it's own virtualenv)\n\n```\npipx install venv-python\n```\n\n# Usage\nIf you have a directory on your path which contains python scripts. You can add a Python to it by cd'ing to it and running\n\n```\nvenv-python $PREFIX\n```\n\nThis will then create python called $PREFIX-python and a pip called $PREFIX-pip.\n\nThen in your python scripts set the hashbang to:\n\n```\n#!/usr/bin/env $PREFIX-python\n\n```\n\nTo install the dependencies of these scripts you can use $PREFIX-pip\n\n# Alternatives and prior works\nThis is obviously just glue code about python virtualenvs. Pipx maintains a virtualenv for a project. You could instead use a single shared Python for all your scripts.\n\n# About me\nI am [@readwithai](http://x.com/readwithai). I write and make tools to do with [reading](https://readwithai.substack.com/p/what-is-reading-broadly-defined), productivity often using [Obsidian](https://readwithai.substack.com/p/what-exactly-is-obsidian)\n\nIf you are interested in this tool your might also be interested in:\n\n1. This blog post about [sending code to a virtualenv](https://readwithai.substack.com/p/sending-code-to-a-python-virtualenv) from within Emacs using Ipython; or\n2. This command-line tool to use [numpy from the shell](https://github.com/talwrii/npcli/blob/master/README.md)\n3. This library that customizes pdb to be [more useable by adding custom commands](https://github.com/talwrii/tomspdb).\n\nYou can follow me on [X](https://x.com/readwithai) or my [blog](https://readwithai.substack.com)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create a specially named python and pip for use with scripts",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/talwrii/venv_python"
    },
    "split_keywords": [
        "scripts",
        " virtualenv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdacb176dc58a42ca80e8d81c5e5ff7c170d4e8a13a066f81a6d022384d9d006",
                "md5": "ae3a7b7dcd6038a22142976c24c7eef0",
                "sha256": "ae5f043321cc0e6a0b9f60cf8db67add9f80fb64ec05eea82546034301a8483c"
            },
            "downloads": -1,
            "filename": "venv-python-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ae3a7b7dcd6038a22142976c24c7eef0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3953,
            "upload_time": "2025-02-16T16:59:06",
            "upload_time_iso_8601": "2025-02-16T16:59:06.399857Z",
            "url": "https://files.pythonhosted.org/packages/bd/ac/b176dc58a42ca80e8d81c5e5ff7c170d4e8a13a066f81a6d022384d9d006/venv-python-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-16 16:59:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "talwrii",
    "github_project": "venv_python",
    "github_not_found": true,
    "lcname": "venv-python"
}
        
Elapsed time: 0.58770s