Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sa868-interface
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
chrissi^
sa868-interface
Commits
7796c969
Commit
7796c969
authored
5 years ago
by
chrissi^
Browse files
Options
Downloads
Patches
Plain Diff
Add python setup
Signed-off-by:
Chris Fiege
<
chris@tinyhost.de
>
parent
673e145a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fastentrypoints.py
+107
-0
107 additions, 0 deletions
fastentrypoints.py
setup.py
+22
-0
22 additions, 0 deletions
setup.py
with
129 additions
and
0 deletions
fastentrypoints.py
0 → 100644
+
107
−
0
View file @
7796c969
# Copyright (c) 2016, Aaron Christianson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''
Monkey patch setuptools to write faster console_scripts with this format:
import sys
from mymodule import entry_function
sys.exit(entry_function())
This is better.
(c) 2016, Aaron Christianson
http://github.com/ninjaaron/fast-entry_points
'''
from
setuptools.command
import
easy_install
import
re
TEMPLATE
=
'''
\
# -*- coding: utf-8 -*-
import re
import sys
from {0} import {1}
if __name__ ==
'
__main__
'
:
sys.argv[0] = re.sub(r
'
(-script\.pyw?|\.exe)?$
'
,
''
, sys.argv[0])
sys.exit({2}())
'''
@classmethod
def
get_args
(
cls
,
dist
,
header
=
None
):
"""
Yield write_script() argument tuples for a distribution
'
s
console_scripts and gui_scripts entry points.
"""
if
header
is
None
:
header
=
cls
.
get_header
()
spec
=
str
(
dist
.
as_requirement
())
for
type_
in
'
console
'
,
'
gui
'
:
group
=
type_
+
'
_scripts
'
for
name
,
ep
in
dist
.
get_entry_map
(
group
).
items
():
# ensure_safe_name
if
re
.
search
(
r
'
[\\/]
'
,
name
):
raise
ValueError
(
"
Path separators not allowed in script names
"
)
script_text
=
TEMPLATE
.
format
(
ep
.
module_name
,
ep
.
attrs
[
0
],
'
.
'
.
join
(
ep
.
attrs
))
args
=
cls
.
_get_script_args
(
type_
,
name
,
header
,
script_text
)
for
res
in
args
:
yield
res
easy_install
.
ScriptWriter
.
get_args
=
get_args
def
main
():
import
os
import
re
import
shutil
import
sys
dests
=
sys
.
argv
[
1
:]
or
[
'
.
'
]
filename
=
re
.
sub
(
'
\.pyc$
'
,
'
.py
'
,
__file__
)
for
dst
in
dests
:
shutil
.
copy
(
filename
,
dst
)
manifest_path
=
os
.
path
.
join
(
dst
,
'
MANIFEST.in
'
)
setup_path
=
os
.
path
.
join
(
dst
,
'
setup.py
'
)
# Insert the include statement to MANIFEST.in if not present
with
open
(
manifest_path
,
'
a+
'
)
as
manifest
:
manifest
.
seek
(
0
)
manifest_content
=
manifest
.
read
()
if
not
'
include fastentrypoints.py
'
in
manifest_content
:
manifest
.
write
((
'
\n
'
if
manifest_content
else
''
)
+
'
include fastentrypoints.py
'
)
# Insert the import statement to setup.py if not present
with
open
(
setup_path
,
'
a+
'
)
as
setup
:
setup
.
seek
(
0
)
setup_content
=
setup
.
read
()
if
not
'
import fastentrypoints
'
in
setup_content
:
setup
.
seek
(
0
)
setup
.
truncate
()
setup
.
write
(
'
import fastentrypoints
\n
'
+
setup_content
)
print
(
__name__
)
This diff is collapsed.
Click to expand it.
setup.py
0 → 100644
+
22
−
0
View file @
7796c969
#!/usr/bin/env python3
import
fastentrypoints
from
setuptools
import
setup
,
find_packages
setup
(
name
=
"
sa868
"
,
version
=
"
0.1.0
"
,
author
=
"
Chris Fiege
"
,
author_email
=
"
chris@tinyhost.de
"
,
description
=
"
Command line tool to control a SA868 Walkie-Talkie Module
"
,
packages
=
[
'
sa868
'
],
entry_points
=
{
'
console_scripts
'
:
[
'
sa868 = sa868.__init__:main
'
,
]
},
install_requires
=
[
'
pyserial
'
,
],
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment