Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer installation #115

Closed
fredrikaverpil opened this issue Jul 1, 2020 · 2 comments
Closed

Developer installation #115

fredrikaverpil opened this issue Jul 1, 2020 · 2 comments

Comments

@fredrikaverpil
Copy link

Hello and thank you for your great work on this setup! ❤️ 🤘

With your nox + poetry setup, it is currently not supported to perform a developer installation in conjunction with your install_with_constraints function.

I am adding something like this to my pyproject.toml:

my-dependency = { path = "../my-dependency" }

And if I then run one of my nox sessions, I get this:

ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /home/fredrik/code/repos/my-dependency
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)

This I get because pip is being used to conduct the installation and I guess that there is a limitation to what pip can currently do. The entry in the temporary constraints text file is: -e ../my-dependency

I'm wondering if this is a road worth pursuing, so I created this issue.

Perhaps I could remove the entries in the constraints file starting with -e. For any dependency removed, I could perhaps build a wheel using the pep517 module and then finally install this wheel via pip and the constraints file.

python -m pep517.build --source ../my-dependency --binary

Do you see any better alternative to this?
It would be nice to avoid the build and just do the install straight away, but I don't know if any tool supports this right now.

@cjolowicz
Copy link
Owner

cjolowicz commented Jul 2, 2020

Thanks for bringing this up. That's indeed a limitation of the technique used by install_with_constraints. PEP 517 does not support editable installs, so using the generated requirements file for path dependencies with their own pyproject.toml will fail.

There are two more options you could consider here:

  1. Explicitly mark the dependency as non-editable in pyproject.toml, or
  2. Remove the editable option from the generated requirements file

Explicitly mark the dependency as non-editable in pyproject.toml

If you add develop = false to the entry for the dependency in pyproject.toml, it will no longer be installed as editable. This will solve your problem, at the expense that both the Nox environment and the Poetry environment need to be updated every time you make changes to the dependency.

[tool.poetry.dependencies]
 python = "^3.8"
-my-dependency = {path = "../my-dependency"}
+my-dependency = {path = "../my-dependency", develop = false}

Remove the editable option from the generated requirements file

You could try to simply remove the leading -e from the generated requirements file on the fly. Parsing requirements files is unfortunately a slippery slope, as technically any pip options could occur on a line. But it might just work for your project.

You'll have to be careful to run nox instead of nox -r after making changes to the dependency, to ensure that the latest version gets installed into the Nox environment.

Essentially you'd do something like this in your install_with constraints function:

        with open(requirements.name) as io:
           lines = list(io)
        with open(requirements.name, mode="w") as io:
           for line in lines:
               if line.startswith("-e "):
                   line = line[len("-e ") :]
               io.write(line)

It seems that this path may lead to trouble, so I'd probably go with the first option.

@fredrikaverpil
Copy link
Author

fredrikaverpil commented Jul 4, 2020

Thanks for your suggestions. I'll see what works best...

I actually came across this one, which I feel will solve all these issues, if it were to be implemented: python-poetry/poetry#1644

If such groups were supported, we could skip using pip altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants