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

Add a developer mode #73

Closed
eliasdorneles opened this issue Sep 20, 2017 · 15 comments
Closed

Add a developer mode #73

eliasdorneles opened this issue Sep 20, 2017 · 15 comments

Comments

@eliasdorneles
Copy link
Contributor

Briefcase installs the platform requirements defined in the setup.py file.

For someone using briefcase-template, for example, this means that it will pip install into the $PLATFORM/app_packages directory the packages defined in the setup.py.

It would be nice to have a "platform developer mode", which would use a local version of those packages (specially useful for someone working on Toga).

One idea to implement this would be to provide a way of configuring alternative local versions for the requirements there, e.g.:

python setup.py TARGET --overrides package-overrides.json

And then, package-overrides.json could have something like:

{
    "toga": "/home/elias/src/toga/src/core/",
    "toga-android": "/home/elias/src/toga/src/android/"
}

This information would then be used by the install_platform_requirements function to feed pip the package names with the overrides applied.

@Ocupe
Copy link

Ocupe commented Sep 20, 2017

@eliasdorneles I would love this addition! However I would prefer a shorter syntax like:

python setup.py TARGET --dev

I would be nice to not have to write a json file and just take the packages from the venv. With json file could be a advanced feature but I think the default should be as simple as possible. With this being sad I have no idea how to make it a reality :).

@freakboy3742
Copy link
Member

@Ocupe @eliasdorneles and I talked about this - the problem is that your local venv won't have all the packages you need. For example, if you're developing for Android, you won't have toga-android installed locally.

So it's not enough to just say --dev (which I agree would be a preferable usage) -- you have to provide paths for all the dependencies you want to install from local sources as well.

That said, since end users are unlikely to have multiple development versions, we could say that --dev will always look for a requirements.dev file.

@freakboy3742
Copy link
Member

As for how to implement this - I don't think it will be that hard. install_app_requirements() and install_platform_requirements() both pass in a list of requirement strings. Each string needs to be parsed to extract the version identifier (if provided); that then gives you a raw list of packages. If requirements.dev file then lists packages and paths:

toga-core /Users/rkm/code/toga/src/core/toga
toga-cocoa /Users/rkm/code/toga/src/cocoa/toga_cocoa
colosseum /Users/rkm/code/colosseum/colosseum

you can filter the list of installed packages to only include files that aren't overridden; and then create symlinks using the directories specified for all the remainder.

@freakboy3742
Copy link
Member

Or... even better... don't symlink - pass in the local directory to the pip install process.

@ramiroluz
Copy link
Contributor

ramiroluz commented Oct 12, 2017

@eliasdorneles @freakboy3742 @Ocupe
I did something like this, parsed the file requirements.dev then I searched by the "key" on the lists:
distributions.install_requires and app_requires to override the names.

But some dependencies are "collected" from the package and are not in any list.

For example, the dependency toga-core come from toga-gtk. toga-gtk is on the list, toga-core is not.

So, if you want a local toga-core would be more difficult to get this done.

@eliasdorneles
Copy link
Contributor Author

@ramiroluz would you mind sharing what you've got anyway? I'd love to give it a try. :)
Thank you! <3

@ramiroluz
Copy link
Contributor

Ok, I will finish my idea, that is, everything that is declared in the dev-file will override the dependencies on the lists. Everything that is not on the lists but explicitly declared on the file will be appended to the app_requires list.

ramiroluz added a commit to ramiroluz/briefcase that referenced this issue Oct 13, 2017
ramiroluz added a commit to ramiroluz/briefcase that referenced this issue Oct 13, 2017
@ramiroluz
Copy link
Contributor

Done, @eliasdorneles what do you rater prefer:

  • Review the changes in my fork?
  • Or want me to do a PR?

@eliasdorneles
Copy link
Contributor Author

eliasdorneles commented Oct 13, 2017 via email

@freakboy3742
Copy link
Member

@ramiroluz That log indicates that the test suite wasn't able to start. That suggests there's something wrong with the PR itself - possibly a syntax error in a test file, or something hasn't been checked in.

Beekeeper just runs python setup.py test in the root of the GitHub repository checkout - so if that doesn't work locally, it won't work on CI either. If you need other arguments to be passed in, then you'll need to modify the beekeeper script to account for that.

@ramiroluz
Copy link
Contributor

ramiroluz commented Oct 15, 2017 via email

@jedie
Copy link
Contributor

jedie commented Mar 18, 2018

And a development mode is what I was looking for, but didn't know it until beeware/toga#315 (comment) ;)

Is it not just that running setup.py install platform requirements via pip with '--force-reinstall' ?

See: https://github.com/pybee/briefcase/search?q=%27--force-reinstall%27

e.g.: if toga installed as "editable" from github source, then it will be replace with the last PyPi package version, see: beeware/Python-Django-template#2 (comment)

Wouldn't it be the easiest thing if we just remove --force-reinstall away?
Then a developer can install the platform requirements by himself from source and can then run setup.py?

Installation from source is just something like this:

git clone https://github.com/pybee/toga.git
pip install -e toga/src/core
pip install -e toga/src/dummy
pip install -e toga/src/django
pip install -e toga/src/android
...

I will try this and report back.

EDIT:

Wouldn't it be the easiest thing if we just remove --force-reinstall away?

I have just tried it and now I see that this is not enough :(

OK, what's about something like this:

We "look" into "pip freeze" in all install_*_requirements() functions and install the requirement in the same way?

jedie added a commit to jedie/briefcase that referenced this issue Mar 18, 2018
@jedie
Copy link
Contributor

jedie commented Mar 18, 2018

I tried a POC here: #111

@freakboy3742
Copy link
Member

The 0.3 branch now includes a developer mode.

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

5 participants