Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trouble Installing In-House Python Package via pip on Windows from Local Server

I’m trying to install a custom, in-house Python package from a local server onto Windows machines in my LAN. I’ve followed the steps below, but I’m encountering an issue.

Summarized steps:

  • Created a custom package with a setup.py file.
  • Generated a wheel file for the package.
  • Hosted the wheel file on a local server.
  • Modified pip.ini for the client machine.
  • Attempted package installation, but encountered errors.

Detailed steps:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • Created a setup.py following this form:
from setuptools import setup, find_packages

# Define package metadata
name = 'sptools'
version = '0.1'
author = 'author'
author_email = 'email'
description = 'description'
url = 'url'

# Define package dependencies
install_requires = [
    'requests==2.31.0',
    'seaborn==0.13.0',
    'torch==2.0.0',
    'tqdm==4.65.0',
    'utils==1.0.1',
    'visualize==0.5.1'
]

# Define packages to include (you can use find_packages())
packages = find_packages()

# Define classifiers for your package
classifiers = [
    'Development Status :: 3 - Alpha',
    'Intended Audience :: Developers',
    'License :: Internal',
    'Programming Language :: Python :: 3.10',
]

# Define the setup configuration
setup(
    name=name,
    version=version,
    author=author,
    author_email=author_email,
    description=description,
    url=url,
    install_requires=install_requires,
    packages=packages,
    classifiers=classifiers,
)
  • Created a .whl for my files, that if installed locally works as expected. The wheel file’s name is sptools-0.1-py3-none-any.whl

  • moved the wheel onto a server, under ~/packages/sptools-0.1-py3-none-any.whl

  • host the files with python -m http.server, and indeed, the file can be manually downloaded with
    wget http://[server_IP:port]/sptools-0.1-py3-none-any.whl

  • Configured pip on the Client computer, (Windows OS) by modifying pip.ini. This is necessary, as I understand it, for pip to know to not only look withing the pypi.org repositories, but also the local one:

[global]
no-cache-dir = true
index-url = http://[ip:port]/
trusted-host = [ip]

[install]
trusted-host = pypi.org pypi.python.org pypi.ngc.nvidia.com
  • Lastly, I have tried to install the package on the client machine, using both:
pip install sptools
# or 
pip install --trusted-host [ip] sptools

Error Messages:

ERROR: Could not find a version that satisfies the requirement sptools (from versions: none)
ERROR: No matching distribution found for sptools

while on the Server I get:

[client-ip] - - [11/Oct/2023 17:56:38] code 404, message File not found
[client-ip] - - [11/Oct/2023 17:56:38] "GET /sptools/ HTTP/1.1" 404 -
[client-ip] - - [11/Oct/2023 17:56:39] code 404, message File not found
[client-ip] - - [11/Oct/2023 17:56:39] "GET /pip/ HTTP/1.1" 404 -

More details:

  • I would like to further state that I have tried inside and outside a conda environment
  • I have tripple checked the names to be exactly the same.
  • I have tested with a public wheel (requests package) and the behaviour is the same
  • I have succesfully installed this why using wget + pip install .whl
  • I have tested with pip config list to make sure the config that is used is the one that I modified

I suspect this is an issue with the pip.ini configuration. Can anyone provide advice on how to resolve this issue? Your help is greatly appreciated.

>Solution :

Your in-house repository needs to follow the Simple Repository API.

In particular, that means that your wheel files need to be placed in directories named after the normalized name of their distributions.

Move sptools-0.1-py3-none-any.whl to a directory named sptools:

<http server root>
└── sptools
    └── sptools-0.1-py3-none-any.whl

Make sure that you can retrieve the wheel file with

$ wget http://[server_IP:port]/sptools/sptools-0.1-py3-none-any.whl

See also Hosting your own simple repository from the Python Packaging docs.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading