Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console script for run_cddd.py #1

Merged
merged 4 commits into from
Nov 28, 2018

Conversation

cthoyt
Copy link
Contributor

@cthoyt cthoyt commented Nov 27, 2018

This PR gives setuptools extra information so it knows how to turn cddd/run_cddd.py into a command line script that can be run from any working directory without explicitly writing the path to the python script using the entry_points option and the magical console_scripts key.

The entry in the list 'cddd = cddd.run_cddd:main_wrapper' means that a script called cddd will be installed and it will run the function found in the cddd.run_cddd called main_wrapper as the __main__. Since the code that did the work was already living inside the if __name__ == '__main__': construct, I excised it and put it inside a new function called main_wrapper and called that from if __name__ == '__main__': . This way, everything will continue to work as before, as well.

Finally, I updated the readme to reflect this change (and also added a bit of code highlighting, while I was editing it)

This means that the script `$ python run_cddd.py` can be called from anywhere using just `$ cddd` regardless of where you are after the module has been pip installed. 

Note: will require one more commit to put all of the main functionality in one function though! I'm editing from the GitHub web interface so I can only do one file at a time :)
- changed usage of `python run_cddd.py` to use entry point
- Added code highlighting
```
run_cddd.py --input smiles.smi --output descriptors.csv --smiles_header smiles
```bash
cddd --input smiles.smi --output descriptors.csv --smiles_header smiles
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the new way for calling the python script. It now works sort of like any other command in the console.

@jrwnter
Copy link
Owner

jrwnter commented Nov 28, 2018

Looks good. I will merge. Thanks!

@jrwnter jrwnter merged commit ecc3230 into jrwnter:master Nov 28, 2018
@cthoyt cthoyt deleted the patch-1 branch November 28, 2018 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants