GithubHelp home page GithubHelp logo

jnmclarty / pyenvdiff-lib Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 3.0 247 KB

Python environment comparison tool

Home Page: http://pyenvdiff.com

License: Other

Makefile 0.92% Python 94.42% HTML 4.66%
diagnostics environment management audit virtualenv conda webapp pyenvdiff python devtools

pyenvdiff-lib's Introduction

PyEnvDiff

https://travis-ci.org/jnmclarty/pyenvdiff-lib.svg?branch=master Documentation Status

Python environment comparison tool. Maximized for compatibility between versions 2.6 to 3.8, pypy, operating systems, distributions, and forks! Virtualenv, pyenv, pyvenv, conda and system!

via Command-Line

From the command line, to get information on the current environment:

python -m pyenvdiff.info

Serialize the information to a file...

python -m pyenvdiff.info my_environment.json

Switch to another environment (you'll need pyenvdiff installed in both)

python -m pyenvdiff.compare my_environment.json

Or compare two from any environment

python -m pyenvdiff.compare my_environment.json my_other_environment.json

via Hub-Based Compare

An HTTP-based service comes with pyenvdiff, all without dependencies (thanks to a copy of bottle). It stores environment information in RAM, for as long as it runs. This service should be considered alpha-stage.

To launch the built-in hub (server):

python -m pyenvdiff.hub

Then navigate in your browser to the URL it gives you to see the menu of available options. Before you send information about other environments on the same machine, your options will be limited to just viewing the server's environment.

Samples of the Hub Landing Page and the Environment Information Page illustrate the features.

From one or more other environments run:

python -m pyenvdiff.post_to_hub

A URL will be displayed to view environment information from any machine on the same network.

Navigate back to the base URL, you'll see more options to compare the two environments.

A Sample of the Environment Diff Page illustrate what the diff can do (if `ghdiff` is installed for the hub).

Programmatic Usage

>>> from pyenvdiff import Environment

>>> e = Environment()
>>> e.to_file('my_env.json')

>>> o = Environment.from_file('other_env.json')

>>> e == o
True

>>> print(e)
... # prints a dump of the environment details

>>> from pyenvdiff import EnvironmentDiff
>>> ed = EnvironmentDiff(e, o)
>>> print(ed)
... # prints a diff of the two environments

Sooo much room for activities!

  • Compare dev, test & prod!
  • Works on my machine, strange it doesn't work on yours
  • Confirming deployments
  • Auditing user desktops, servers, research environments & ecosystems
  • Filing (or requesting) bug reports

Installation

There are no mandatory, nor automatically installing, dependencies. There are optional dependencies which increase.

pip install pyenvdiff

OR just copy & paste pyenvdiff anywhere on PYTHONPATH

There is one optional dependency. The core functionality doesn't use it. It's only needed for pretty HTML-based comparisons via the web.

pip install ghdiff

Under the hood

  • Robust and organized object model collects and serializes environment information.
  • Zero dependency, pure-python, harmless install! Simply pip install pyenvdiff or copy anywhere on PYTHONPATH.
  • As-needed import statements, to maximize compatibility across python flavours.
  • Favours compatible python-code over succinct or newer-style python-code
  • Free software: BSD license
  • Documentation: https://pyenvdiff.readthedocs.io.

Credits

This package was started with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

pyenvdiff-lib's People

Contributors

brukhabtu avatar jnmclarty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyenvdiff-lib's Issues

TypeError: string indices must be integers

  • PyEnvDiff version: 0.1.0
  • Python version: 3.6
  • Operating System: Windows

Description

pyenvdiff fails to serialize the environment information to the console.

What I Did

run

python -m pyenvdiff.info

Error

Traceback (most recent call last):
  File "/home/jmclarty/anaconda3/envs/py36/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/jmclarty/anaconda3/envs/py36/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jmclarty/proj/pyenvdiff-lib/pyenvdiff/info.py", line 9, in <module>
    print(env)
  File "/home/jmclarty/proj/pyenvdiff-lib/pyenvdiff/environment.py", line 102, in __str__
    out.append(str(info_set[key]))
  File "/home/jmclarty/proj/pyenvdiff-lib/pyenvdiff/collectors.py", line 162, in __str__
    out = [" ".join([str(i[a]) for a in self.attrs]) for i in self.info]
  File "/home/jmclarty/proj/pyenvdiff-lib/pyenvdiff/collectors.py", line 162, in <listcomp>
    out = [" ".join([str(i[a]) for a in self.attrs]) for i in self.info]
  File "/home/jmclarty/proj/pyenvdiff-lib/pyenvdiff/collectors.py", line 162, in <listcomp>
    out = [" ".join([str(i[a]) for a in self.attrs]) for i in self.info]
TypeError: string indices must be integers

Remove API key necessity from docs.

There is zero pickup of people using the service I run on AWS. I want to remove the API key notes from the docs, and just make it free to use.

Python 3.6 Issues with -m flag

  • PyEnvDiff version: 0.1.0
  • Python version: 3.6.0
  • Operating System: Darwin Rick-Laptop-SOHO-LAN 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

Description

While testing the tool with Python 3.6, I noticed this message popping up, although it seems to work fine after that.

I did some brief search around this last night and it might be related to known issue around the use of -m when executing python modules. Apparently, this was introduced at some point 3.5.x line.

What I Did

(test3.6) Rick-Laptop-SOHO-LAN:test3.6 rfoliva$ python -m pyenvdiff.info test.yaml
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py:125: RuntimeWarning: 'pyenvdiff.info' found in sys.modules after import of package 'pyenvdiff', but prior to execution of 'pyenvdiff.info'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))

How to install a library "as a builtin"?

If a user is okay to install pyenvdiff, since there are no deps, it's all pure python, I am wondering if there are ways to use without needing to import, that work elegantly with all versions of python.

SysPrefix looks strange

  • PyEnvDiff version: pyenvdiff==0.2.0
  • Python version: Python 2.7.15rc1
  • Operating System: Ubuntu 18.04.1 LTS

Description

I executed python -m pyenvdiff.info my_environment.json

the part of SysPrefix looks strange:


SysPrefix
*********
E
r
r
o
r
 
a
t
t
e
m
p
t
i
n
g
 
t
o
 
c
o
l
l
e
c
t
 
(
S
y
s
P
r
e
f
i
x
)
:
 
'
m
o
d
u
l
e
'
 
o
b
j
e
c
t
 
h
a
s
 
n
o
 
a
t
t
r
i
b
u
t
e
 
'
b
a
s
e
_
e
x
e
c
_
p
r
e
f
i
x
'

pyenvdiff's own python version isn't specified.

  • PyEnvDiff version: 0.2.0
  • Python version: All
  • Operating System: All

Description

pyenvdiff's own python version isn't specified.

pyenvdiff        v0.2.0      -> /home/jmclarty/anaconda3/envs/py36/lib/python3.6/site-packages
  py vNone 

Python 3.6 Issues with YAML export

  • PyEnvDiff version: 0.1.0
  • Python version: 3.6.0
  • Operating System: Darwin Rick-Laptop-SOHO-LAN 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

Description

I have been playing with the package since yesterday. A number of times, I have experienced issues when trying to output data to yaml file, failing with error message regarding failure to

I ran into this a number of times yesterday while attempting to output the yaml feature, without success but realized today I was only trying on 3.6. So I tried pip installing it on Python 2.7.13 and it worked like a charm.

So I tried the 3.6 again on a brand new venv and it failed with error message on failing to import yaml. So I pip installed PyYAML and it worked fine. To confirm, I pip uninstalled PyYAML, and it failed again, as per output below.

It seems like some versions of Python 3.6 require PyYAML

What I Did

(test3.6) Rick-Laptop-SOHO-LAN:test3.6 rfoliva$ python -m pyenvdiff.info test.yaml
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py:125: RuntimeWarning: 'pyenvdiff.info' found in sys.modules after import of package 'pyenvdiff', but prior to execution of 'pyenvdiff.info'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))

OSUname
*******
Darwin Rick-Laptop-SOHO-LAN 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

PipDistributions
****************
pyyaml 3.12 3.12 PyYAML None 3.6 /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages
pip 9.0.1 9.0.1 pip None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages
pyenvdiff 0.1.0 0.1.0 pyenvdiff None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages
setuptools 28.8.0 28.8.0 setuptools None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages

PkgutilModules
**************
asyncio
collections
concurrent
ctypes
curses
dbm
distutils
email
encodings
ensurepip
html
http
idlelib
importlib
json
lib2to3
logging
multiprocessing
pip
pkg_resources
pydoc_data
pyenvdiff
setuptools
sqlite3
test
tkinter
turtledemo
unittest
urllib
venv
wsgiref
xml
xmlrpc
yaml

Platform
********
Darwin-16.4.0-x86_64-i386-64bit | i386 | 64bit |

SysApiVersion
*************
1013

SysByteOrder
************
little

SysExecutable
*************
/Users/rfoliva/Dev_Sandbox/test3.6/bin/python

SysFloatInfo
************
1.7976931348623157e+308 1024 308 2.2250738585072014e-308 -1021 -307 15 53 2.220446049250313e-16 2 1

SysPath
*******

/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages

SysPlatform
***********
darwin

SysVersion
**********
3.6.0 (default, Dec 26 2016, 20:33:09)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

SysVersionInfo
**************
3.6.0.final.0

TimeZone
********
18000 | EST | EDT

Stored yaml version of environment information to test.yaml
(test3.6) Rick-Laptop-SOHO-LAN:test3.6 rfoliva$ pip uninstall PyYAML
Uninstalling PyYAML-3.12:
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/PyYAML-3.12-py3.6.egg-info
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/_yaml.cpython-36m-darwin.so
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__init__.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/__init__.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/composer.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/constructor.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/cyaml.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/dumper.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/emitter.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/error.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/events.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/loader.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/nodes.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/parser.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/reader.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/representer.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/resolver.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/scanner.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/serializer.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/__pycache__/tokens.cpython-36.pyc
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/composer.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/constructor.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/cyaml.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/dumper.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/emitter.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/error.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/events.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/loader.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/nodes.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/parser.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/reader.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/representer.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/resolver.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/scanner.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/serializer.py
  /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/yaml/tokens.py
Proceed (y/n)? y
  Successfully uninstalled PyYAML-3.12
(test3.6) Rick-Laptop-SOHO-LAN:test3.6 rfoliva$ python -m pyenvdiff.info test.yaml
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py:125: RuntimeWarning: 'pyenvdiff.info' found in sys.modules after import of package 'pyenvdiff', but prior to execution of 'pyenvdiff.info'; this may result in unpredictable behaviour
  warn(RuntimeWarning(msg))

OSUname
*******
Darwin Rick-Laptop-SOHO-LAN 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

PipDistributions
****************
pip 9.0.1 9.0.1 pip None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages
pyenvdiff 0.1.0 0.1.0 pyenvdiff None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages
setuptools 28.8.0 28.8.0 setuptools None None /Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages

PkgutilModules
**************
asyncio
collections
concurrent
ctypes
curses
dbm
distutils
email
encodings
ensurepip
html
http
idlelib
importlib
json
lib2to3
logging
multiprocessing
pip
pkg_resources
pydoc_data
pyenvdiff
setuptools
sqlite3
test
tkinter
turtledemo
unittest
urllib
venv
wsgiref
xml
xmlrpc

Platform
********
Darwin-16.4.0-x86_64-i386-64bit | i386 | 64bit |

SysApiVersion
*************
1013

SysByteOrder
************
little

SysExecutable
*************
/Users/rfoliva/Dev_Sandbox/test3.6/bin/python

SysFloatInfo
************
1.7976931348623157e+308 1024 308 2.2250738585072014e-308 -1021 -307 15 53 2.220446049250313e-16 2 1

SysPath
*******

/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python36.zip
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages

SysPlatform
***********
darwin

SysVersion
**********
3.6.0 (default, Dec 26 2016, 20:33:09)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]

SysVersionInfo
**************
3.6.0.final.0

TimeZone
********
18000 | EST | EDT
/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/pyenvdiff/import_macros.py:64: UserWarning: Coundn't import yaml.  This flavour of python isn't compatible with pyenvdiff, yet.  Please file an issue at github.com/jnmclarty/pyenvdiff.
  warn("Coundn't import yaml.  " + compatibility + instructions)
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/pyenvdiff/info.py", line 146, in <module>
    env.to_yaml(fname)
  File "/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/pyenvdiff/info.py", line 128, in to_yaml
    self._to_yaml_fs(outfile)
  File "/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/pyenvdiff/info.py", line 105, in _to_yaml_fs
    yaml = import_yaml()
  File "/Users/rfoliva/Dev_Sandbox/test3.6/lib/python3.6/site-packages/pyenvdiff/import_macros.py", line 65, in import_yaml
    return yaml
UnboundLocalError: local variable 'yaml' referenced before assignment
(test3.6) Rick-Laptop-SOHO-LAN:test3.6 rfoliva$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.