Skip to content

Building a new python spec file virtualenv

Alan Malta Rodrigues edited this page Nov 2, 2018 · 2 revisions

If you need to build a new python package spec file and you need to know exactly what are the package dependencies, you can proceed as follows.

  1. Install the virtualenv package, either via pip or anaconda:
# conda install virtualenv
# pip install virtualenv
  1. Create a virtual environment for your project. It creates a folder in the current directory which will contain the python executable files
# virtualenv test_pyopenssl
  1. Check it got properly created
alannewmacpro:test_pyopenssl amaltaro$ ls
test_pyopenssl
  1. Now you need to enable this virtual environment, such that any package you install using pip will be placed in the test_pyopenssl folder, isolated from the global python installation (note the project name appears in the prompt):
alannewmacpro:test_pyopenssl amaltaro$ source test_pyopenssl/bin/activate
(test_pyopenssl) alannewmacpro:test_pyopenssl amaltaro$ 
  1. Now you install the package you want to check, specifying its version if needed:
# pip install pyOpenSSL==18.0.0
  1. Now that we have pyOpenSSL installed, we can get a snapshot of the environment with (that would have the following output):
# pip freeze
asn1crypto==0.24.0
cffi==1.11.5
cryptography==2.3.1
enum34==1.1.6
idna==2.7
ipaddress==1.0.22
pycparser==2.19
pyOpenSSL==18.0.0
six==1.11.0
  1. If you want to have a nice output and correctly see the tree of dependencies, you need to instal pipdeptree
# pip install pipdeptree
  1. Run it to see a tree of dependencies:
# pipdeptree
pipdeptree==0.13.1
  - pip [required: >=6.0.0, installed: 18.1]
pyOpenSSL==18.0.0
  - cryptography [required: >=2.2.1, installed: 2.3.1]
    - asn1crypto [required: >=0.21.0, installed: 0.24.0]
    - cffi [required: >=1.7,!=1.11.3, installed: 1.11.5]
      - pycparser [required: Any, installed: 2.19]
    - enum34 [required: Any, installed: 1.1.6]
    - idna [required: >=2.1, installed: 2.7]
    - ipaddress [required: Any, installed: 1.0.22]
    - six [required: >=1.4.1, installed: 1.11.0]
  - six [required: >=1.5.2, installed: 1.11.0]
setuptools==40.5.0
wheel==0.32.2

and voila! Now you have the full list of package dependencies and you can write the spec files as you need.

Clone this wiki locally