Skip to main content

A collection of Python snippets for the Kokel Lab

Project description

Tyrannosaurus

Build status Latest version on PyPi Supported Python versions Documentation status Travis License

  1. Generate Python projects set up with modern tools, including Tox, PyPi, and Anaconda.
  2. Update dependencies listed in any format, and find conflicts.

I wrote this after making 18 Git commits trying to configure readthedocs and PyPi. This avoids that struggle for 99% of projects.

Install with pip install tyrannosaurus. Create a project with tyrannosaurus init for a structure like this one, modify it as you see fit, and use tyrannosaurus reqs, tyrannosaurus bump, and/or tyrannosaurus find to manage dependencies. These commands will keep any requirements.txt, setup.py, Pipfile, Poetry dependencies, conda recipes, and Anaconda environment files in sync. And they'll tell you about conflicting, cyclic, and duplicate dependencies.

Non-goal: This little project does not introduce a new abstraction for dependency management. It only makes it easier to start new projects and sync or migrate between formats. Anaconda, conda-forge, pipenv, and poetry are great places to look.

⚠ Not finished yet! The scripts are scattered everywhere. This should be ready in late April.

creating a new project

tyrannosaurus init mynewproject

Your new project is ready for PyPi, Sphinx, Sphinx API docs, readthedocs, Git, Tox, Travis, CircleCI, and conda-forge. The Tox config will generate PyPi-ready source and wheel builds, and even a conda package for you! Your project's version is specified only once, in yourpackage/__init__.py.

You can modify your project freely after, and tyrannosaurus will still understand it. Of course, init also has some command-line options. Run tyrannosaurus init --help to see them. You can choose another license with tyrannosaurus init mynewproject --license "MIT".

managing dependencies

Tyrannosaurus's best feature is managing and translating dependencies. It keeps your dependencies consistent between requirements.txt, conda recipes, Anaconda environment files, Pipfiles (pipenv), and setup.py files. If there is a merge conflict, it will keep the highest version. Just run:

tyrannosaurus reqs

No pun intended, of course.

You can also update the versions to the most recent available on PyPi and your Anaconda channels: It will report inconsistencies between Anaconda channel versions and versions on PyPi.

tyrannosaurus bump

Finally, you can use pipreqs to find dependencies from your imports:

tyrannosaurus find

All of these commands will tell you about dependency conflicts. Note that pip does not know about dependency trees, which can be a serious problem. If you only want this, call tyrannosaurus check.

optional dependencies

By the way, you can distinguish between requirements and optional dependencies in all of these types. For example, your requirements.txt might look like this:

click                  >=7.1,<8.0
hypothesis[test]       >=5.8,<6.0
pytest[test]           >=5.4,<6.0

In setup.py, these are listed in extras_require. Unfortunately, environment.yml files don't support optional dependencies. We get around this using comments starting with # @. See the docs for more info.

configuring

Occasionally you may need to modify tyrannosaurus's behavior. For example, you may want it to leave your requirements.txt untouched or modify a file called all-requirements.txt. Or, maybe you want to change the way it chooses version ranges. To do this, add a .tyrannosaurus file in your root. More information is in the docs.

compatibility and problems

Tyrannosaurus is your average mesozoic-era dinosaur, compatible with Python 3.4+. However, you can modify any project it generates as you see fit.

It's not very intelligent, so it will back up your files first. For example, it will make a .requirements.txt.bak-2020-04-05T152203.1151492. You can tell it to clean up older versions with the global --clean flag.

Please note that lock files for pipenv and poetry are not affected by design.

building, extending, and contributing

New issues and pull requests are welcome.

Tyrannosaurus is bootstrapped—built using itself. If you fork it, you can modify its files and install your fork to modify its default project structure.

To modify the default README.md, modifying this one won't work. The same is true for some other files that are also used to describe tyrannosaurus itself. Files under docs/ and tyrannosaurus/ are not included in new projects. To work around this, you can add or modify files under tyrannosaurus/resources/auto/. These files will be copied to new projects. In text files, ${{project}} will be replaced with the project name.

meta info

Tyrannosaurus was developed by Douglas Myers-Turnbull and is licensed under the Apache License, version 2.0.

Related projects, some of which tyrannosaurus uses:

                                              .++++++++++++.  
                                           .++HHHHHHH^^HHH+.
                                          .HHHHHHHHHH++-+-++.
                                         .HHHHHHHHHHH:t~~~~~
                                        .+HHHHHHHHHHjjjjjjjj. 
                                       .+NNNNNNNNN/++/:--.. 
                              ........+NNNNNNNNNN.            
                          .++++BBBBBBBBBBBBBBB.             
 .tttttttt:..           .++BBBBBBBBBBBBBBBBBBB.             
+tt+.      ``         .+BBBBBBBBBBBBBBBBBBBBB+++cccc.        
ttt.               .-++BBBBBBBBBBBBBBBBBBBBBB++.ccc.    
+ttt++++:::::++++++BBBBBBBBBBBBBBBBBBBBBBB+..++.            
.+TTTTTTTTTTTTTBBBBBBBBBBBBBBBBBBBBBBBBB+.    .ccc.          
  .++TTTTTTTTTTBBBBBBBBBBBBBBBBBBBBBBBB+.      .cc.          
    ..:++++++++++++++++++BBBBBB++++BBBB.                     
           .......      -LLLLL+. -LLLLL.                     
                        -LLLL+.   -LLLL+.                    
                        +LLL+       +LLL+                       
                        +LL+         +ff+                       
                        +ff++         +++:                 
                        ++++:                              

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tyrannosaurus-0.0.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tyrannosaurus-0.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file tyrannosaurus-0.0.1.tar.gz.

File metadata

  • Download URL: tyrannosaurus-0.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tyrannosaurus-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a17b97c67af196297a08830baf5de97e112cd9eaa8455e4a9ad8f80003f042dd
MD5 b30abc8796060dea379005a58a19904c
BLAKE2b-256 b831d9c5e379ad8bee3bdfcf5a3c8a02ec491a7113e941ea10c16de1c4864a16

See more details on using hashes here.

File details

Details for the file tyrannosaurus-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tyrannosaurus-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tyrannosaurus-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7511033fc023f19ac9f9b9d6ee65565695f7973536b3928097ded9467f367ced
MD5 49ea1b54e9abcae7cfb3322752be9387
BLAKE2b-256 9698609abec9711c674caf123d94372f378aa97ba612f4c63a784f4b9c7057a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page