8

My repository contains my own python module and a submodule to one of its dependencies which has its own setup.py.

I'd like to call the dependency's setupy.py when installing my own lib, how is it possible?

My first attempt:

 $ tree
.
├── dependency
│   └── setup.py
└── mylib
    └── setup.py


 $ cat mylib/setup.py 
from setuptools import setup

setup(
    name='mylib',
    install_requires= ["../dependency"]
    # ...
)

$ cd mylib && python setup.py install
error in arbalet_core setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'../depen'"

However install_requires does not accept paths.

My second attempt was to use dependency_links=["../dependency"] with install_requires=["dependency"] however a dependency of the same name already exists in Pypi so setuptools tries to use that version instead of mine.

What's the correct/cleanest way?

1
  • Maybe this is possible using dependency_links using a file:// url as explained here: stackoverflow.com/questions/32688688/…. Can't you rename the dependency if the code is under your control? Commented Dec 6, 2016 at 15:25

1 Answer 1

1

A possible solution is to run a custom command before/after the install process.

An example:

from setuptools import setup
from setuptools.command.install import install

import subprocess

class InstallLocalPackage(install):
    def run(self):
        install.run(self)
        subprocess.call(
            "python path_to/local_pkg/setup.py install", shell=True
        )

setup(
    ...,
    cmdclass={ 'install': InstallLocalPackage }
)
Sign up to request clarification or add additional context in comments.

Comments

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.