Let's say I have no internet, and a custom PyPI clone running at 10.0.0.2.
I want to be author a Python package that someone on my intranet can install. It has dependency X, which lives on my custom PyPI clone.
How can I author my package so that someone can install it, pulling in dependency X, without needing to apply any special pip configuration? That is, how can I author my package so that installing it pulls in custom PyPI dependencies? In this constraint, I only have access to edit the setup.py
.
The context is that I am using a managed service that accepts a tar'd Python package with a setup.py file, and then runs pip to install everything. I don't have access to how pip is called, or any environmental config on that system.
Is there a way through setup.py alone to pull in packages from a custom IP address for a PyPI?
As far as I'm aware, you can't update the setup.py to point it to download dependencies from a specific server. However, the person that's executing the pip install can specify which server to use to look for the package and its dependencies with the -i flag like so
pip install -i http://localhost:8000 <package>
The dependencies can be specified in the setup.py, on the other hand. In setuptools.setup you can declare dependencies like so:
import sys
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="somepackage",
version="0.0.1",
author="Your Name",
author_email="[email protected]",
description="Some desc",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.8"
],
install_requires=["dependency1", "dependency2"]
)