-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f8ff75
commit 767d6b3
Showing
9 changed files
with
197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.pyc | ||
*.egg-info | ||
*.tar.gz | ||
*.coverage | ||
.output | ||
/dist | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,37 @@ | ||
# tempypy | ||
Quick and Easy Temporary python virtual environments | ||
tempyenv | ||
===================== | ||
|
||
Description | ||
=========== | ||
|
||
tempyenv sets up a python environment in a temporary path. Quick way to create a throw away python environment. | ||
|
||
[![Build Status](https://app.travis-ci.com/outbit/tempyenv.svg?branch=develop "ansible-docs latest build")](http://travis-ci.org/outbit/tempyenv) | ||
[![PIP Version](https://img.shields.io/pypi/v/tempyenv.svg "tempyenv PyPI version")](https://pypi.python.org/pypi/tempyenv) | ||
[![Coverage Status](https://coveralls.io/repos/outbit/tempyenv/badge.svg?branch=develop&service=github)](https://coveralls.io/github/outbit/tempyenv?branch=develop) | ||
[![Gitter IM](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/outbit/tempyenv) | ||
|
||
|
||
Installation | ||
=========== | ||
|
||
```shell | ||
$ python -m pip install tempyenv | ||
``` | ||
|
||
Usage | ||
=========== | ||
|
||
```shell | ||
$ tempyenv | ||
``` | ||
|
||
License | ||
======= | ||
|
||
tempyenv is released under the [MIT License](LICENSE.md). | ||
|
||
Author | ||
====== | ||
|
||
David Whiteside (<david@davidwhiteside.com>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Build new release | ||
=== | ||
|
||
```bash | ||
git checkout master | ||
git merge develop --no-ff | ||
git push | ||
git tag vX.Y.Z | ||
git push origin vX.Y.Z | ||
``` | ||
|
||
- Publish a release on github.com | ||
|
||
Follow instructions to build and publish to pypi | ||
=== | ||
|
||
```bash | ||
# Setup your ~/.pypirc | ||
[distutils] | ||
index-servers = | ||
tempyenv | ||
tempyenv-test | ||
|
||
[tempyenv] | ||
repository = https://upload.pypi.org/legacy/ | ||
username = xyz | ||
password = xyz | ||
|
||
[tempyenv-test] | ||
repository = https://test.pypi.org/legacy/ | ||
username = xyz | ||
password = xyz | ||
|
||
# Build | ||
python setup.py bdist_wheel --universal | ||
|
||
# Upload | ||
rm -f dist/* | ||
twine upload --repository-url https://upload.pypi.org/legacy/ dist/tempyenv-* | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__version__ = '1.0.0' | ||
__author__ = 'David Whiteside' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import tempfile | ||
import subprocess | ||
import os | ||
import sys | ||
|
||
class TemporaryVenvCreator: | ||
def __init__(self): | ||
self.temp_dir = None | ||
self.venv_path = None | ||
|
||
def create_temporary_directory(self): | ||
self.temp_dir = tempfile.TemporaryDirectory(delete=False) | ||
self.venv_path = os.path.join(self.temp_dir.name, 'venv') | ||
|
||
def create_virtual_environment(self): | ||
try: | ||
subprocess.run(['python3', '-m', 'venv', self.venv_path], check=True) | ||
print(f"Virtual environment created at {self.venv_path}") | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error creating virtual environment: {e}") | ||
|
||
def load_virtual_environment(self): | ||
try: | ||
print(f"Virtual environment loading from {self.venv_path}") | ||
#current_shell = os.environ.get("SHELL") # Currently just support bash | ||
current_shell = "bash" | ||
subprocess.run([f"{current_shell}", | ||
"-c", | ||
f"source {self.venv_path}/bin/activate && export PS1=\"(tempyenv)$PS1\\$ \" && {current_shell}"], | ||
stdin=sys.stdin, | ||
stdout=sys.stdout, | ||
stderr=sys.stderr) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error loading virtual environment: {e}") | ||
|
||
if __name__ == "__main__": | ||
venv_creator = TemporaryVenvCreator() | ||
venv_creator.create_temporary_directory() | ||
venv_creator.create_virtual_environment() | ||
venv_creator.load_virtual_environment() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export PYTHONPATH="${PYTHONPATH}:./lib" | ||
coverage run --source=ansibledocgen -m unittest discover test/units/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('lib')) | ||
from tempyenv import __version__, __author__ | ||
|
||
from pathlib import Path | ||
this_directory = Path(__file__).parent | ||
long_description = (this_directory / "README.md").read_text() | ||
|
||
try: | ||
from setuptools import setup, find_packages | ||
except ImportError: | ||
print("tempyenv needs setuptools in order to build. Install it using" | ||
" your package manager (usually python-setuptools) or via pip (pip" | ||
" install setuptools).") | ||
sys.exit(1) | ||
|
||
setup( | ||
name='tempyenv', | ||
version=__version__, | ||
description='Easiest and quickest way to setup a temporary python virtual environment', | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
author=__author__, | ||
author_email='david@davidwhiteside.com', | ||
url='https://github.com/outbit/tempyenv', | ||
license='MIT', | ||
install_requires=[ | ||
'setuptools'], | ||
include_package_data=True, | ||
package_dir={ | ||
'': 'lib'}, | ||
package_data = { '': ['*.j2']}, | ||
packages=find_packages('lib'), | ||
classifiers=[ | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'Intended Audience :: Information Technology', | ||
'Intended Audience :: System Administrators', | ||
'License :: OSI Approved :: MIT License', | ||
'Natural Language :: English', | ||
'Operating System :: POSIX', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
'Programming Language :: Python :: 3.12', | ||
'Programming Language :: Python :: 3 :: Only', | ||
'Topic :: System :: Installation/Setup', | ||
'Topic :: System :: Systems Administration', | ||
'Topic :: Utilities', | ||
], | ||
python_requires='>=3.7', | ||
entry_points={ | ||
'console_scripts': [ | ||
'tempyenv = tempyenv.cli:main' | ||
] | ||
}, | ||
data_files=[], | ||
) |
Empty file.