Coder Social home page Coder Social logo

Comments (7)

FRidh avatar FRidh commented on July 21, 2024

Just executing or importing the module should install the necessary dependencies.

Module names are not unique; multiple packages can provide modules with the same name.

Furthermore, pipfile shall provide a deterministic way to describe an environment; installing on demand defies the point because you introduce state. (How will one know what version of django will be installed when importing?)

from pipfile.

lonetwin avatar lonetwin commented on July 21, 2024

Just executing or importing the module should install the necessary dependencies.

Module names are not unique; multiple packages can deliver modules with the same name.

Right, but resolving that ambiguity would be done by checking the pipfile. That's no different than what pip/pipfile will do, right ? A MetaPathFinder implementation would load a pipfile . What I am suggesting is moving the call to pip install .. into a hook that gets called at import time.

Furthermore, pipfile shall provide a deterministic way to describe an environment; installing on demand defies the point because you introduce state. (How will one know what version of django will be installed when importing?

By loading the pipfile/Pipfile.lock in the MetaPathFinder implementation ?

from pipfile.

FRidh avatar FRidh commented on July 21, 2024

By loading the pipfile/Pipfile.lock in the MetaPathFinder implementation ?

And why would one ever want that? If you need an environment with packages, then you build that environment and then start using it. Why would you build a smaller version first and then install during runtime? Just so you don't have to do a pip install Pipfile.lock in advance?

Anyway, Pipfile.lock is supposed to be easily readable so I don't see any issue preventing you from parsing it and installing from it during runtime.

from pipfile.

lonetwin avatar lonetwin commented on July 21, 2024

Why would you build a smaller version first and then install during runtime? Just so you don't have to do a pip install Pipfile.lock in advance?

I'm sorry but I'm not sure what you mean by "build a smaller version first and then install during runtime".

The example above doesn't do that, neither was I suggesting that we do that. The reason one would want to do what I suggested is you can tell users, "download and run foo" rather than telling them to "download, run pip install -r/-p whatever and run foo" -- yeah it doesn't seem like a big deal, I just was thinking from a distribution point of view where the only necessary command line to (for instance) run a UI based python package can be avoided.

Anyway, Pipfile.lock is supposed to be easily readable so I don't see any issue preventing you from parsing it and installing from it during runtime.

Yep, thanks. On IRC there were a number of valid reason why doing something like this might be fraught with difficulties so I'll close this. Although, I think packaging and distributing modules this way in predictable environments would not be a bad thing.

Thanks for your attention.

from pipfile.

FRidh avatar FRidh commented on July 21, 2024

The example above doesn't do that, neither was I suggesting that we do that. The reason one would want to do what I suggested is you can tell users, "download and run foo" rather than telling them to "download, run pip install -r/-p whatever and run foo" -- yeah it doesn't seem like a big deal, I just was thinking from a distribution point of view where the only necessary command line to (for instance) run a UI based python package can be avoided.

That is an interesting use case. You do not want to pollute your global site packages I would imagine (or whatever env you're in at that moment), so a better approach would be to create a new Python env first.

With Nix we have something like that actually:

#! /usr/bin/env nix-shell
#! nix-shell -i python -p 'python.withPackages(packages: [ packages.prettytable])'

import prettytable

# Print a simple table.
t = prettytable.PrettyTable(["N", "N^2"])
for n in range(1, 10): t.add_row([n, n * n])
print t

When executed, the script builds an environment where there's a Python interpreter along with that package.

I guess you could do something similar to this in Python by running the file twice (a bit similar to what is done with setup.py and setup_requires, but it won't ever be exactly reproducible, because you don't know the state of the first interpreter.

from pipfile.

xavfernandez avatar xavfernandez commented on July 21, 2024

you can tell users, "download and run foo" rather than telling them to "download, run pip install -r/-p whatever and run foo"

@lonetwin You might want to take a look at https://pypi.org/project/rwt/

from pipfile.

lonetwin avatar lonetwin commented on July 21, 2024

@xavfernandez thanks! Yes, rwt appears to be pretty much what @FRidh describes as a possible approach.

from pipfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.