pythonpippackage

Building and installing a python package locally


There is a PyPi package i wanted to install to access some API's. After installing I noticed the following error:

conda 24.7.1 requires requests<3,>=2.28.0, but you have requests 2.27.1 which is incompatible.

So i tried to update the requests to 2.28.0 but got the following error:

XXX requires requests==2.27.1, but you have requests 2.28.0 which is incompatible.

So, basically the package (XXX) i want to use is incompatible with Conda, however as it's open source, i made an issue, then i went on and also fixed this issue and made a pull request, however, as the project seems dead for 2 years, i doubt it ever gonna end up in the repository and be published on PyPi.

Can i build this package locally and install it for myself and use it? im new to python but i do have experience in other languages.

I tried github actions, but it builds for PyPi for releasing, which I don't want to do, because this is someone else's work and I just made some slight changes to fix a certain bug.

Update: I thank @Markus Hirsimäki for his help, but i actually ended up re-writing the whole API from the ground up. Took a lot of time, but it works and up-to-date. For whom face this issue with Tabdeal API, i will soon public the repository on github and maybe publish the package on PyPi.(if possible by me, i don't know anything about publishing yet)


Solution

  • If the build steps are visible in the source code of the repository, you could simply run then manually on your local machine. After the build is done you can install the package locally using pip and the file you just built.

    The exact steps to do the installation depend on the project.


    Edit based on the comments provided:

    You can probably get it working by doing pip install websocket-client==1.3.3 and copying this folder locally https://github.com/Tabdeal-Exchange/tabdeal-python/tree/master/tabdeal

    Then you can just >>> import tabdeal if you are in the folder that contains the tabdeal folder you just downloaded.

    If this approach works, you can set up your own build and packaging process around it. The easiest way would be to copy it from somewhere https://github.com/hirsimaki-markus/importmonkey would probably be suitable for copying minimal build steps from. Essentially it boils down to python -m build --wheel when you have the pyproject.toml and source code placed as shown in my example.