Repository: ansible/ansible

Issue:
pycrypto not listed in the Python package requirements list
<!---
Please do not report issues/requests related to Ansible modules here !!

Report them to the appropriate modules-core or modules-extras project:
  - https://github.com/ansible/ansible-modules-core/issues
  - https://github.com/ansible/ansible-modules-extras/issues

Also verify first that your issue/request is not already reported in GitHub
-->


##### ISSUE TYPE
 - Documentation Report

##### COMPONENT NAME
Running From Source

##### ANSIBLE VERSION

```
ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
```

##### CONFIGURATION


##### OS / ENVIRONMENT
N/A

##### SUMMARY
`pycrypto` not listed in the Python package requirements list

##### STEPS TO REPRODUCE

1. Read https://docs.ansible.com/ansible/intro_installation.html#running-from-source
2. Install the Python dependencies:
    ```
    $ sudo pip install paramiko PyYAML Jinja2 httplib2 six
    ```
3. Run the last confirmation step:
    ```
    $ ansible all -m ping --ask-pass
    ```

##### EXPECTED RESULTS
```
127.0.0.1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
```

##### ACTUAL RESULTS
```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: DistributionNotFound: The 'pycrypto>=2.6' distribution was not found and is required by ansible
127.0.0.1 | FAILED! => {
    "failed": true,
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
```



Discussion:
I agree that we should make the install doc match the contents of setup.py ...

```
install_requires=['paramiko', 'jinja2', "PyYAML", 'setuptools', 'pycrypto >= 2.6'],
```

Maybe we could move the requirements to install into a requirements.txt file that is referenced by setup.py as well as the instructions specifying to utilize the requirements.txt instead of listing the packages separately in 2 locations?

Just a thought, as I've seen this done elsewhere.

@jctanner and @sivel I was looking at resolving this documentation concern. Were you thinking about including a requirements.txt in the root of the project then reading this file in during setup? Would you just update the docsite to point users to the requirement.txt or can the information in requirement.txt be dynamically loaded into the docsite? This would create a dependency for setup to always have the requirement.txt file. I did find some information within the development community advising against the approach of making install_requires dependent upon an external file. Sounds like a number of IDE's could have issues resolving the dependencies.
@BondAnthony i'm not sure. It might be something to discuss at the next core team meeting.
Please note pycrypto is waaay out of date, nearing 3 years since last release at this point. pycryptodome would be a better requirement; it's a drop-in, and its latest release was 6 days ago- it is actively developed.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -11,6 +11,13 @@
             " install setuptools).")
     sys.exit(1)
 
+with open('requirements.txt') as requirements_file:
+    install_requirements = requirements_file.read().splitlines()
+    if not install_requirements:
+        print("Unable to read requirements from the requirements.txt file"
+                "That indicates this copy of the source code is incomplete.")
+        sys.exit(2)
+
 setup(
     name='ansible',
     version=__version__,
@@ -21,7 +28,7 @@
     license='GPLv3',
     # Ansible will also make use of a system copy of python-six and
     # python-selectors2 if installed but use a Bundled copy if it's not.
-    install_requires=['paramiko', 'jinja2', "PyYAML", 'setuptools', 'pycrypto >= 2.6'],
+    install_requires=install_requirements,
     package_dir={ '': 'lib' },
     packages=find_packages('lib'),
     package_data={


Test patch:
diff --git a/test/compile/python2.4-skip.txt b/test/compile/python2.4-skip.txt
--- a/test/compile/python2.4-skip.txt
+++ b/test/compile/python2.4-skip.txt
@@ -53,4 +53,5 @@
 /lib/ansible/template/
 /lib/ansible/utils/
 /lib/ansible/vars/
+/setup.py
 /test/