question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrating module dependencies to proper PIP packages

See original GitHub issue

Just figured I should document this… At first, I tried to keep data access layers as minimal as possible (i.e. ideally in a single file), but it really seems to make more trouble than convenience:

  • somewhat annoying to keep track of that in the config
  • dependencies need to be installed separately via requirements.txt
  • non-transparent to static analysis, and to check it with mypy, still need a proper environment

With proper setup.py

  • one can simply git pip install <github repo url>, without cloning anything in a temporary location
  • you can use virtualenv, if you prefer, to avoid mixing HPI dependencies and rest of the packages
  • with --editable install, you can develop as if it was a symlink
  • and you still can manually symlink code if you prefer for some reason

Basically, the only downside is maintaining setup.py. I keep it very minimal, merely with the package name, py.typed file for MyPy and the dependencies, since I’m not planning to upload to PIP (and no one really looks at the classifiers/reads documentation on PyPi anyway).

UPD: also it seems that for proper mypy integration it’s necessary to have __init__.py (see my comment here https://github.com/karlicoss/endoexport/blob/be5084aa45aaac206ff86624244f40c08b439340/src/endoexport/__init__.py#L1-L5 ). If anyone knows how to get around this, please let me know!

Related discussions:

Migrated:

Tagging @seanbreckenridge as you were interested in that too, let me know if you have some thoughts!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
karlicosscommented, Sep 26, 2020

All right, I converted a few more modules:

, and added HPI support with a backwards compatible fallback https://github.com/karlicoss/HPI/pull/83

I’ve tested for a bit and seems fine, but I’ll leave it for a couple of days just to be more sure, and then update the docs, and merge everything in one go.

0reactions
karlicosscommented, Feb 21, 2021

Right! So, I added a thing to HPI that can parse the requirements (via ast module, so there won’t be any import errors or something). So now it’s possible to use something like hpi module install my.endomondo, and it will install the required dependencies. Or run hpi module requires my.endomondo which will dump the dependencies in stdout (in case the user has some custom install process for dependencies). Seems like a reasonable compromise without forcing any special plugin architecture, guess okay to close this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependency Management with Pip, Python's Package Manager
pip install –upgrade pip. The pip command installs packages and their dependencies from PyPI (Python Package Index) by default:.
Read more >
Using Python's pip to Manage Your Projects' Dependencies
In this example, you run pip with the install command followed by the name of the package that you want to install. The...
Read more >
Migrating Python packages - UVA Research Computing
In this how-to we will discuss pip and conda . You will need to load the module for the newer Python version. For...
Read more >
Managing Python packages the right way - Opensource.com
When installing packages, pip will first resolve the dependencies, check if they are already installed on the system, and, if not, install them....
Read more >
Managing Python Dependencies with Requirements.txt
This is normally done by using pip freeze > requirements.txt, which records an environment's current package list into requirements.txt. Since ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found