Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Python: change generated package name #1507

Merged
merged 2 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ private ViewModel generateMetadataView(
SurfaceNamer surfaceNamer,
String outputPath) {
List<ApiMethodView> exampleMethods = generateExampleMethods(model, productConfig);
String gapicPackageName =
surfaceNamer.getGapicPackageName(packageConfig.packageName(TargetLanguage.PYTHON));
return metadataTransformer
.generateMetadataView(packageConfig, model, template, outputPath, TargetLanguage.PYTHON)
.namespacePackages(computeNamespacePackages(productConfig.getPackageName(), surfaceNamer))
Expand All @@ -178,6 +180,7 @@ private ViewModel generateMetadataView(
.clientModules(clientModules(surfaceNamer))
.apiModules(apiModules(packageConfig.apiVersion()))
.typeModules(typesModules(surfaceNamer))
.gapicPackageName(gapicPackageName)
.protoPackageDependencies(generateProtoPackageDependencies())
.additionalDependencies(generateAdditionalDependencies())
.readmeMetadata(
Expand All @@ -187,7 +190,7 @@ private ViewModel generateMetadataView(
.fullName(model.getServiceConfig().getTitle())
.apiSummary(model.getServiceConfig().getDocumentation().getSummary())
.hasMultipleServices(false)
.gapicPackageName("gapic-" + packageConfig.packageName(TargetLanguage.PYTHON))
.gapicPackageName(gapicPackageName)
.majorVersion(packageConfig.apiVersion())
.developmentStatusTitle(
metadataNamer.getReleaseAnnotation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
import com.google.common.collect.Iterables;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/** The SurfaceNamer for Python. */
public class PythonSurfaceNamer extends SurfaceNamer {
Expand All @@ -60,6 +62,12 @@ public PythonSurfaceNamer(String packageName) {
packageName);
}

private static final Pattern VERSION_PATTERN =
Pattern.compile(
"^([vV]\\d+)" // Major version eg: v1
+ "([pP]\\d+)?" // Point release eg: p2
+ "(([aA]lpha|[bB]eta)\\d*)?"); // Release level eg: alpha3

@Override
public SurfaceNamer cloneWithPackageName(String packageName) {
return new PythonSurfaceNamer(packageName);
Expand Down Expand Up @@ -96,6 +104,15 @@ public String getVersionedDirectoryNamespace() {
return namespace.substring(0, namespace.lastIndexOf('.'));
}

@Override
public String getGapicPackageName(String configPackageName) {
List<String> parts = Arrays.asList(configPackageName.split("-"));
if (VERSION_PATTERN.matcher(parts.get(parts.size() - 1)).matches()) {
return Joiner.on("-").join(parts.subList(0, parts.size() - 1));
}
return configPackageName;
}

@Override
public String getFormattedVariableName(Name identifier) {
return localVarName(identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install gapic-google-cloud-library-v1
<your-env>/bin/pip install google-cloud-library


Windows
Expand All @@ -58,7 +58,7 @@ Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install gapic-google-cloud-library-v1
<your-env>\Scripts\pip.exe install google-cloud-library

Preview
~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install gapic-google-cloud-library-v1
<your-env>/bin/pip install google-cloud-library


Windows
Expand All @@ -58,7 +58,7 @@ Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install gapic-google-cloud-library-v1
<your-env>\Scripts\pip.exe install google-cloud-library

Next Steps
~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
============== file: docs/conf.py ==============
# -*- coding: utf-8 -*-
#
# gapic-google-cloud-library-v1 documentation build configuration file
# google-cloud-library documentation build configuration file
#
# This file is execfile()d with the current directory set to its
# containing dir.
Expand Down Expand Up @@ -61,7 +61,7 @@ source_suffix = '.rst'
master_doc = 'index'

# General information about the project.
project = u'gapic-google-cloud-library-v1'
project = u'google-cloud-library'
copyright = u'2017, Google'
author = u'Google APIs'

Expand Down Expand Up @@ -215,7 +215,7 @@ html_theme = 'sphinx_rtd_theme'
#html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'gapic-google-cloud-library-v1-doc'
htmlhelp_basename = 'google-cloud-library-doc'

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -237,7 +237,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'gapic-google-cloud-library-v1.tex', u'gapic-google-cloud-library-v1 Documentation',
(master_doc, 'google-cloud-library.tex', u'google-cloud-library Documentation',
author, 'manual'),
]

Expand Down Expand Up @@ -267,7 +267,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'gapic-google-cloud-library-v1', u'gapic-google-cloud-library-v1 Documentation',
(master_doc, 'google-cloud-library', u'google-cloud-library Documentation',
[author], 1)
]

Expand All @@ -281,8 +281,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'gapic-google-cloud-library-v1', u'gapic-google-cloud-library-v1 Documentation',
author, 'gapic-google-cloud-library-v1', 'GAPIC library for the {metadata.shortName} v1 service',
(master_doc, 'google-cloud-library', u'google-cloud-library Documentation',
author, 'google-cloud-library', 'GAPIC library for the {metadata.shortName} v1 service',
'APIs'),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
============== file: docs/conf.py ==============
# -*- coding: utf-8 -*-
#
# gapic-google-cloud-library-v1 documentation build configuration file
# google-cloud-library documentation build configuration file
#
# This file is execfile()d with the current directory set to its
# containing dir.
Expand Down Expand Up @@ -61,7 +61,7 @@ source_suffix = '.rst'
master_doc = 'index'

# General information about the project.
project = u'gapic-google-cloud-library-v1'
project = u'google-cloud-library'
copyright = u'2017, Google'
author = u'Google APIs'

Expand Down Expand Up @@ -215,7 +215,7 @@ html_theme = 'sphinx_rtd_theme'
#html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'gapic-google-cloud-library-v1-doc'
htmlhelp_basename = 'google-cloud-library-doc'

# -- Options for LaTeX output ---------------------------------------------

Expand All @@ -237,7 +237,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'gapic-google-cloud-library-v1.tex', u'gapic-google-cloud-library-v1 Documentation',
(master_doc, 'google-cloud-library.tex', u'google-cloud-library Documentation',
author, 'manual'),
]

Expand Down Expand Up @@ -267,7 +267,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'gapic-google-cloud-library-v1', u'gapic-google-cloud-library-v1 Documentation',
(master_doc, 'google-cloud-library', u'google-cloud-library Documentation',
[author], 1)
]

Expand All @@ -281,8 +281,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'gapic-google-cloud-library-v1', u'gapic-google-cloud-library-v1 Documentation',
author, 'gapic-google-cloud-library-v1', 'GAPIC library for the {metadata.shortName} v1 service',
(master_doc, 'google-cloud-library', u'google-cloud-library Documentation',
author, 'google-cloud-library', 'GAPIC library for the {metadata.shortName} v1 service',
'APIs'),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install gapic-google-cloud-library-v1
<your-env>/bin/pip install google-cloud-library


Windows
Expand All @@ -58,7 +58,7 @@ Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install gapic-google-cloud-library-v1
<your-env>\Scripts\pip.exe install google-cloud-library

Preview
~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install gapic-google-cloud-library-v1
<your-env>/bin/pip install google-cloud-library


Windows
Expand All @@ -58,7 +58,7 @@ Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install gapic-google-cloud-library-v1
<your-env>\Scripts\pip.exe install google-cloud-library

Next Steps
~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class LibraryServiceClient(object):

# Finally, track the GAPIC package version.
metrics_headers['gapic'] = pkg_resources.get_distribution(
'gapic-google-cloud-library-v1',
'google-cloud-library',
).version

# Load the configuration defaults.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class NoTemplatesAPIServiceClient(object):

# Finally, track the GAPIC package version.
metrics_headers['gapic'] = pkg_resources.get_distribution(
'gapic-google-cloud-library-v1',
'google-cloud-library',
).version

# Load the configuration defaults.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install_requires = [
]

setup(
name='gapic-google-cloud-library-v1',
name='google-cloud-library',
version='0.15.0',
author='Google, Inc.',
author_email='googleapis-packages@google.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ install_requires = [
]

setup(
name='gapic-google-cloud-library-v1',
name='google-cloud-library',
version='0.15.0',
author='Google, Inc.',
author_email='googleapis-packages@google.com',
Expand Down