2

Initial question (2020-02-15)

I'm building a python library: my_custom_library, with standard requirements (NumPy, pandas, librosa ...) and custom functions.

I would like to build a wheel of my_custom_library to then pip install this library on python3.8 32bits on windows10 on a machine with no access to internet (flash drive transfert). This install should be a "true" windows10 install and should not require WSL.

I would consider the packaging a success if I could produce one file my_custom_library-0.0.0-win32.whl similar to numpy-1.18.1-cp38-cp38-win32.whl on https://pypi.org/project/numpy/#files. This package is meant to stay private, I don't want to publish anything on pypi.

What is the best practice to build the wheel of my_custom_library for windows10 ?

What is the shortest list of commands to do that ?

From what I saw, it seems I need to build the wheel on the same OS as the OS where the wheel will be installed.

Can I build the wheel on a linux machine (ubuntu 18.04LTS) and install it on windows10 ?

If it's possible, what is the shortest list of commands to do that ?


Requirements (2020-02-17)

my_custom_library will import many well-known libraries including:

librosa==0.7.1 
matplotlib==3.1.1
numpy==1.16.4
opencv-python==4.1.2.30
pandas==0.24.2
scikit-learn==0.21.3
scipy==1.3.2
sinoroc
  • 9,658
  • 1
  • 13
  • 39
Alex
  • 92
  • 8
  • The dependencies are not really relevant for this problem. What have you already tried so far? Have you already tried building a wheel of your project? What are you using to package your project: _setuptools_, _poetry_, _flit_, something else? In case of _setuptools_, have you already tried to run `python3 setup.py bdist_wheel`? – sinoroc Feb 17 '20 at 09:11
  • I tried to install the packages with the wheels downloaded on my linux machine `pip download -r requirements.txt`. At the begining of the install, I got an error indicating that the plateform was not supported. I checked the requirements whell, they had CPU and OS tags. To give some context. I need to install the package on a machine without any internet acces. I have to bring all the requirements and *my_custom_library* on a flash drive to set up everything. The machine where the installation takes place has windows, python and pip installed. – Alex Feb 18 '20 at 09:51

1 Answers1

1

Can I build the wheel on a linux machine (ubuntu 18.04LTS) and install it on windows10 ?

Pure Python library — yes. Actually a pure Python library doesn't need to be platform-specific at all, you can build a universal wheel or use sdist (source distribution).

But if the library has code written in C/C++ then no, you have to build it on an exact platform (processor architecture, minimal OS version, exact Python version). You can build 32-bit library on a 64-bit Windows using 32-bit Python. But not the other way around — you cannot build 64-bit library on a 32-bit Windows.

phd
  • 57,284
  • 10
  • 68
  • 103
  • *my_custom_library* will import numpy, which has several different wheels on its pypi page ( https://pypi.org/project/numpy/#files ). Do that mean I will have to build the wheel on similar machine ? If not what command should I use to build package the library in one wheel ? – Alex Feb 17 '20 at 08:20
  • 1
    No. Just importing doesn't make your code platform-dependent. Pure Python modules (regardless of their dependencies — `pip` will install dependencies separately, they aren't parts of your wheel) don't require compilation. Only if your package contain code in C/C++ you need to compile it and then you need a similar machine. Virtual machines or Docker containers are ok for that. – phd Feb 17 '20 at 11:37
  • Thanks, to make sure I understand: 1. I do not have to do anything specific for my *my_custom_library* in pure python. 2. I have to take the wheels of the packages in the requirements with C/C++ code (numpy ...) that are adapted to the machine. Once I moved all the wheels (requiements + *my_custiom_package*) to the machine without internet (flashdrive install). Should I do something specific to install the packages ? Do I only have to type `pip install my_custiom_package` ? Or is there an order to install the dependencies ? – Alex Feb 18 '20 at 09:39
  • 1
    https://stackoverflow.com/a/14447068/7976758: `pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt` – phd Feb 18 '20 at 10:17
  • thanks phd, I got everything I need with those two references and your insight – Alex Feb 18 '20 at 10:22