Skip to content

Commit

Permalink
Updates to use main entry point.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Apr 18, 2017
1 parent e219ee1 commit 2a7ec3b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 18 deletions.
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ At a minimum, you must set a ``formal_name`` key (the full, formal name for the
app) and a ``bundle`` key (the bundle identifier for the author organization -
usually a reverse domain name).

Alternatively, if you're starting from scratch, you can use `cookiecutter`_ to
generate a stub project with the required content::

$ pip install cookiecutter
$ cookiecutter https://github.com/pybee/briefcase-template

.. _cookiecutter: http://github.com/audreyr/cookiecutter

The ``icon`` attribute specifies the prefix of a path to a set of image files.
The name specified will be appended with a number of suffixes to construct
filenames for the various icon sizes needed on each platform. You should
Expand Down
6 changes: 5 additions & 1 deletion briefcase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def app_dir(self):
def app_packages_dir(self):
return os.path.join(os.getcwd(), self.resource_dir, 'app_packages')

@property
def version(self):
return self.distribution.get_version()

def generate_app_template(self):
print(" * Writing application template...")

Expand All @@ -165,7 +169,7 @@ def generate_app_template(self):
'bundle': self.bundle,
'year': date.today().strftime('%Y'),
'month': date.today().strftime('%B'),
'version': self.distribution.get_version(),
'version': self.version,
'version_code': self.version_code,
'guid': self.guid,
'secret_key': self.secret_key,
Expand Down
33 changes: 33 additions & 0 deletions briefcase/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def finalize_options(self):
def app_dir(self):
return os.path.join(os.getcwd(), self.dir)

@property
def version(self):
parts = self.distribution.get_version().split('.')

if len(parts) == 0:
return '1.0.0'
elif len(parts) == 1:
return '%s.0.0' % tuple(parts)
elif len(parts) == 2:
return '%s.%s.0' % tuple(parts)
else:
return '%s.%s.%s' % tuple(parts[:3])

def install_icon(self):
raise RuntimeError("Django doesn't support icons.")

Expand Down Expand Up @@ -69,3 +82,23 @@ def install_extras(self):

print(" - Building Webpack assets...")
subprocess.Popen([npm, "run", "build"], cwd=os.path.abspath(self.dir)).wait()

def post_run(self):
print()
print("Installation complete.")
print()
print("Before you run this Django project, you should review the value")
print("of the settings in django/briefcase/settings/.env to ensure they")
print("are appropriate for your machine.")
print()
print("Once you've confirmed the settings are OK, you should run:")
print()
print(" $ cd django")
print(" $ ./manage.py migrate")
print(" $ ./manage.py runserver")
print()
print("This will apply the initial migration and start a test server.")
print()
print("You can then point a web browser at http://127.0.0.1:8000 to")
print("view your running application.")
print()
17 changes: 6 additions & 11 deletions briefcase/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import distutils.command.install_scripts as orig
from pkg_resources import Distribution, PathMetadata
import shutil
import subprocess
import sys

from .app import app
Expand All @@ -28,15 +29,7 @@ def finalize_options(self):
self.support_dir = os.path.join(self.dir, 'python')

iconfile = '%s.ico' % self.icon
self.icon_filename = os.path.join(self.resource_dir, self.distribution.get_name() + os.path.splitext(iconfile)[1])

@property
def app_dir(self):
return self.support_dir

@property
def app_packages_dir(self):
return self.support_dir
self.icon_filename = os.path.join(self.app_dir, self.distribution.get_name() + os.path.splitext(iconfile)[1])

def install_icon(self):
shutil.copyfile('%s.ico' % self.icon, self.icon_filename)
Expand All @@ -48,5 +41,7 @@ def find_support_pkg(self):
version = "%s.%s.%s" % sys.version_info[:3]
return 'https://www.python.org/ftp/python/%s/python-%s-embed-amd64.zip' % (version, version)

# def install_extras(self):
# print(" * Creating executable...")
def install_extras(self):
print(" * Creating application link...")
subprocess.Popen(["powershell", "-File", "make_link.ps1"], cwd=os.path.abspath(self.dir)).wait()
os.remove(os.path.join(os.path.abspath(self.dir), 'make_link.ps1'))
13 changes: 8 additions & 5 deletions docs/tutorials/tutorial-1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ In this tutorial you will create a simple ios application using toga framework.
Update your ios project
-----------------------

In this step we assume that you followed the previous tutorial :doc:`/intro/tutorial-0.rst`.
In this step we assume that you followed the previous tutorial :doc:`/intro/tutorial-0.rst`.
First at all, you can clean your previous app in your ``iostutorial`` folder:

.. code-block:: bash
rm -rf iOS/
We are going to use the Toga framework, so we have to include the ``toga-ios`` requirement in the ``ios`` section
Expand Down Expand Up @@ -43,7 +43,7 @@ modified to be class-based:
def startup(self):
self.main_window = toga.MainWindow(self.name)
self.main_window.app = self
box = toga.Box()
button = toga.Button('Hello world', on_press=button_handler)
Expand All @@ -52,11 +52,14 @@ modified to be class-based:
self.main_window.content = box
self.main_window.show()
def button_handler(widget):
print("hello")
def main():
return HelloWorld('First App', 'org.pybee.helloworld')
Create the iOS app
------------------
Expand All @@ -65,7 +68,7 @@ Now you can invoke setuptools again:

.. code-block:: bash
$ python setup.py ios
Notice that the ``app_packages`` is not empty after the update, and it contains toga packages and their requirements.

Open the iOS project with Xcode
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
entry_points={
'distutils.commands': [
'android = briefcase.android:android',
'app = briefcase.app:app', # Don't call directly, but registration required
'app = briefcase.app:app', # Don't call directly, but registration required
'django = briefcase.django:django',
'ios = briefcase.ios:ios',
'linux = briefcase.linux:linux',
Expand Down

0 comments on commit 2a7ec3b

Please sign in to comment.