Skip to content

Instantly share code, notes, and snippets.

@datavudeja
datavudeja / pycli
Created February 9, 2025 22:09 — forked from energizah/pycli
#!/usr/bin/env python3
import argparse
import functools
import os
import pathlib
import shutil
import subprocess
import sys
import types
@datavudeja
datavudeja / README.markdown
Created February 9, 2025 22:09 — forked from seanh/README.markdown
virtualenv bootstrap script for creating a virtual environment and installing CKAN into it

To create a virtual environment and install CKAN into it:

git clone git://gist.github.com/2206132.git
python 2206132/ckan-bootstrap.py pyenv

This makes a directory pyenv in the current working directory, creates a virtual environment in the pyenv dir, and installs CKAN (and all CKAN's dependencies) into the virtual environment.

Activate the virtual environment and run the CKAN tests:

@datavudeja
datavudeja / update_reqs.py
Created February 9, 2025 22:10 — forked from winhamwr/update_reqs.py
Python script to install some pip-based requirements reliably in a virtualenv
#! /usr/bin/env python
"""
Update a set of virtualenvs based on a given set of pip requirements files
whenever those files change. Keeps track of requirements file changes by md5
hashing the files and storing that hash in the virtualenv. That means that
only updates to the files themselves will trigger updating (changes to a
repository won't be caught).
Optionally also supports uploading/downloading a full bundle of all requirements
to/from Amazon S3 based on the requirements hash in order to ensure that
@datavudeja
datavudeja / python_popen_python.py
Created February 9, 2025 22:11 — forked from sheilatron/python_popen_python.py
Python function to create child Python processes inheriting sys.paths
def spawn_python_script(package_name, script_name, *args):
"""
Run the module ``script_name`` as an external Python script,
using the same Python executable as the current process,
with the same Python paths. This needs to support both
virtualenv and buildout Python executables.
Example:
popen = run_as_script('zetl.scripts','start_conductor.py')
#!/usr/bin/env python3
"""
Author: Teddy Xinyuan Chen
Date: 2020-08-17
"""
from functools import cache
from pathlib import Path
from subprocess import run
import re
@datavudeja
datavudeja / app.py
Created February 9, 2025 22:13 — forked from mpurdon/app.py
Create venv programmatically
import os
import sys
import subprocess
class App:
def __init__(self, virtual_dir):
self.virtual_dir = virtual_dir
self.virtual_python = os.path.join(self.virtual_dir, "Scripts", "python.exe")
@datavudeja
datavudeja / Cargo.toml
Created February 9, 2025 22:14 — forked from ssokolow/Cargo.toml
Simple example of getting the rust-cpython and setuptools-rust examples working together
[package]
name = "unimportant_if_subsumed_by_setuptools"
version = "0.1.0"
authors = ["Your Name Here <[email protected]>"]
[lib]
name = "unimportant_if_subsumed_by_setuptools"
crate-type = ["cdylib"]
[dependencies.cpython]
@datavudeja
datavudeja / clonevirtualenv.py
Created February 9, 2025 22:14 — forked from edwardgeorge/clonevirtualenv.py
A script for cloning a non-relocatable virtualenv.
"""virtualenv cloning script.
A script for cloning a non-relocatable virtualenv.
Virtualenv provides a way to make virtualenv's relocatable which could then be
copied as we wanted. However making a virtualenv relocatable this way breaks
the no-site-packages isolation of the virtualenv as well as other aspects that
come with relative paths and '/usr/bin/env' shebangs that may be undesirable.
Also, the .pth and .egg-link rewriting doesn't seem to work as intended. This
@datavudeja
datavudeja / virtualenv_execute.py
Created February 9, 2025 22:14 — forked from turicas/virtualenv_execute.py
Execute Python code in a virtualenv, return its stdout and stderr
#!/usr/bin/env python
# coding: utf-8
import os
import shlex
from subprocess import Popen, PIPE
def execute_in_virtualenv(virtualenv_name, commands):
'''Execute Python code in a virtualenv, return its stdout and stderr.'''
class Car():
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptive_name(self):