5

Please before flagging as duplicate, I have tried a bunch of solutions including one here but no luck

I have created a simple tool to do some tasks and was able to package it successfully.

When trying to install it, I get the desired effect when I use python setup.py install but pip install package_name just installs the package but no post installation script.

Here is part of my code;

setup.py

from distutils import setup
from app.scripts import *

setup(

        #Application name
        name = "my-app-name",

        version = "my-app-version",
        author = "my-name",
        author_email = "my-email",
        packages = ['app'],
        include_package_data = True,
        license = 'MIT',
        url = "https://my-url",
        description = "description",
        install_requires = ["flake8"],
        cmdclass = {
            "install":Post_install
        }
    )

scripts.py

from distutils.command.install import install
import os

class Post_install(install):

    @staticmethod
    def func():      
        return True

    def run(self):
        install.run(self)
        #Pre install actions
        if Post_install.func():
            print("Bingo")
        else:
            print("Failed")

Thanks :)

PS I run pip install after uploading the package.

3
  • Is it possible that you're installing an earlier version of your library? Does it take a while for the pip servers to update? Commented Jul 29, 2017 at 13:15
  • It's hard to tell since you've stripped the code of certain details. Commented Jul 29, 2017 at 13:16
  • @SwiftsNamesake I have verified the version of the library I'm installing, it is the right one, I'm sure of that Commented Jul 29, 2017 at 19:02

1 Answer 1

1
+50

Install the package directly from your GitHub repository:

pip install -vvv git+url/for/github/repo@my-branch

You mentioned in the chat that you'd like to add this package to your requirements.txt file. See this question for details:

-e git://github.com/path/to/project

Former answer (rejected by the OP):

I managed to recreate the issue you're having. It seems to be a matter of pip install silencing or redirecting output (as indicated by an answer to this question).

The solution is to add the option -vvv after pip install. I'm guessing the v stands for verbose.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for the answer, I've also tried all those proposed options and it seems not to work with pip, "though working fine with python setup.py install
To be clear, you're saying that pip install -vvv [name of package] doesn't work? If so, that's really odd, since I copied your files and tried it myself on a local dummy package (pip install -vvv .).
It installs the package, but post install script still not running
Yeah local install with setup.py install also works fine " as I wrote in question", But pip oddly doesn't run the post install scripts
I meant a local pip install
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.