简体   繁体   中英

Using setup.py and requirements.txt to overwrite package with a github version?

I am working on a github project that will eventually be released on both conda and PyPl. Because of PyPl (and current development needs) I need to make the installation work using this command: python -m pip install -e. (from inside the github cloned folder - pip 21)

However, my project has a dependency from a forked github repo. The problem I have is that I do not find a way to install the package from that fork using the command above, ....but I have to. Any trick I could find either got me nothing or the prod version of the repo. The only two things that worked are (1) manual or scripted launch of pip install [cannot do this, need setup.py to install things] (2) using conda [cannot rely on conda alone, I need the regular pip to work].

Can you please help me or point me in the right direction?

I use a requirements.txt that contains this line at the bottom:

...
-e git+https://github.com/jojurgens/pyqode.qt.git@master#egg=pyqode.qt

and a setup.py that contains this

with open(here / "requirements.txt", encoding="utf-8") as f:
    requirements = f.read().splitlines()

setup(
    name="qiskit_metal",
    version="0.0.2",
    install_requires=requirements,
)

On execution I get this error:

...error in setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Parse error at "'-e git+h'": Expected W:(abcd...)

I think what you should specify is the version of Shapely on the requirements, for example Shapely==<version> . If you want to install from differente source (and not from pip), do it outside of requirements.txt. For that you can evoke a bash command inside of your python code.

Actually I was finally able to find an answer. For who may need this info, here is what I did:

In requirements.txt I have changed the line to this:

pyqode.qt @ git+https://github.com/jojurgens/pyqode.qt.git#egg=pyqode.qt

that alone took care of the error.

That also solved my other (not described here) problem about "updating" the conda environment without corrupting it. So now I update the environment with just the same install command (as opposed to the update command, which does not work) python -m pip install -e.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM